以下の内容はhttps://inamori.hateblo.jp/entry/2019/08/01/085825より取得しました。


JuliaでProject Euler(19)

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に似ているといえば似ている。




以上の内容はhttps://inamori.hateblo.jp/entry/2019/08/01/085825より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14