diff options
Diffstat (limited to 'problem751.ijs')
-rw-r--r-- | problem751.ijs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/problem751.ijs b/problem751.ijs new file mode 100644 index 0000000..89d3450 --- /dev/null +++ b/problem751.ijs @@ -0,0 +1,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 ''
\ No newline at end of file |