<div dir="ltr">Again with some TIMTOWTDI. I'm trying to learn some Perl6 so here is my FizzBuzz basketball attempt (definitely not golf anyway).<div><br></div><div>It's a full CLI application; complete with usage screen and some tests. </div><div><a href="https://github.com/PsyDefect/App-FizzBuzz.git">https://github.com/PsyDefect/App-FizzBuzz.git</a></div></div><div class="gmail_extra"><br clear="all"><div><div dir="ltr"><br>John Dexter<br></div></div>
<br><div class="gmail_quote">On Fri, Sep 12, 2014 at 12:08 AM, kevin <span dir="ltr"><<a href="mailto:kbrannen@pwhome.com" target="_blank">kbrannen@pwhome.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 09/11/2014 02:03 PM, Tommy Butler wrote:<br>
...<span class=""><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<a href="http://rosettacode.org/wiki/FizzBuzz" target="_blank">http://rosettacode.org/wiki/<u></u>FizzBuzz</a><br>
<br>
Is all about the modulus operator.  To do it another way might be<br>
creative but would almost certainly likely be less efficient.  The only<br>
thing I can think of that world be faster is the cheat method I saw,<br>
where you hard code into your program the known fizzes and buzzes,<br>
spitting them out at the corresponding integer positions in the 1 to 100<br>
loop.<br>
</blockquote></span>
...<br>
<br>
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.<br>
<br>
my @nums;<br>
for ($i=3 ; $i <= 100 ; $i += 3) { $nums[$i]++; }<br>
for ($i=5 ; $i <= 100 ; $i += 5) { $nums[$i] += 2; }<br>
my @strings = (0, "Fizz", "Buzz", "FizzBuzz");<br>
print (($strings[$nums[$_]] || $_) . "\n") for (1 .. 100);<br>
<br>
I don't think I'd call that cheating, but inefficient I'll agree with. :)<br>
<br>
By cheating, I assume the method where you create an array with 100 hard-coded values? Yeah, I go with cheating there. :)<span class="HOEnZb"><font color="#888888"><br>
<br>
Kevin<br>
______________________________<u></u>_________________</font></span><div class="HOEnZb"><div class="h5"><br>
Dfw-pm mailing list<br>
<a href="mailto:Dfw-pm@pm.org" target="_blank">Dfw-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/dfw-pm" target="_blank">http://mail.pm.org/mailman/<u></u>listinfo/dfw-pm</a><br>
</div></div></blockquote></div><br></div>