Created
September 24, 2013 05:36
-
-
Save pocket7878/6680752 to your computer and use it in GitHub Desktop.
ナムドット問題僕の回答 出力の行数を減らすためにSetを使ってる。
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
require 'set' | |
k = [0]*5; m = [0]*5 | |
begin | |
puts Set.new([*1..5]).divide{|i| k[i-1]}.map{|i| i.to_a*""}*"." | |
end while | |
(if i = [4,3,2,1].index{|i| k[i] <= m[i-1]}; then i=4-i | |
k[i]+=1; m[i] = m[i]>k[i] ? m[i] : k[i] | |
((i+1)..4).each{|j| k[j] = k[0]; m[j] = m[i]; } | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment