-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7bc9c93
commit b077bc6
Showing
2 changed files
with
544 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
def parse_crate_layout(file): | ||
lines = [] | ||
lines.append(FILE.readline()) | ||
while(lines[len(lines) - 1] != " 1 2 3 4 5 6 7 8 9 \n"): | ||
lines.append(FILE.readline()) | ||
lines.pop() | ||
lines.reverse() | ||
|
||
crate_layout = [[] for i in range(9)] | ||
for line in lines: | ||
for i in range(9): | ||
char = line[i * 4 + 1] | ||
if char != ' ': | ||
crate_layout[i].append(char) | ||
|
||
return crate_layout | ||
|
||
def simulate_crate_mover_9000(crate_layout, file): | ||
for line in FILE: | ||
n,form_crate,to_crate = line.rstrip().replace("move ","").replace(" from ",",").replace(" to ",",").split(',') | ||
for i in range(int(n)): | ||
crate_layout[int(to_crate) - 1].append(crate_layout[int(form_crate) - 1].pop()) | ||
|
||
def simulate_crate_mover_9001(crate_layout, file): | ||
for line in FILE: | ||
n,form_crate,to_crate = line.rstrip().replace("move ","").replace(" from ",",").replace(" to ",",").split(',') | ||
crate_layout[int(to_crate) - 1] = crate_layout[int(to_crate) - 1] + crate_layout[int(form_crate) - 1][-int(n):] | ||
crate_layout[int(form_crate) - 1] = crate_layout[int(form_crate) - 1][:-int(n)] | ||
FILE = open("downloadedInput.txt") | ||
|
||
#crate_rows = parse_crate_layout(FILE) | ||
#FILE.readline() | ||
#simulate_crate_mover_9001(crate_rows, FILE) |
Oops, something went wrong.