Created
September 14, 2015 04:55
-
-
Save youchan/93b4c53da408e244b82a to your computer and use it in GitHub Desktop.
「プログラマの数学」(結城 浩) P76 恋人探しをプログラムで求める
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 「プログラマの数学」(結城 浩) P76 恋人探しをプログラムで求める | |
# | |
# 読書会で書いたやつを捨てるのもったいないので貼っとく | |
# | |
graph = {a: [:b, :e, :d], b: [:a, :c, :f], c: [:b, :d, :g], d: [:a, :c, :h], | |
e: [:f, :h, :a], f: [:e, :g, :b], g: [:f, :h, :c], h: [:e, :g, :d]} | |
c = {a: 0, b: 0, c: 0, d: 0, e: 0, f: 0, g: 1, h: 0} | |
12.times do |i| | |
cc = {a:0, b:0, c:0, d:0, e:0, f:0, g:0, h:0} | |
c.each do |d| | |
graph[d[0]].each do |s| | |
cc[s] += d[1].to_r / 3 | |
end | |
end | |
p cc | |
c = cc | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment