re-organise repo
This commit is contained in:
24
2021/Gareth solution Python/1.py
Normal file
24
2021/Gareth solution Python/1.py
Normal file
@@ -0,0 +1,24 @@
|
||||
numbers = []
|
||||
rolling = []
|
||||
while True:
|
||||
a = input("")
|
||||
if a == "a":
|
||||
break
|
||||
numbers.append(a)
|
||||
print("Numbers are Inputed")
|
||||
z = 0
|
||||
while True:
|
||||
if z == len(numbers)-2:
|
||||
break
|
||||
a = int(numbers[z])+int(numbers[z+1])+int(numbers[z+2])
|
||||
rolling.append(a)
|
||||
z = z + 1
|
||||
inc = 0
|
||||
x = 0
|
||||
while True:
|
||||
if x == len(rolling)+1:
|
||||
break
|
||||
if int(rolling[x]) > int(rolling[x-1]):
|
||||
inc = inc + 1
|
||||
x = x + 1
|
||||
print(inc)
|
||||
19
2021/Gareth solution Python/2.py
Normal file
19
2021/Gareth solution Python/2.py
Normal file
File diff suppressed because one or more lines are too long
27
2021/Gareth solution Python/5pt1.py
Normal file
27
2021/Gareth solution Python/5pt1.py
Normal file
@@ -0,0 +1,27 @@
|
||||
lines = []
|
||||
while True:
|
||||
try:
|
||||
a, b, c, d = map(int, input().replace(",", " ").replace(" -> ", " ").split())
|
||||
lines.append([(a, b), (c, d)])
|
||||
except ValueError:
|
||||
break
|
||||
x = 0
|
||||
for line in lines:
|
||||
if max(line[0]) > x or max(line[1]) > x:
|
||||
x = [max(line[0]), max(line[1])][max(line[0]) < max(line[1])]
|
||||
|
||||
diagram = [[0 for i in range(x + 1)] for j in range(x + 1)]
|
||||
for line in lines:
|
||||
if line[0][1] == line[1][1]:
|
||||
for i in range(min(line[0][0], line[1][0]), max(line[0][0], line[1][0])+1):
|
||||
diagram[line[0][1]][i] += 1
|
||||
elif line[0][0] == line[1][0]:
|
||||
for i in range(min(line[0][1], line[1][1]), max(line[0][1], line[1][1])+1):
|
||||
diagram[i][line[0][0]] += 1
|
||||
count_bigger = 0
|
||||
for line in diagram:
|
||||
print(line)
|
||||
for num in line:
|
||||
count_bigger += [0, 1][num > 1]
|
||||
|
||||
print(count_bigger)
|
||||
38
2021/Gareth solution Python/5pt2.py
Normal file
38
2021/Gareth solution Python/5pt2.py
Normal file
@@ -0,0 +1,38 @@
|
||||
lines = []
|
||||
while True:
|
||||
try:
|
||||
a, b, c, d = map(int, input().replace(",", " ").replace(" -> ", " ").split())
|
||||
lines.append([(a, b), (c, d)])
|
||||
except ValueError:
|
||||
break
|
||||
x = 0
|
||||
for line in lines:
|
||||
if max(line[0]) > x or max(line[1]) > x:
|
||||
x = [max(line[0]), max(line[1])][max(line[0]) < max(line[1])]
|
||||
|
||||
diagram = [[0 for i in range(x + 1)] for j in range(x + 1)]
|
||||
for line in lines:
|
||||
if line[0][1] == line[1][1]:
|
||||
for i in range(min(line[0][0], line[1][0]), max(line[0][0], line[1][0]) + 1):
|
||||
diagram[line[0][1]][i] += 1
|
||||
elif line[0][0] == line[1][0]:
|
||||
for i in range(min(line[0][1], line[1][1]), max(line[0][1], line[1][1]) + 1):
|
||||
diagram[i][line[0][0]] += 1
|
||||
else:
|
||||
print(line)
|
||||
xs, x, ys, y = min(line[0][0], line[1][0]),\
|
||||
max(line[0][0], line[1][0]), \
|
||||
[line[0][1], line[1][1]][line[0][0] > line[1][0]],\
|
||||
[line[0][1], line[1][1]][line[0][0] < line[1][0]]
|
||||
yp = ys
|
||||
for i in range(xs, x+1):
|
||||
diagram[yp][i] += 1
|
||||
yp += [-1, 1][ys < y]
|
||||
|
||||
count_bigger = 0
|
||||
for line in diagram:
|
||||
print(line)
|
||||
for num in line:
|
||||
count_bigger += [0, 1][num > 1]
|
||||
|
||||
print(count_bigger)
|
||||
18
2021/Gareth solution Python/6.py
Normal file
18
2021/Gareth solution Python/6.py
Normal file
@@ -0,0 +1,18 @@
|
||||
#it is very not efficient for pt2 but I didn't have much time today to think of a better solution
|
||||
fish = [2,3,1,3,4,4,1,5,2,3,1,1,4,5,5,3,5,5,4,1,2,1,1,1,1,1,1,4,1,1,1,4,1,3,1,4,1,1,4,1,3,4,5,1,1,5,3,4,3,4,1,5,1,3,1,1,1,3,5,3,2,3,1,5,2,2,1,1,4,1,1,2,2,2,2,3,2,1,2,5,4,1,1,1,5,5,3,1,3,2,2,2,5,1,5,2,4,1,1,3,3,5,2,3,1,2,1,5,1,4,3,5,2,1,5,3,4,4,5,3,1,2,4,3,4,1,3,1,1,2,5,4,3,5,3,2,1,4,1,4,4,2,3,1,1,2,1,1,3,3,3,1,1,2,2,1,1,1,5,1,5,1,4,5,1,5,2,4,3,1,1,3,2,2,1,4,3,1,1,1,3,3,3,4,5,2,3,3,1,3,1,4,1,1,1,2,5,1,4,1,2,4,5,4,1,5,1,5,5,1,5,5,2,5,5,1,4,5,1,1,3,2,5,5,5,4,3,2,5,4,1,1,2,4,4,1,1,1,3,2,1,1,2,1,2,2,3,4,5,4,1,4,5,1,1,5,5,1,4,1,4,4,1,5,3,1,4,3,5,3,1,3,1,4,2,4,5,1,4,1,2,4,1,2,5,1,1,5,1,1,3,1,1,2,3,4,2,4,3,1]
|
||||
day = 0
|
||||
index = 0
|
||||
while True:
|
||||
if day == 256:
|
||||
break
|
||||
if index == len(fish):
|
||||
index = 0
|
||||
day = day + 1
|
||||
print("Day",day)
|
||||
if fish[index] == 0:
|
||||
fish[index] = 6
|
||||
fish.append(9)
|
||||
elif fish[index]!=0:
|
||||
fish[index]= fish[index]-1
|
||||
index = index + 1
|
||||
print("Number fo fish ",len(fish))
|
||||
7
2021/Gareth solution Python/ConvertToArray.py
Normal file
7
2021/Gareth solution Python/ConvertToArray.py
Normal file
@@ -0,0 +1,7 @@
|
||||
numbers = []
|
||||
while True:
|
||||
a = input("")
|
||||
if a == "a":
|
||||
break
|
||||
numbers.append(a)
|
||||
print(numbers)
|
||||
79
2021/Gareth solution Python/Day3pt2.py
Normal file
79
2021/Gareth solution Python/Day3pt2.py
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user