Created
January 3, 2023 04:46
Revisions
-
TAKIZAWA Yozo created this gist
Jan 3, 2023 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ from time import sleep # (state,symbol) => (state,symbol,head) delta = {(0,0):(1,1,+1), (0,1):(0,2,-1), (0,2):(0,1,-1), (1,0):(0,2,-1), (1,1):(1,2,+1), (1,2):(0,0,+1)} ds = {0: ' ', 1: '.', 2: '*'} state, stackL, C, stackR = 0, [0]*29, 0, [0]*50 while len(stackL) > 0 and len(stackR) > 0: state, C, head = delta[(state,C)] if head == +1: stackL.insert(0, C) C = stackR[0]; stackR = stackR[1:] else: stackR.insert(0, C) C = stackL[0]; stackL = stackL[1:] for s in list(reversed(stackL))+[C]+stackR : print(ds[s], end='') print() sleep(0.005)