Problem 22
https://projecteuler.net/problem=22
function read_names(path) open(path, "r") do fp for line in eachline(fp) return [ s[2:length(s)-1] for s in split(line, ",") ] end end end function name_score(name) return sum(Int(c)-Int('A')+1 for c in name) end function e022(path) names = sort(read_names(path)) return sum(k*name_score(name) for (k, name) in enumerate(names)) end path_names = ARGS[1] println(e022(path_names))
ファイルを読むのは上のよう。Pythonに似ているといえば似ている。