loading...

re: How to approach solving a challenge during a coding interview VIEW POST

FULL DISCUSSION
 

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()
 

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

 

. 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

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! 😂

 

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

 
 

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()
 

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

 
code of conduct - report abuse