Answer the question
In order to leave comments, you need to log in
Algorithm tester?
I am writing this answer.
comp=[1,2,3],[4,5,6]
comp2=[1],[2]
def test(arr):
result=''
for i in range(len(arr[0])):
for j in range(len(arr)):
result+=str(arr[j][i]) +' '
print(result)
test(comp)
Answer the question
In order to leave comments, you need to log in
with open('input.txt', 'r') as f:
nums = f.read().splitlines()
rows=nums[1:]
common=[]
result_string=''
for r in rows:
arr=r.split(' ')
common.append(arr)
for i in range(len(common[0])):
for j in range(len(common)):
result_string+=str(common[j][i])+' '
print(result_string)
Um... You need to read data from an input file (in a task, this is input.txt or stdin).
import sys
n = int(sys.stdin.readline().strip())
comp = [sys.stdin.readline().strip().split(" "), sys.stdin.readline().strip().split(" ")]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question