본문 바로가기
Algorithm

[Codeup] Python 기초 100제(6)

by Jiseong 2021. 5. 27.

[6098]

 

d = []
for i in range(10):
    d.append(list(map(int, input().split())))

x, y = 1, 1

while True:
    if d[x][y] == 2:
        d[x][y] = 9
        break

    if d[x][y+1] != 1:
        d[x][y] = 9
        y += 1
    else:
        if d[x+1][y] != 1:
            d[x][y] = 9
            x += 1
        else:
            d[x][y] = 9
            break          

for i in range(10):
    for j in range(10):
        print(d[i][j],end=' ')
    print()

[결과]

1 1 1 1 1 1 1 1 1 1
1 0 0 1 0 0 0 0 0 1
1 0 0 1 1 1 0 0 0 1
1 0 0 0 0 0 0 1 0 1
1 0 0 0 0 0 0 1 0 1
1 0 0 0 0 1 0 1 0 1
1 0 0 0 0 1 2 1 0 1
1 0 0 0 0 1 0 0 0 1
1 0 0 0 0 0 0 0 0 1
1 1 1 1 1 1 1 1 1 1
-------------------
1 1 1 1 1 1 1 1 1 1 
1 9 9 1 0 0 0 0 0 1 
1 0 9 1 1 1 0 0 0 1 
1 0 9 9 9 9 9 1 0 1 
1 0 0 0 0 0 9 1 0 1 
1 0 0 0 0 1 9 1 0 1 
1 0 0 0 0 1 9 1 0 1 
1 0 0 0 0 1 0 0 0 1 
1 0 0 0 0 0 0 0 0 1 
1 1 1 1 1 1 1 1 1 1

 

다 풀었다. 얻은게 있길 바라며 계속 점검하고 실행해보자

2021.05.26 - [Dev/Algorithm] - [Codeup] Python 기초 100제(5)

 

[Codeup] Python 기초 100제(5)

[6095] n = int(input()) d = [] for i in range(20): d.append([]) for j in range(20): d[i].append(0) for i in range(n): x, y = map(int,input().split()) d[x][y] = 1 for i in range(1,20): for j in rang..

limjs-dev.tistory.com

 

'Algorithm' 카테고리의 다른 글

Baekjoon - for  (0) 2021.05.30
Baekjoon - if  (0) 2021.05.30
[Codeup] Python 기초 100제(5)  (0) 2021.05.26
[Codeup] Python 기초 100제(4)  (0) 2021.05.25
[Codeup] Python 기초 100제(3)  (0) 2021.05.24

댓글