Andrew Libby on 13 Sep 2017 17:08:14 -0700 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: [PLUG] Why Can't Programmers.. Program? |
On 9/13/17 8:04 PM, Walt Mankowski wrote: > On Wed, Sep 13, 2017 at 07:42:37PM -0400, Andrew Libby wrote: >> >> Nice. I came up with a solution that I don't I saw, it's nothing >> amazing, but it does only a single modulus per loop: >> >> #!/usr/bin/env ruby >> >> 1.upto(100).each do |i| >> puts( >> case i % 15 >> when 0 then :FizzBuzz >> when 3,6,9,12 then :Fizz >> when 5,10 then :Buzz >> else i >> end >> ) >> end >> >> Andy > > Will challenged me to write it without using modulus at all. Here's a > straightforward C solution: > > https://gist.github.com/waltman/354d043fe13271c87bd4389e709ddf53 > > And one in Perl that doesn't use modulus or if: > > https://gist.github.com/waltman/82371164b7a50981d763c94ea1bade76 > > Walt > When I saw the pearl version, initially I thought to myself "Hey, that's cheating!" Then I smiled sand remarked "Well done Walt, well done.".
Attachment:
signature.asc
Description: OpenPGP digital signature
___________________________________________________________________________ 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