[DFW.pm] Fizzbuzz assignment

Reini Urban rurban at cpanel.net
Fri Sep 12 10:55:08 PDT 2014


On 09/11/2014 05:09 PM, Sriharsha Vedurumudi wrote:
> Got a compile error  when trying to run this.
> But this worked (81 chars though)
>
> map{print
> "".($_%15)?($_%3)?($_%5)?"$_\n":"Buzz\n":"Fizz\n":"FizzBuzz\n"}(1..100)

do not use map when you can use for

> On 09/11/2014 05:35 PM, Andrew Sohn wrote:
>> Here's my Fizz Buzz golf attempt... :)
>>
>> print$_%3?'':Fizz,$_%5?'':Buzz,$_%3&&$_%5?$_:'',"\n"for 1..100
>> 63 characters

well, for the golf cmdline you need ""
p -e'print$_%3?"":Fizz,$_%5?"":Buzz,$_%3&&$_%5?$_:"","\n"for 1..100'

-- 
Reini


More information about the Dfw-pm mailing list