Skip to content

Instantly share code, notes, and snippets.

@rinh
Created April 12, 2013 13:18
Show Gist options
  • Save rinh/5371930 to your computer and use it in GitHub Desktop.
Save rinh/5371930 to your computer and use it in GitHub Desktop.
fixed = (num) ->
if num.length is 1 then "0" + num else num
_format = (line) ->
line.replace( /(\d+)/g , ($0, $1) ->
return fixed($1)
)
.replace /\./g , " "
format = (n) ->
console.info( _format(n) )
nums = """
3.13.14.15.25+4.5
3.17.25.27.33+1.3
6.17.23.24.25+1.3
6.13.25.26.27+4.5
7.17.23.24.25+5.7
7.16.25.27.33+3.6
7.12.13.14.25+4.5
8.17.25.26.27+1.3
8.17.23.24.25+5.7
8.13.14.15.34+3.6
9.13.14.25.27+5.7
9.21.25.27.34+3.6
"""
format nums
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment