Skip to content

Commit 088c54a

Browse files
committed
Removed a lot of print statements
1 parent 452c69b commit 088c54a

15 files changed

+30
-62
lines changed

2015/08-Matchsticks.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
test_data = {}
55

66
test = 1
7-
test_data[test] = {"input": open('test.txt', "r+").read(),
7+
test_data[test] = {"input": '',
88
"expected": ['12', '19'],
99
}
1010

@@ -35,7 +35,6 @@
3535
len_literals = 0
3636
len_memory = 0
3737
for string in puzzle_input.split('\n'):
38-
print (string)
3938
len_literals += len(string)
4039

4140
string = string.replace('\\\\', '\\').replace('\\"', '"')
@@ -44,25 +43,20 @@
4443

4544
len_memory += len(string)
4645

47-
print (string, len_literals, len_memory)
48-
4946
puzzle_actual_result = len_literals - len_memory
5047

5148

5249
else:
5350
len_literals = 0
5451
len_escaped = 0
5552
for string in puzzle_input.split('\n'):
56-
print (string)
5753
len_literals += len(string)
5854

5955
string = string.replace('\\', '\\\\').replace('"', '\\"')
6056
string = '"' + string + '"'
6157

6258
len_escaped += len(string)
6359

64-
print (string, len_literals, len_escaped)
65-
6660
puzzle_actual_result = len_escaped - len_literals
6761

6862
# -------------------------------- Outputs / results -------------------------------- #

2015/22-Wizard Simulator 20XX.py

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ def apply_effects (counters, player_stats, boss_stats):
9191
if part_to_test == 2:
9292
player_stats[1] -= 1
9393
if player_stats[1] <= 0:
94-
print ('Boss wins')
94+
if verbose_level >=2:
95+
print ('Boss wins')
9596
break
9697

9798
# Apply effects
@@ -102,14 +103,16 @@ def apply_effects (counters, player_stats, boss_stats):
102103

103104
# Apply player move
104105
if spells[player_action][0] > player_stats[0]:
105-
print ('Aborting: not enough mana')
106+
if verbose_level >=2:
107+
print ('Aborting: not enough mana')
106108
break
107109
if spells[player_action][1] == 1:
108110
player_stats[1] += spells[player_action][3]
109111
boss_stats[0] -= spells[player_action][2]
110112
else:
111113
if counters[player_action] != 0:
112-
print ('Aborting: reused ' + player_action)
114+
if verbose_level >=2:
115+
print ('Aborting: reused ' + player_action)
113116
break
114117
else:
115118
counters[player_action] = spells[player_action][1]
@@ -120,7 +123,8 @@ def apply_effects (counters, player_stats, boss_stats):
120123
print (counters, player_stats, boss_stats)
121124

122125
if boss_stats[0] <= 0:
123-
print ('Player wins with', mana_used, 'mana used')
126+
if verbose_level >=2:
127+
print ('Player wins with', mana_used, 'mana used')
124128
min_mana_used = min (min_mana_used, mana_used)
125129
break
126130
if mana_used > min_mana_used:
@@ -140,7 +144,8 @@ def apply_effects (counters, player_stats, boss_stats):
140144
print (counters, player_stats, boss_stats)
141145

142146
if player_stats[1] <= 0:
143-
print ('Boss wins')
147+
if verbose_level >=2:
148+
print ('Boss wins')
144149
break
145150
else:
146151
max_moves = 15
@@ -152,7 +157,8 @@ def apply_effects (counters, player_stats, boss_stats):
152157
for strategy in itertools.product(spells.keys(), repeat=max_moves):
153158
count_strategies -= 1
154159
if 'S' not in strategy[0:4] or 'R' not in strategy[0:5]:
155-
print (' Missing Shield or Recharge')
160+
if verbose_level >=2:
161+
print (' Missing Shield or Recharge')
156162
continue
157163
if any ([True for i in range(1, max_moves) if strategy[0:i] in pruned_strategies]):
158164
print (' Pruned')
@@ -175,7 +181,8 @@ def apply_effects (counters, player_stats, boss_stats):
175181
# Player turn
176182
player_hp -= 1
177183
if player_hp <= 0:
178-
print ('Boss wins')
184+
if verbose_level >=2:
185+
print ('Boss wins')
179186
# pruned_strategies.append(tuple(actions_done))
180187
break
181188

@@ -198,7 +205,8 @@ def apply_effects (counters, player_stats, boss_stats):
198205

199206
# Apply player move
200207
if spells[player_action][0] > player_mana:
201-
print ('Aborting: not enough mana')
208+
if verbose_level >=2:
209+
print ('Aborting: not enough mana')
202210
# pruned_strategies.append(actions_done)
203211
break
204212
# Missile
@@ -215,34 +223,39 @@ def apply_effects (counters, player_stats, boss_stats):
215223
# Shield
216224
elif player_action == 'S':
217225
if shield_left != 0:
218-
print ('Aborting: reused ' + player_action)
226+
if verbose_level >=2:
227+
print ('Aborting: reused ' + player_action)
219228
# pruned_strategies.append(actions_done)
220229
break
221230
else:
222231
shield_left = 6
223232
# Poison
224233
elif player_action == 'P':
225234
if poison_left != 0:
226-
print ('Aborting: reused ' + player_action)
235+
if verbose_level >=2:
236+
print ('Aborting: reused ' + player_action)
227237
# pruned_strategies.append(actions_done)
228238
break
229239
else:
230240
poison_left = 6
231241
# Recharge
232242
elif player_action == 'R':
233243
if recharge_left != 0:
234-
print ('Aborting: reused ' + player_action)
244+
if verbose_level >=2:
245+
print ('Aborting: reused ' + player_action)
235246
# pruned_strategies.append(actions_done)
236247
break
237248
else:
238249
shield_left = 5
239250

240251
if boss_hp <= 0:
241-
print ('Player wins with', mana_used, 'mana used')
252+
if verbose_level >=2:
253+
print ('Player wins with', mana_used, 'mana used')
242254
min_mana_used = min (min_mana_used, mana_used)
243255
break
244256
if mana_used > min_mana_used:
245-
print ('Aborting: too much mana used')
257+
if verbose_level >=2:
258+
print ('Aborting: too much mana used')
246259
break
247260

248261

@@ -263,7 +276,8 @@ def apply_effects (counters, player_stats, boss_stats):
263276
player_hp -= boss_dmg - player_armor
264277

265278
if player_hp <= 0:
266-
print ('Boss wins')
279+
if verbose_level >=2:
280+
print ('Boss wins')
267281
# pruned_strategies.append(actions_done)
268282
break
269283
else:

2015/24-It Hangs in the Balance.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
group_weight = total_weight // 3 if part_to_test == 1 else total_weight // 4
5151

5252
for group1_size in range (1, len(list_packages) - 2):
53-
print('Testing with group 1 of size', group1_size)
5453
for group1 in itertools.combinations(list_packages, group1_size):
5554
if sum(group1) != group_weight:
5655
continue
@@ -60,7 +59,6 @@
6059
remaining_packages = [x for x in list_packages if x not in group1]
6160

6261
for group2_size in range (1, len(remaining_packages) - 2):
63-
print('Testing with group 2 of size', group2_size)
6462
for group2 in itertools.combinations(remaining_packages, group2_size):
6563
if sum(group2) == group_weight:
6664
mini_quantum_entanglement = min(mini_quantum_entanglement, reduce(mul, group1, 1))

2016/01-No Time for a Taxicab.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@
8989
if (x1, y1) == (x, y):
9090
continue
9191
if (x1, y1) in locations_visited and puzzle_actual_result == 'Unknown':
92-
print (x1, y1)
9392
puzzle_actual_result = abs(x1) + abs(y1)
9493
break
9594
locations_visited.append((x1, y1))

2016/03-Squares With Three Sides.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@
4242
sides.sort()
4343
a, b, c = sides
4444

45-
print (string, a, b, c, a+b)
46-
4745
if c < (a + b):
4846
possible_triangles += 1
4947

@@ -57,8 +55,6 @@
5755
for n in range(len(lines)//3):
5856
for i in range (3):
5957
sides = [int(lines[n*3+y][i]) for y in range (3)]
60-
print (lines[n*3:n*3+3])
61-
print(sides)
6258
sides.sort()
6359
a, b, c = sides
6460

2016/05-How About a Nice Game of Chess.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
encoded = hashlib.md5(coded_value).hexdigest()
4444
if encoded[0:5] == '00000':
4545
password += encoded[5]
46-
print (i, password, coded_value, encoded)
4746
if len(password) == 8:
4847
puzzle_actual_result = password
4948
break
@@ -61,7 +60,6 @@
6160
continue
6261
if password[int(encoded[5])] == '_':
6362
password[int(encoded[5])] = encoded[6]
64-
print (i, ''.join(password), coded_value, encoded)
6563
if '_' not in password:
6664
puzzle_actual_result = ''.join(password)
6765
break

2016/09-Explosives in Cyberspace.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@
8787
continue
8888

8989
def decompress(string):
90-
print (string)
9190
total_length = 0
9291

9392
if '(' in string:

2016/11-Radioisotope Thermoelectric Generators.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ def cost(self, current_node, next_node):
110110

111111
end = '4' * 11
112112

113-
print ('number of states', len(states))
114-
115113
graph = pathfinding.WeightedGraph()
116114
came_from, total_cost = graph.a_star_search(puzzle_input, end)
117115

2016/14-One-Time Pad.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
new_hash = hashlib.md5((puzzle_input + str(index + i)).encode('utf-8')).hexdigest()
5050
if triplet * 5 in new_hash:
5151
found_keys += 1
52-
print (init_hash, triplet, index, index + i, found_keys)
5352
break
5453

5554
if found_keys == 64:
@@ -81,21 +80,12 @@
8180
if quintuplets:
8281
hashes_quintuplets[i] = quintuplets
8382

84-
if i % 100 == 0:
85-
print ('calculated', i)
86-
87-
print ('Calculated hashes')
88-
89-
90-
print (hashes_first_triplet)
91-
print (hashes_quintuplets)
9283

9384
for index, triplet in hashes_first_triplet.items():
9485
for i in range (1, 1000):
9586
if index + i in hashes_quintuplets:
9687
if triplet in hashes_quintuplets[index + i]:
9788
found_keys += 1
98-
print (hashes[index], triplet, index, index + i, found_keys)
9989
break
10090

10191
if found_keys == 64:

2016/15-Timing is Everything.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343
if part_to_test == 2:
4444
disks.append((len(disks)+1, 11, 0))
4545

46-
print (disks)
47-
4846
time = 0
4947
while True:
5048
disk_ok = 0

0 commit comments

Comments
 (0)