Skip to main content
2 of 2
Commonmark migration

Smalltalk (Smalltalk/X), 63/78

the first version creates an intermediate string (78):

t:=Number readFrom:Stdin.
((15to:1by:-1)collect:[:i|$0+(t>>i&1)]as:String)print

actually, there is no need to create the string; just output the chars (63):

t:=Number readFrom:Stdin.
15to:1by:-1 do:[:i|($0+(t>>i&1))print]

mhmh - is there a shorter way to read to a number?

blabla999
  • 2k
  • 12
  • 11