brute Force2 [프로그래머스] 행렬의 곱 파이썬 def solution(a, b): c = [] for i in range(0,len(a)): # row of a temp=[] for j in range(0,len(b[0])): # col of b s = 0 for k in range(0,len(a[0])): # col of a or row of b s += a[i][k]*b[k][j] temp.append(s) c.append(temp) return c a = b = [1, 4] [3, 3] [3, 2] [3, 3] [4, 1] matrix muliplication answer를 list라고 선언했을때 answer[0][0] = (a[0][0] * b[0][0]) + (a[0][1] * b[1][0]) . . . answer[2][1] = (a[2].. 2021. 3. 16. [프로그래머스] 숫자의 표현 파이썬 그냥 무식하게 brute force로 def solution(num): answer = 0 for i in range(1, num + 1): s = 0 while s < num: s += i i += 1 if s == num: answer += 1 return answer 2021. 3. 15. 이전 1 다음