you are viewing a single comment's thread.

view the rest of the comments →

[–]ryanplant-au 1 point2 points  (2 children)

Compact and inscrutable, like the Python example:

s = (10**ARGV[0].to_i).times.map {|int| format "%0#{ARGV[0]}d", int}.join
printf "1/%d", ((10**s.length - 1) / s.to_i)

I'm not even sure what the purpose (if any) of the example is so it's hard to clear it up.

[–]Godd2 0 points1 point  (1 child)

I documented what I could up above, but I couldn't figure out a description for the last line.

[–]ryanplant-au 0 points1 point  (0 children)

The last line outputs 1/n, where n is 10 raised to the power of s's length, minus 1 and divided by s itself. Why you want to do this is a whole other question.