DEV Community

loading...

Discussion on: How to approach solving a challenge during a coding interview

Collapse
teotcd profile image
JedDevs

Hello,
Not a javascript user here, (python and lua). Still found this a very insightful read.

I would like to add that simlifying code to such a degree to take up less lines can make it less readable, overall not making the end product much better in my opinion.
(Correct me if i'm wrong 🙂.)
But it's certainly interesting to see!
(Even if my limited understanding of js restricted me from understanding the final final solution fully.)

I quickly opened up trusty repl and did one up in python:

def FizzBuzz():
  for i in range (1,101):
    #print(i/3)
    if i%3 == 0 and i%5 == 0:
      print("FizzBuzz")
    elif i%3 == 0:
      print("Fizz")
    elif i%5 == 0:
      print("Buzz")
    else: 
      print(i)
FizzBuzz()
Collapse
teotcd profile image
JedDevs

I also wrote one up in lua, because I have um, no uh, life. 😊

function FizzBuzz()
  for i = 1,100 do
    --print(i)
    if i%3 == 0 and i%5 == 0 then
      print("FizzBuzz")
    elseif i%3 == 0 then
      print("Fizz")
    elseif i%5 == 0 then
      print("Buzz")
    else
      print(i)
    end
  end
end
FizzBuzz()
Collapse
adyngom profile image
Ady Ngom Author

"...because I have um, no uh, life" haha welcome to the club :)

Collapse
theodesp profile image
Collapse
adyngom profile image
Ady Ngom Author

Very readable and does the job for someone who does not code in Python. Life is complicated already, code does not need to be :)

Collapse
teotcd profile image
JedDevs

Merci Monsieur!

Thread Thread
adyngom profile image
Ady Ngom Author

lol je vous en prie :) (so polite)

Collapse
teotcd profile image
JedDevs

Any suggestions as too how I could level up my code would be 👌

Collapse
adyngom profile image
Ady Ngom Author

. Keep finding a working solution first and foremost,
. revisit and refactor when new concepts and better technique can significantly improve your working solution
. read and write (code) everyday
. (most important) share and teach anytime you have a holy s*** moment. teaching will force you to learn and get better

Thread Thread
teotcd profile image
JedDevs

Thank you for your reply, It was very helpful!

. revisit and refactor when new concepts and better technique can significantly improve your working solution

StackOverflow to the rescue!

. read and write (code) everyday

( and night!)

. (most important) share and teach anytime you have a holy s*** moment. teaching will force you to learn and get better.

I have certainly found this to be the case.
Back in highschool I sat next to two people who really struggled and helping them inturn really helped me improve my code and realise a better way to write it or engrain it in my memory!
On top of that I used to have to lead the class in middle school as my teacher would literally ask me and my friend for help as she was out of her depth! 😂