- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
# My first attempt in J:
+/(>/)"1 <.@(10&^.)(2 & x:) (+%)/\(1x,1000$2)
# It gave the right answer, but took about an hour.
# Based on other people's comments I went back and figured out the relationship
# between one answer and the next, and came up with this,
# which runs in less than 1 second:
((((0{])+([:$[:":1{])>([:$[:":2{])),(1{]+2*2{]),1{]+2{])^:1000) 0 3x 2x
http://www.dezcom.org/bbs/index.php?showtopic=60529