0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

五角形の世界であなたは過去の自分に出会う

Last updated at Posted at 2016-10-31
  • 図形はだめ
    • 立体図形じゃないだけましですが…
    • 六角形ですらきついのに五角形とか。
    • はなびら(凸頂点の数)はxy座標に直せましたが、今回は…
  • しえるさんごろし禁止^q^
    • 前回は手を動かすことができたでしょうが、今回は1時間座っているだけだった可能性もありえます…

答案1

  • 縦長の六角形と見て、上が0、左が1、右が2、下が3
tyama_henae09.rb
# !/usr/bin/env ruby
# http://nabetani.sakura.ne.jp/hena/orde09_penwa/
# http://qiita.com/Nabetani/items/1c0a2bb20b3ab3e7f55b

T=[
	[[0,0,1,4],[-1,0,2,3],[0,-1,3,2],[1,-1,1,2],[0,0,2,1]],
	[[0,0,2,0],[0,0,3,4],[-1,1,0,3],[-1,0,3,1],[0,0,0,0]],
	[[0,0,1,0],[0,0,0,4],[1,-1,3,3],[1,0,0,1],[0,0,3,0]],
	[[0,0,2,4],[1,0,1,3],[0,1,0,2],[-1,1,2,2],[0,0,1,1]],
]

while gets
	cur=[0,0,0,2]
	trail={cur[0,3]=>0}
	i=0
	if $_.chomp.each_char{|c|
		if c=='a'
			cur[3]=(cur[3]-1)%5
		elsif c=='c'
			cur[3]=(cur[3]+1)%5
		elsif c=='F'
			i+=1
			dx,dy,z,dir=T[cur[2]][cur[3]]
			cur=[cur[0]+dx,cur[1]+dy,z,dir]
			if trail.has_key?(cur[0,3])
				puts '%d,%d'%[i,trail[cur[0,3]]]
				break
			end
			trail[cur[0,3]]=i
		end
	}
		puts '-'
	end
	STDOUT.flush
end

答案2

手裏剣型なら1つの五角形を回転移動させて単位図形を作れるのか…悔しい…

e09_mod.rb
=begin
T=[
	[[0,0,1,1],[0,0,3,0],[0,-1,2,2],[0,-1,1,4],[1,0,3,3]],
	[[0,0,2,1],[0,0,0,0],[1,0,3,2],[1,0,2,4],[0,1,0,3]],
	[[0,0,3,1],[0,0,1,0],[0,1,0,2],[0,1,3,4],[-1,0,1,3]],
	[[0,0,0,1],[0,0,2,0],[-1,0,1,2],[-1,0,0,4],[0,-1,2,3]],
]
=end
D=[[0,-1],[1,0],[0,1],[-1,0]]
T=4.times.map{|i|
	[[0,0,(i+1)%4,1],[0,0,(i+3)%4,0],[*D[i],(i+2)%4,2],[*D[i],(i+1)%4,4],[*D[(i+1)%4],(i+3)%4,3]]
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?