Skip to main content
1 of 5
ngn
  • 15.3k
  • 2
  • 43
  • 87

#APL, 35 characters

{⍵,'.'⍴⍨⍵≡⌽'9608x'['6908'⍳⍵]}∘⍕¨0,⍳

⍳N           the numbers 1..N
0,           prepend a 0
⍕¨           format-each, convert numbers to strings
'6908'⍳⍵     find the index of each digit in '6908'; digits not found will have index 5
'9608x'[...] effectively swap 9←→6 and replace 1,2,3,4,5,7 with 'x'
⌽            reverse
⍵≡           does the original string match? false=0 true=1
'.'⍴⍨        take that many dots
⍵,           and append them to the original string
ngn
  • 15.3k
  • 2
  • 43
  • 87