Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def foldx(xvalue):
- global coords
- global maxx
- maxx=xvalue
- for line in coords:
- if line[0]>xvalue:
- line[0]=2*xvalue-line[0]
- def foldy(yvalue):
- global coords
- global maxy
- maxy=yvalue
- for line in coords:
- if line[1]>yvalue:
- line[1]=2*yvalue-line[1]
- with open('input13') as f:
- lines = f.read().splitlines()
- coords=[]
- folds=[]
- isFoldsList=False
- for line in lines:
- if isFoldsList==True:
- folds.append(line)
- elif line!='':
- tmp = line.split(',')
- coords.append([int(tmp[0]),int(tmp[1])])
- else:
- isFoldsList=True
- maxx=0
- maxy=0
- for fold in folds:
- tmp=fold.split('=')
- if 'x' in tmp[0]:
- foldx(int(tmp[1]))
- else:
- foldy(int(tmp[1]))
- answer=[bytearray(' '*(maxx),'ascii') for i in range(maxy)]
- for line in coords:
- answer[line[1]][line[0]]=ord('#')
- print(answer)
Advertisement
Add Comment
Please, Sign In to add comment