Problem:


パターンの回転

8 文字 &times; 8 行のパターンを右回りに 90 度、180 度、270 度回転させて出力するプログラムを作成してください。

Input

8 文字 &times; 8 行からなるパターンが与えられます。文字は、英数字、半角シャープ '#' 、アスタリスク '*' からなります。

Output

次の形式で、回転させたパターンを出力してください。

90（半角数字固定）
90度回転させたパターン
180（半角数字固定）
180度回転させたパターン
270（半角数字固定）
270度回転させたパターン

Sample Input

#*******
#*******
#*******
#*******
#*******
#*******
#*******
########

Output for the Sample Input

90
########
#*******
#*******
#*******
#*******
#*******
#*******
#*******
180
########
*******#
*******#
*******#
*******#
*******#
*******#
*******#
270
*******#
*******#
*******#
*******#
*******#
*******#
*******#
########



Sample input:
#*******
#*******
#*******
#*******
#*******
#*******
#*******
########


Sample output:
90
########
#*******
#*******
#*******
#*******
#*******
#*******
#*******
180
########
*******#
*******#
*******#
*******#
*******#
*******#
*******#
270
*******#
*******#
*******#
*******#
*******#
*******#
*******#
########

Submission status: Wrong Answer

Solution code:
import sys

rotation = [90, 180, 270]

pattern = sys.stdin.readlines()
for var in range(len(pattern)):
	pattern[var] = pattern[var].replace("\n", "")

for var in rotation:
	print var
	
	if var == 90:
		for i in xrange(4):
			temp = pattern[i]
			pattern[i] = pattern[7 - i]
			pattern[7 - i] = temp
	if var == 180:
		for i in xrange(8):
			pattern[i] = pattern[i][::-1]
	if var == 270:
		for i in xrange(4):
			temp = pattern[i]
			pattern[i] = pattern[7 - i]
			pattern[7 - i] = temp
	
	for vr in pattern:
		print vr

Submission status: Wrong Answer

Solution code:
m=[input() for _ in range(8)]
for i in range(3):
    m=list(zip(*m[::-1]))
    print(90*i)
    for x in m:
        print(''.join(x))

Submission status: Wrong Answer

Solution code:
def Draw(pattern, rowRange, colRange):
    
    s = ""

    for row in rowRange:
        for col in colRange:
            s += pattern[row][col]
        s += "\n"

    print(s, end="")


pattern = [input() for lp in range(8)]

print("90")
Draw(pattern, range(7, -1, -1), range(0, 8))

print("180")
Draw(pattern, range(7, -1, -1), range(7, -1, -1))

print("270")
Draw(pattern, range(0, 8), range(7, -1, -1))

Submission status: Wrong Answer

Solution code:
from __future__ import print_function
from copy import deepcopy

try:
    xrange
except NameError:
    pass
else:
    range = xrange

def solve(lines):
    lines90 = deepcopy(lines)
    for i in range(8):
        for j in range(8):
            lines90[j][7 - i] = lines[i][j]
    print(90)
    print('\n'.join(map(''.join, lines90)))
    
    lines180 = deepcopy(lines)
    for i in range(8):
        for j in range(8):
            lines180[j][7 - i] = lines90[i][j]
    print(180)
    print('\n'.join(map(''.join, lines180)))
    
    lines270 = deepcopy(lines)
    for i in range(8):
        for j in range(8):
            lines270[j][7 - i] = lines180[i][j]
    print(27)
    print('\n'.join(map(''.join, lines270)))

if __name__ == '__main__':
    lines = []
    for _ in range(8):
        lines.append(list(raw_input().strip()))
    solve(lines)

Submission status: Accepted

Solution code:
x = [list(raw_input()) for _ in [0]*8]
for i in [1,2,3]:
  x = zip(*x[::-1])
  print i*90
  for e in x: print "".join(e)

Submission status: Accepted

Solution code:
x = [raw_input() for _ in [0] * 8]
for i in [1, 2, 3]:
  x = zip(*x[::-1])
  print i*90
  for e in x:
    print "".join(e)

