blob: 89d345014a5d0057bf73ec2b221c4cdaab6d1dc1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
digits =: 24
next =: {{ (<.y)*1+y-<.y }}
catseq =: {{ (([: ".'x',~]) % 10x^<:@#) (digits+1){.;":each<.y }}
digitsOf =: {{ <. y * 10^x:x }}
solve =: {{
lowerBound =. x:2.0
upperBound =. x:2.9
whilst. (digits digitsOf res) ~: (digits digitsOf start) do.
start =. -: lowerBound + upperBound
res =. catseq <. next^:(i.digits+1) start
if. res < start do.
upperBound =. start
elseif. res > start do.
lowerBound =. start
end.
end.
start
}}
problem751 =: ({.,'.',}.)": digits digitsOf solve ''
|