Skip to main content
Commonmark migration
Source Link

#J, 39 bytes

J, 39 bytes

f=.$:&>:`[@.(1=#@~.@(10&#.inv)@])
g=.0&f

Take the digits (10&#.inv)@], remove dups ~., check if the length is 1 (same basic idea as Dennis's solution). Recurse with incremented left and right args if it's not.

Note because $: recurses on the entire verb, we need to define a second verb to give the left arg an initial value of 0. I'd be curious to know how to avoid that, if possible.

Also, I'd be curious to know if there is a way to do this with ^: (do... while version).

Try it online!

#J, 39 bytes

f=.$:&>:`[@.(1=#@~.@(10&#.inv)@])
g=.0&f

Take the digits (10&#.inv)@], remove dups ~., check if the length is 1 (same basic idea as Dennis's solution). Recurse with incremented left and right args if it's not.

Note because $: recurses on the entire verb, we need to define a second verb to give the left arg an initial value of 0. I'd be curious to know how to avoid that, if possible.

Also, I'd be curious to know if there is a way to do this with ^: (do... while version).

Try it online!

J, 39 bytes

f=.$:&>:`[@.(1=#@~.@(10&#.inv)@])
g=.0&f

Take the digits (10&#.inv)@], remove dups ~., check if the length is 1 (same basic idea as Dennis's solution). Recurse with incremented left and right args if it's not.

Note because $: recurses on the entire verb, we need to define a second verb to give the left arg an initial value of 0. I'd be curious to know how to avoid that, if possible.

Also, I'd be curious to know if there is a way to do this with ^: (do... while version).

Try it online!

Source Link
Jonah
  • 33.8k
  • 4
  • 40
  • 94

#J, 39 bytes

f=.$:&>:`[@.(1=#@~.@(10&#.inv)@])
g=.0&f

Take the digits (10&#.inv)@], remove dups ~., check if the length is 1 (same basic idea as Dennis's solution). Recurse with incremented left and right args if it's not.

Note because $: recurses on the entire verb, we need to define a second verb to give the left arg an initial value of 0. I'd be curious to know how to avoid that, if possible.

Also, I'd be curious to know if there is a way to do this with ^: (do... while version).

Try it online!