Gavin W. Burris on 13 Sep 2017 08:09:55 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Why Can't Programmers.. Program?


As soon as I read this, I was immediately compelled to write code. :P

for N in 1 to 100:
    msg = N
    modthree = N % 3
    modfive = N % 5
    if modthree == 0:
        if modfive == 0:
            msg = "FizzBuzz"
        else:
            msg = "Fizz"
    else if modfive == 0:
        msg = "Buzz"
    print msg

Now I wonder what the optimal nested conditionals would be...  That's a fun question!


On Wed 09/13/17 10:47AM EDT, ronpguilmet wrote:
> This is not New, but it is new to me. Apparently this is a programming interview question to weed out applicants. It's called FizzBuzz.
> Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".
> https://blog.codinghorror.com/why-cant-programmers-program/
> 
> 
> 
> Sent from my T-Mobile 4G LTE Device

> ___________________________________________________________________________
> Philadelphia Linux Users Group         --        http://www.phillylinux.org
> Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
> General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug


-- 
Gavin W. Burris
Senior Project Leader for Research Computing
The Wharton School
University of Pennsylvania
Search our documentation: http://research-it.wharton.upenn.edu/about/
Subscribe to the Newsletter: http://whr.tn/ResearchNewsletterSubscribe
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug