-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAOC_Day5_part1.py
59 lines (51 loc) · 1.42 KB
/
AOC_Day5_part1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import re
import pandas as pd
import openpyxl
import numpy as np
File = open("Day5_Input.txt", "r")
Lines = File.readlines()
List = np.linspace(0, 127, 128)
def getMinMax(List,Letter):
if Letter == "F" or Letter == "L":
NewList = List[0:int(len(List)/2)]
else:
NewList = List[int(len(List)/2):int(len(List))]
return NewList
MaxRow = 0
TakenSeats = []
Data = [[],[]]
for Line in Lines:
List = np.linspace(0, 127, 128)
print(Line[0:7])
print(Line[8:10])
for ele in Line[0:6]:
List = getMinMax(List,ele)
if Line[6] == "F":
Row = List[0]
else:
Row = List[1]
List = np.linspace(0, 7, 8)
for ele in [Line[7],Line[8],Line[9]]:
List= getMinMax(List, ele)
Col = List[0]
if float(Row) > MaxRow:
MaxRow = Row
ColMax = Col
elif Row == MaxRow:
if float(Col) > ColMax:
ColMax = Col
print('Row = {0} and Col = {1}'.format(Row,Col))
if float(Row) > 1 and float(Row) < 126:
SeatID = float(Row)*8+float(Col)
TakenSeats.append(SeatID)
Data[0].append(Row)
Data[1].append(Col)
Array = np.array(TakenSeats)
print(len(Array))
Array.sort()
print(Array)
print(len(Array))
for i in range(1,len(Array)-1):
if Array[i+1]-Array[i] == 2:
MySeatID = Array[i]+1
print(MySeatID)