Interview problem – FizzBuzz

So, you try to pass an interview as a programmer. There are a few ways you’re tested, it’s not just coding skills but your ability to communicate.

Communicate, what do you mean, code either compiles and works or it don’t?

Well, no, so you live …


This content originally appeared on DEV Community and was authored by Chris Noring

So, you try to pass an interview as a programmer. There are a few ways you're tested, it's not just coding skills but your ability to communicate.

Communicate, what do you mean, code either compiles and works or it don't?

Well, no, so you live in a world with stakeholder and team members. In that world, you need to navigate and that means understanding a problem, asking clarifying questions and be prepared for changes and yes sometimes short deadlines.

So what can I expect on the interview then?

Well, for one, a problem, and not just a problem, you're expected to communicate from start to finish, through all the phases.

What phases?

Understand the problem

In this phase, you need to listen, repeat back what you heard and from there communicate assumptions. If those assumptions are incorrect, you may get clarifications. What you don't want to do is to just code away thinking you understood everything.

Problem breakdown

In this phase, you should start to think about how to break down a problem in easier parts, sub problems if you will. At the job, you will be given big and complicated tasks and you will be asked to break it down into smaller parts that you can solve. - That's the job, oh and coding :).

Start coding

At this point, start implementing the easier parts of your problem, a naive solution if you will. See if your interviewer has any comments. Then proceed until you have a working solution.

Cover all your bases

At this point, ensure you communicate any edge cases that you might need to handle and possible improvements to your code.

Here it's likely your interviewer may spot a bug or ask you to implement a new requirement. Don't panic, take your time and figure out how to solve.

Summary

In the last part, the interviewer may sum up the interview and ask general questions, but if you have communicated thus far, you've written reasonable code that mostly works, chances are you pass this interview.

So what problem am I likely to get, can you give m an example?

The problem : Fizz Buzz

Lets take a problem called Fizz Buzz. Here's the description:

Your code is divisible by 5 and 3. If both then print "FizzBuzz", if only by 3, then "Fizz" if only by 5, then "Buzz".

To approach this problem, ensure you understand its sub problems:

1) Divisible, that a number is divided and leaves no remainder and you at least in Python have a module operator to help you.
2) Understand what condition to implement first, i.e. you should start with divisible by 5 and 3 and then add the other conditions.

Here's a solution:

arr = range(30)
for item in arr:
  no = item + 1
  if no % 5 == 0 and no % 3 == 0:
    print(f"{no} FizzBuzz")
  elif no % 5 == 0:
    print(f"{no}: Buzz")
  elif no %3 == 0:
    print(f"{no} Fizz")
  else:
    print(f"{no}")

and yea, take your time implementing and COMMUNICATE cause you're tested on both skills.


This content originally appeared on DEV Community and was authored by Chris Noring


Print Share Comment Cite Upload Translate Updates
APA

Chris Noring | Sciencx (2022-07-06T21:35:00+00:00) Interview problem – FizzBuzz. Retrieved from https://www.scien.cx/2022/07/06/interview-problem-fizzbuzz/

MLA
" » Interview problem – FizzBuzz." Chris Noring | Sciencx - Wednesday July 6, 2022, https://www.scien.cx/2022/07/06/interview-problem-fizzbuzz/
HARVARD
Chris Noring | Sciencx Wednesday July 6, 2022 » Interview problem – FizzBuzz., viewed ,<https://www.scien.cx/2022/07/06/interview-problem-fizzbuzz/>
VANCOUVER
Chris Noring | Sciencx - » Interview problem – FizzBuzz. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/07/06/interview-problem-fizzbuzz/
CHICAGO
" » Interview problem – FizzBuzz." Chris Noring | Sciencx - Accessed . https://www.scien.cx/2022/07/06/interview-problem-fizzbuzz/
IEEE
" » Interview problem – FizzBuzz." Chris Noring | Sciencx [Online]. Available: https://www.scien.cx/2022/07/06/interview-problem-fizzbuzz/. [Accessed: ]
rf:citation
» Interview problem – FizzBuzz | Chris Noring | Sciencx | https://www.scien.cx/2022/07/06/interview-problem-fizzbuzz/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.