Skip to main content
chipping away at this bit by bit
Source Link
jayprich
  • 421
  • 2
  • 8

R[R], 110110 86 bytes

o=c(1,1:9);o=o%o%o%o%o;o=c(o%o%o)
x=c(1,n);while((x=sort(x))<x[2])x[1]=(x+o[x+1])[1]
x

this is slow because it computes the sums of products of non[TIO][TIO-zero digits up to 999999 inside the recursionjgstqwvp]

I'm supplying the argument in a variable n, the result is given by function application f(c(1,n)) which counts as 10 bytes of 110previous version 110:

  
f=function(x){if((x[1]=x[1]+(c((y=(y=c(1,1:9))%o%y%o%y)%o%y))[x[1]+1])==x[2]){x[1]}else{f(sort(x))}}
f(c(1,n))

Try it online! [TIO][TIO-jge9udaw] [R]: https://www.r-project.org/ [TIO-jge9udaw]: https://tio.run/##HU/basMwDH3fVxwoBYutD9lg0IH/om8lD8GRM8NiB8seTUO@PVUiJHF0OxzlLdrvLwAn3H4ZXR7qyLEgCKZOhHuEiE7QRQWFB86bt75GV0KK5kFL8MY87k1r9/RunDGzVXem@Wh@rkTndJ73OADR/VhrWrJ68NnSstcr/wkv3kjKRTlpXd@82Rki0XaCS@NUCwukjoLkMeXUV1cOHFO8PDkn9GEI2qoTSsL1MJUsodevkNnVLCoZF/xznnXC3gcX9NftBQ "R – Try It Online" [TIO-jgstqwvp]: https://tio.run/##K/qfZ2tm/D/fNlnDUMfQylLTOt82XxUKrUHCYJYmVwVYRZ6mdXlGZk6qhkaFbXF@UYlGhaamTUW0UaxmRbRhrK1GhXZ@dIW2YawmkMdV8f8/AA "R – Try It Online"

R, 110 bytes

this is slow because it computes the sums of products of non-zero digits up to 999999 inside the recursion

I'm supplying the argument in a variable n, the result is given by function application f(c(1,n)) which counts as 10 bytes of 110

 
f=function(x){if((x[1]=x[1]+(c((y=(y=c(1,1:9))%o%y%o%y)%o%y))[x[1]+1])==x[2]){x[1]}else{f(sort(x))}}
f(c(1,n))

Try it online!

[R], 110 86 bytes

o=c(1,1:9);o=o%o%o%o%o;o=c(o%o%o)
x=c(1,n);while((x=sort(x))<x[2])x[1]=(x+o[x+1])[1]
x

[TIO][TIO-jgstqwvp]

previous version 110:

 
f=function(x){if((x[1]=x[1]+(c((y=(y=c(1,1:9))%o%y%o%y)%o%y))[x[1]+1])==x[2]){x[1]}else{f(sort(x))}}
f(c(1,n))

[TIO][TIO-jge9udaw] [R]: https://www.r-project.org/ [TIO-jge9udaw]: https://tio.run/##HU/basMwDH3fVxwoBYutD9lg0IH/om8lD8GRM8NiB8seTUO@PVUiJHF0OxzlLdrvLwAn3H4ZXR7qyLEgCKZOhHuEiE7QRQWFB86bt75GV0KK5kFL8MY87k1r9/RunDGzVXem@Wh@rkTndJ73OADR/VhrWrJ68NnSstcr/wkv3kjKRTlpXd@82Rki0XaCS@NUCwukjoLkMeXUV1cOHFO8PDkn9GEI2qoTSsL1MJUsodevkNnVLCoZF/xznnXC3gcX9NftBQ "R – Try It Online" [TIO-jgstqwvp]: https://tio.run/##K/qfZ2tm/D/fNlnDUMfQylLTOt82XxUKrUHCYJYmVwVYRZ6mdXlGZk6qhkaFbXF@UYlGhaamTUW0UaxmRbRhrK1GhXZ@dIW2YawmkMdV8f8/AA "R – Try It Online"

Source Link
jayprich
  • 421
  • 2
  • 8

R, 110 bytes

this is slow because it computes the sums of products of non-zero digits up to 999999 inside the recursion

I'm supplying the argument in a variable n, the result is given by function application f(c(1,n)) which counts as 10 bytes of 110

f=function(x){if((x[1]=x[1]+(c((y=(y=c(1,1:9))%o%y%o%y)%o%y))[x[1]+1])==x[2]){x[1]}else{f(sort(x))}}
f(c(1,n))

Try it online!