[DFW.pm] Homework for the list, and for Oct 08 meeting

John Dexter john.dexter at psydefect.com
Wed Sep 24 14:19:34 PDT 2014


Again with some TIMTOWTDI. I'm trying to learn some Perl6 so here is my
FizzBuzz basketball attempt (definitely not golf anyway).

It's a full CLI application; complete with usage screen and some tests.
https://github.com/PsyDefect/App-FizzBuzz.git


John Dexter

On Fri, Sep 12, 2014 at 12:08 AM, kevin <kbrannen at pwhome.com> wrote:

> On 09/11/2014 02:03 PM, Tommy Butler wrote:
> ...
>
>> http://rosettacode.org/wiki/FizzBuzz
>>
>> Is all about the modulus operator.  To do it another way might be
>> creative but would almost certainly likely be less efficient.  The only
>> thing I can think of that world be faster is the cheat method I saw,
>> where you hard code into your program the known fizzes and buzzes,
>> spitting them out at the corresponding integer positions in the 1 to 100
>> loop.
>>
> ...
>
> You mean in the spirit of "Sieve of Eratosthenes" where you trade space of
> complexity? That's the only way I can think of to do it without the modulus
> operator.
>
> my @nums;
> for ($i=3 ; $i <= 100 ; $i += 3) { $nums[$i]++; }
> for ($i=5 ; $i <= 100 ; $i += 5) { $nums[$i] += 2; }
> my @strings = (0, "Fizz", "Buzz", "FizzBuzz");
> print (($strings[$nums[$_]] || $_) . "\n") for (1 .. 100);
>
> I don't think I'd call that cheating, but inefficient I'll agree with. :)
>
> By cheating, I assume the method where you create an array with 100
> hard-coded values? Yeah, I go with cheating there. :)
>
> Kevin
> _______________________________________________
>
> Dfw-pm mailing list
> Dfw-pm at pm.org
> http://mail.pm.org/mailman/listinfo/dfw-pm
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/dfw-pm/attachments/20140924/ff125e3c/attachment.html>


More information about the Dfw-pm mailing list