Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: mini-golf: convert integer into list of powers of two

by toolic (Bishop)
on May 23, 2012 at 21:21 UTC ( [id://972106]=note: print w/replies, xml ) Need Help??


in reply to mini-golf: convert integer into list of powers of two

score = 56, although I don't really understand your spec. Why doesn't f(4) = 1,2,4?

# 1 2 3 4 5 # 12345678901234567890123456789012345678901234567890123456789 perl -E'$n=pop;while(2**$i<=$n){$_.=2**$i.",";$i++}chop;say' + 31 1,2,4,8,16

Replies are listed 'Best First'.
Re^2: mini-golf: convert integer into list of powers of two
by tobyink (Canon) on May 23, 2012 at 22:01 UTC

    f(7) is (1,2,4) because 7 is 1+2+4.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://972106]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-04-19 06:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found