Submission status: Accepted

Solution code:
import copy

V = [list(raw_input()) for i in range(8)]
_V = []
for r in range(8):
    lis = []
    for c in range(8):
        lis.append('')
    else:
        _V.append(lis)
for angle in [90, 180, 270]:
    for r in range(8):
        for c in range(8):
            _V[c][7-r] = V[r][c]
    else:
        V = copy.deepcopy(_V)
    print angle
    for line in V:
        print ''.join(line)

Submission status: Accepted

Solution code:
m=[input() for _ in range(8)]
print(90)
a=-1
for j in range(8):
    for i in range(7,a,a):
        print(m[i][j],end='')
    print()
print(180)
for i in range(7,a,a):
    for j in range(7,a,a):
        print(m[i][j],end='')
    print()
print(270)
for j in range(7,a,a):
    for i in range(8):
        print(m[i][j],end='')
    print()

Submission status: Accepted

Solution code:
def rotate(m,n):
    print(90*n)
    for i in range(8):
        print(''.join(m[i]),end='')
        print()

m=[input() for _ in range(8)]
for i in range(3):
    m=list(zip(*m[::-1]))
    rotate(m,i+1)

Submission status: Accepted

Solution code:
m=[input() for _ in range(8)]
for i in range(3):
    m=list(zip(*m[::-1]))
    print(90*(i+1))
    for x in m:
        print(''.join(x))

Submission status: Accepted

Solution code:
m=[input() for _ in range(8)]
for i in [90,180,270]:
    m=list(zip(*m[::-1]))
    print(i)
    for x in m:
        print(''.join(x))

Submission status: Accepted

Solution code:
def rotate(k, p):
    q=[]
    print('90' if k==1 else('180' if k==2 else '270'))
    for i in range(8):
        t=''
        for j in range(8)[::-1]:
            print(p[j][i], end='')
            t+=p[j][i]
        q.append(t)
        print()
    return q

p= [input() for _ in range(8)]
for i in range(1, 4):
    p= rotate(i, p)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0133

