Last active
December 18, 2015 07:08
-
-
Save Leko/5743929 to your computer and use it in GitHub Desktop.
CodeIQの「コードゴルフ:ぐるぐる渦巻き」
https://codeiq.jp/ace/ozy4dm/q335 を更新しました。206文字です。もう期限終了してるけれど。
提出出来た前のバージョンはリビジョンを参照。
This file contains hidden or 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
M=-1,v=y=0,1,0;a,N=Array,gets.to_i;D=N*N;x,f=N-1,a.new(N) {a.new};D.times{|i|f[y][x]="%*d"%[D.to_s.size,D-i,c=x+M[v],d=y+M[3-v]];v=c*d<0||c==N||d==N||f[d][c]?(v+1)%4:v;x+=M[v];y+=M[3-v]};f.map{|y|puts y*' '} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment