반응형
결과는 아래와 같다.#!/usr/bin/env python # Daum sinjisik # Author : DwYoon ################################################################## print "---------------------" for i in xrange(12): for j in xrange(12): print (((i+2)/2)%2)^(((j)/2)%2), print ################################################################## print "---------------------" for i in xrange(12): for j in xrange(12): print (((i+3)/3)%2)^(((j)/3)%2), print ################################################################## print "---------------------" array = [ [ 0 for i in xrange(6) ] for j in xrange(6) ] # for i in xrange(6): # print array[i] n = 1 x, y = 0, 0 v = 1, 0 array[y][x] = n while [ x, y ] != [ 0, 1 ]: if (x, y) == (5, 0): v = 0, 1 elif (x, y) == (5, 5): v = -1, 0 elif (x, y) == (0, 5): v = 0, -1 n+=1 x, y = x+v[0], y+v[1] array[y][x] = n for y in xrange(6): for x in xrange(6): print "%2d"%array[y][x], print ################################################################## print "---------------------" array = [ [ 0 for i in xrange(6) ] for j in xrange(6) ] n = 1 x, y = 0, 0 v = 1, 0 array[y][x] = n while 1: x, y = x+v[0] , y+v[1] if x < 0 or x > 5 or y < 0 or y > 5 or array[y][x] != 0: x, y = x-v[0] , y-v[1] v = -v[1], v[0] # velocity vector +90 degree rotation x, y = x+v[0] , y+v[1] n+=1 array[y][x] = n if n == 36: break for y in xrange(6): for x in xrange(6): print "%2d"%array[y][x], print
--------------------- 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 --------------------- 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 --------------------- 1 2 3 4 5 6 20 0 0 0 0 7 19 0 0 0 0 8 18 0 0 0 0 9 17 0 0 0 0 10 16 15 14 13 12 11 --------------------- 1 2 3 4 5 6 20 21 22 23 24 7 19 32 33 34 25 8 18 31 36 35 26 9 17 30 29 28 27 10 16 15 14 13 12 11
728x90
'프로그래밍 > 숙제도둑질' 카테고리의 다른 글
[C#|초급] 사다리꼴 넓이 구하기 (0) | 2008.09.17 |
---|---|
[FORTRAN77|초급] exp 함수 테일러급수 (0) | 2008.05.10 |
[C|MFC|수치해석] 라그랑지 다항식 (0) | 2008.04.14 |
[C#|초급] 성적입력 및 출력 (0) | 2008.03.31 |
[C|MFC] 푸리에 시리즈 사각파 (0) | 2008.03.17 |