"""
import sys
from sys import stdin
input = stdin.readline


def rotate_ccw(data):
    A = [[''] * 8 for _ in range(8)]
    for i in range(8):
        for j in range(8):
            A[i][j] = data[j][7-i]

    for l in A:
        print(''.join(l))
    return A


def rotate_cw(data):
    A = [[''] * 8 for _ in range(8)]
    for i in range(8):
        for j in range(8):
            A[i][j] = data[7-j][i]

    for l in A:
        print(''.join(l))
    return A


def main(args):
    data = []
    for _ in range(8):
        data.append(list(input().strip()))

    print('90')
    data = rotate_cw(data)
    print('180')
    data = rotate_cw(data)
    print('270')
    data = rotate_cw(data)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
def Draw(pattern, rowRange, colRange):
    s = ""

    for row in rowRange:
        for col in colRange:
            s += pattern[row][col]
        s += "\n"

    print(s, end="")


def Draw2(pattern, colRange, rowRange):
    s = ""

    for col in colRange:
        for row in rowRange:
            s += pattern[row][col]
        s += "\n"

    print(s, end="")


pattern = [input() for lp in range(8)]

print("90")
Draw2(pattern, range(0, 8), range(7, -1, -1))

print("180")
Draw(pattern, range(7, -1, -1), range(7, -1, -1))

print("270")
Draw2(pattern, range(7, -1, -1), range(0, 8))

Submission status: Accepted

Solution code:
table = []

for l in range(8):
    table.append(input())

print(90)
for i in range(8):
    for j in range(8):
        print(table[7-j][i], end="")
    print("")

print(180)
for i in range(8):
    for j in range(8):
        print(table[7-i][7-j], end="")
    print("")

print(270)
for i in range(8):
    for j in range(8):
        print(table[j][7-i], end="")
    print("")

Submission status: Accepted

Solution code:
def spin(p):
  ret = [[None] * 8 for _ in range(8)]
  for i in range(8):
    for j in range(8):
      ret[i][j] = p[7 - j][i]
  return ret

def print_p(p):
  for line in p:
    print("".join(line))

p = [input() for _ in range(8)]

print(90)
p = spin(p)
print_p(p)

print(180)
p = spin(p)
print_p(p)

print(270)
p = spin(p)
print_p(p)

Submission status: Accepted

Solution code:
# AOJ 0133 Rotation of a Pattern
# Python3 2018.6.19 bal4u

a = [[[0 for c in range(8)] for r in range(8)] for k in range(4)]
title = ["0", "90", "180", "270"]

for r in range(8):
	a[0][r] = list(input())
for k in range(1, 4):
	print(title[k])
	for r in range(8):
		for c in range(8):
			a[k][c][7-r] = a[k-1][r][c]
	for r in range(8): print(*a[k][r], sep='')

Submission status: Accepted

Solution code:
import copy
w,h = 8,8
tile = [[] for i in xrange(h)]
for i in xrange(h):
    temp = raw_input()
    for j in xrange(w):
        tile[i].append(temp[j])
for i in xrange(3):
    if i is 0: print 90
    elif i is 1: print 180
    elif i is 2: print 270
    tile_copy = copy.deepcopy(tile)
    for i in xrange(w):
        for j in xrange(h):
            tile[j][i] = tile_copy[w-1-i][j]
    for i in xrange(h):
        print "".join(tile[i])

Submission status: Accepted

Solution code:
import sys

def rotate90(ptn):
    ptn = zip(ptn[0], ptn[1], ptn[2], ptn[3],\
              ptn[4], ptn[5], ptn[6], ptn[7])
    for i in range(8): ptn[i] = list(ptn[i])
    for i in range(8): ptn[i].reverse()
    return ptn

def print_ptn(ptn):
    for i in range(8):
        for j in range(8):
            sys.stdout.write(ptn[i][j])
        print

ptn = []
for i in range(8):
    ptn.append(list(raw_input()))
for i in range(3):
    print 90 * (i + 1)
    ptn = rotate90(ptn)
    print_ptn(ptn)

Submission status: Accepted

Solution code:
from __future__ import print_function
from copy import deepcopy

try:
    xrange
except NameError:
    pass
else:
    range = xrange

def rotate(array):
    array2 = deepcopy(array)
    for i in range(8):
        for j in range(8):
            array2[j][7 - i] = array[i][j]
    return array2

def to_str(array):
    return '\n'.join(map(''.join, array))

def solve(lines):
    lines90 = rotate(lines)
    print(90)
    print(to_str(lines90))
    
    lines180 = rotate(lines90)
    print(180)
    print(to_str(lines180))
    
    lines270 = rotate(lines180)
    print(270)
    print(to_str(lines270))

if __name__ == '__main__':
    lines = []
    for _ in range(8):
        lines.append(list(raw_input().strip()))
    solve(lines)

Submission status: Accepted

Solution code:
T = lambda d:["".join(d) for d in zip(*d[::-1])]
D = [raw_input() for _ in xrange(8)]
for i in xrange(1,4):
    print str(90*i)
    print "\n".join(reduce(lambda a,b:b(a),[T]*i,D))

Submission status: Accepted

Solution code:
T = lambda d:["".join(d) for d in zip(*d[::-1])]
D = [raw_input() for _ in xrange(8)]
for i in xrange(1,4):
    print 90*i
    print "\n".join(reduce(lambda a,b:b(a),[T]*i,D))

Submission status: Accepted

Solution code:
p = [raw_input() for i in xrange(8)]
pr = ["".join([p[y][x] for y in xrange(7,-1,-1)]) for x in xrange(8)]
print "90"
for i in xrange(8):
    print pr[i]
print "180"
for i in xrange(7,-1,-1):
    print p[i][::-1]
print "270"
for i in xrange(7,-1,-1):
    print pr[i][::-1]

Submission status: Accepted

Solution code:
p=[list(raw_input()) for i in range(8)]
plist=[p,[],[],[]]
for r in range(3):
	for j in range(8):
		plist[r+1].append([plist[r][i][j] for i in range(7,-1,-1)])
	print 90*(r+1)
	for i in range(8):
		print "".join(plist[r+1][i])

Submission status: Accepted

Solution code:
d=[list(raw_input()) for i in range(8)]
p=[d,[],[],[]]
for r in range(3):
	print 90*(r+1)
	for j in range(8):
		p[r+1].append([p[r][i][j] for i in range(7,-1,-1)])
		print "".join(p[r+1][j])

Submission status: Accepted

Solution code:
p=[[list(raw_input()) for i in range(8)],[],[],[]]
for r in range(3):
	print 90*(r+1)
	for j in range(8):
		p[r+1].append([p[r][i][j] for i in range(7,-1,-1)])
		print "".join(p[r+1][j])

Submission status: Accepted

Solution code:
p=[[list(raw_input()) for i in range(8)],[],[],[]]
for r in range(3):
	print 90*(r+1)
	for j in range(8):
		p[r+1].append([p[r][-i-1][j] for i in range(8)])
		print "".join(p[r+1][j])

Submission status: Accepted

Solution code:
t = []

for i in range(8):
    t.append(input())
    
print(90)
for i in range(8):
    for j in range(8):
        print(t[7-j][i],end="")
    print("")

print(180)
for i in range(8):
    for j in range(8):
        print(t[7-i][7-j],end="")
    print("")

print(270)
for i in range(8):
    for j in range(8):
        print(t[j][7-i],end="")
    print("")

Submission status: Accepted

Solution code:

MAX=8
L = [ [None] * MAX for x in range(MAX) ]

for i in range(MAX):
    l = list(input())
    L[i] = l

T = [ [None] * MAX for x in range(MAX) ]

for r in range(1,4):
    print(r*90)
    for i in range(MAX):
        for j in range(MAX):
            T[i][j] = L[MAX-1-j][i]

    L = T
    T = [ [None] * MAX for x in range(MAX) ]
    for l in L:
        print("".join(l))

Submission status: Accepted

Solution code:
#写経させていただきました。
def spin(p):
    ret = [[None] * 8 for _ in range(8)]
    for i in range(8):
        for j in range(8):
            ret[i][j] = p[7 - j][i]
    return ret

def print_p(p):
    for line in p:
        print("".join(line))

p = [input() for _ in range(8)]

print(90)
p = spin(p)
print_p(p)

print(180)
p = spin(p)
print_p(p)

print(270)
p = spin(p)
print_p(p)

Submission status: Accepted

Solution code:
mat = []
for _ in range(8):
    mat.append(list(input()))

mat90 = [[0 for i in range(8)] for j in range(8)]
print(90)
for i in range(8):
    for j in range(8):
        mat90[i][j] = mat[7-j][i]

for i in range(8):
    print(''.join(m for m in mat90[i]))

mat180 = [[0 for i in range(8)] for j in range(8)]
print(180)
for i in range(8):
    for j in range(8):
        mat180[i][j] = mat90[7-j][i]

for i in range(8):
    print(''.join(m for m in mat180[i]))

mat270 = [[0 for i in range(8)] for j in range(8)]
print(270)
for i in range(8):
    for j in range(8):
        mat270[i][j] = mat180[7-j][i]

for i in range(8):
    print(''.join(m for m in mat270[i]))

Submission status: Accepted

Solution code:
def spin(pazzule):
    pzl = [["" for i in range(8)] for j in range(8)]
    for i in range(8):
        for j in range(8):
            pzl[i][j] = pazzule[7-j][i]
    return pzl
    
pazzule = [list(input()) for i in range(8)]
pazzule = spin(pazzule)
print("90")
for i in range(8):
    print("".join(pazzule[i]))
print("180")
pazzule = spin(pazzule)
for i in range(8):
    print("".join(pazzule[i]))
print("270")
pazzule = spin(pazzule)
for i in range(8):
    print("".join(pazzule[i]))