From 3c0c1fe2cd7c6a9cec8edd9d7dfd518c9f2b3371 Mon Sep 17 00:00:00 2001 From: nailerHeum Date: Tue, 28 May 2019 15:52:43 +0900 Subject: [PATCH 1/2] Solve programmers supoja problem https://programmers.co.kr/learn/courses/30/lessons/42840 --- 190527/nailer/supoja.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 190527/nailer/supoja.py diff --git a/190527/nailer/supoja.py b/190527/nailer/supoja.py new file mode 100644 index 0000000..4da95b0 --- /dev/null +++ b/190527/nailer/supoja.py @@ -0,0 +1,31 @@ +def solution(answers): + answer = [] + x = 0 + y = 0 + z = 0 + d = {} + ySet = [2, 1, 2, 3, 2, 4, 2, 5] + zSet = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5] + for i in list(range(len(answers))): + if answers[i] == i % 5 + 1: + x += 1 + if answers[i] == ySet[i % 8]: + y += 1 + if answers[i] == zSet[i % 10]: + z += 1 + if x==y and y==z: + return [1,2,3] + if x>y and x>z: + return [1] + if y>x and y>z: + return [2] + if z>x and z>y: + return [3] + if x==y and y > z: + return [1, 2] + if y==z and z > x: + return [2, 3] + if z==x and x > y: + return [1, 3] + + return answer From c15b679eabf2e88f524d8609a240c2270dfa34f3 Mon Sep 17 00:00:00 2001 From: nailerHeum Date: Sun, 2 Jun 2019 22:07:16 +0900 Subject: [PATCH 2/2] Solve snail problem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 백준 달팽이 알고리즘 문제 해결 --- 190530/nailer/snail.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 190530/nailer/snail.py diff --git a/190530/nailer/snail.py b/190530/nailer/snail.py new file mode 100644 index 0000000..24e3901 --- /dev/null +++ b/190530/nailer/snail.py @@ -0,0 +1,32 @@ +import sys +from functools import reduce + +a = int(input()) +b = int(input()) +matrix = [[0]*a for i in range(a)] +row = a//2 +column = a//2 +sequence = 1 +sequenceCount = 0 +posiNeg = -1 +answerRow = 0 +answerCol = 0 + +for i in range(a*a): + matrix[row][column] = i+1 + if b == i+1: + answerRow = row + answerCol = column + if sequenceCount == 2*sequence: + sequence += 1 + sequenceCount = 0 + posiNeg *= -1 + sequenceCount += 1 + if sequenceCount <= sequence: + row += posiNeg + else: + column += posiNeg * -1 + +for item in matrix: + print(reduce(lambda x, y: str(x)+' '+str(y), item)) +print(answerRow+1, answerCol+1)