Japanese numeral for Ruby kaigi by gugod

# -*- coding: utf-8 -*-
U = '\xe5\x80\x8b|\xe5\x8d\x81|\xe7\x99\xbe|\xe5\x8d\x83'
D = '\xe9\x9b\xb6|\xe4\xb8\x80|\xe4\xba\x8c|\xe4\xb8\x89|\xe5\x9b\x9b|\xe4\xba\x94|\xe5\x85\xad|\xe4\xb8\x83|\xe5\x85\xab|\xe4\xb9\x9d'

def i(a,s)
  a.index(s)/4
end

STDIN.each { |l|
  v = 0
  l.gsub(/(#{D})?(#{U}|$)/) {|m|
    a = i(D,($1||"\xe4\xb8\x80"))
    v += a*10**i(U,$2)
  }
  puts v-2
}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return top