Skip to main content
added 398 characters in body
Source Link
Peter Taylor
  • 43.4k
  • 4
  • 72
  • 179

GolfScript (23 chars)

~:^,2>{^\base[4]/,~}$0= 

or

~:^,2>{^\base[4]/,}$-1= 

or

~:^,2>{^\base[4]/,}$)\; 

Note that this takes input from stdin: for a fair comparison with Howard's GolfScript version subtract one char.


Howard points out that the rules have changed, and it's not very logical that they now exclude 4 as a possible input when it has a valid output (any integer greater than 4). To cover that case as well requires an extra 2 characters, which can be added in all kinds of ways:

~:^)),2>{^\base[4]/,}$)\; 

or

~:^,{))^\base[4]/,}$)))\; 

being a couple of the obvious ones.

GolfScript (23 chars)

~:^,2>{^\base[4]/,~}$0= 

or

~:^,2>{^\base[4]/,}$-1= 

or

~:^,2>{^\base[4]/,}$)\; 

Note that this takes input from stdin: for a fair comparison with Howard's GolfScript version subtract one char.

GolfScript (23 chars)

~:^,2>{^\base[4]/,~}$0= 

or

~:^,2>{^\base[4]/,}$-1= 

or

~:^,2>{^\base[4]/,}$)\; 

Note that this takes input from stdin: for a fair comparison with Howard's GolfScript version subtract one char.


Howard points out that the rules have changed, and it's not very logical that they now exclude 4 as a possible input when it has a valid output (any integer greater than 4). To cover that case as well requires an extra 2 characters, which can be added in all kinds of ways:

~:^)),2>{^\base[4]/,}$)\; 

or

~:^,{))^\base[4]/,}$)))\; 

being a couple of the obvious ones.

Source Link
Peter Taylor
  • 43.4k
  • 4
  • 72
  • 179

GolfScript (23 chars)

~:^,2>{^\base[4]/,~}$0= 

or

~:^,2>{^\base[4]/,}$-1= 

or

~:^,2>{^\base[4]/,}$)\; 

Note that this takes input from stdin: for a fair comparison with Howard's GolfScript version subtract one char.