Skip to content

Commit 7eca76f

Browse files
authored
[2018] Remove Python 2.7 support (#58)
* [2018] Remove Python 2.7 support * Fix readme
1 parent b0b290f commit 7eca76f

File tree

26 files changed

+12
-67
lines changed

26 files changed

+12
-67
lines changed

2018/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ https://adventofcode.com/2018
55
## Language
66

77
This year I chose to implement in Python 2, but ported the code such that it
8-
works in either Python 2 or Python 3.
8+
works properly in Python 3. Python 2 support has been removed.
99

1010
## Preparation
1111

2018/day01/day01.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
https://adventofcode.com/2018/day/1
55
"""
66

7-
from __future__ import print_function
8-
97
from functools import reduce
108

119

2018/day02/day02.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
https://adventofcode.com/2018/day/2
55
"""
66

7-
from __future__ import print_function
8-
97
from collections import Counter, defaultdict
108
from functools import reduce
119

2018/day03/day03.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
https://adventofcode.com/2018/day/3
55
"""
66

7-
from __future__ import print_function
8-
97
import re
108
from collections import defaultdict
119
from functools import reduce

2018/day04/day04.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
https://adventofcode.com/2018/day/4
55
"""
66

7-
from __future__ import print_function
8-
97
import re
108
from collections import defaultdict
119

2018/day05/day05.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
https://adventofcode.com/2018/day/5
55
"""
66

7-
from __future__ import print_function
8-
97
from string import ascii_lowercase
108

119

2018/day06/day06.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,9 @@
44
https://adventofcode.com/2018/day/6
55
"""
66

7-
from __future__ import print_function
8-
97
import sys
108
from functools import reduce
119

12-
_MIN_INT = -sys.maxsize - 1
13-
1410

1511
class Point:
1612
"""Represents a point in 2D space."""
@@ -37,10 +33,10 @@ class Rect:
3733
@staticmethod
3834
def bounding_box(points):
3935
"""Returns a rectangle which forms the boundary of all points"""
40-
min_x = sys.maxsize
41-
min_y = sys.maxsize
42-
max_x = _MIN_INT
43-
max_y = _MIN_INT
36+
min_x = float('inf')
37+
min_y = float('inf')
38+
max_x = float('-inf')
39+
max_y = float('-inf')
4440

4541
for point in points:
4642
min_x = min(min_x, point.coord_x)

2018/day07/day07.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
https://adventofcode.com/2018/day/7
55
"""
66

7-
from __future__ import print_function
8-
97
import re
108
from collections import defaultdict
119

2018/day08/day08.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
https://adventofcode.com/2018/day/8
55
"""
66

7-
from __future__ import print_function
8-
97

108
class TreeNode: # pylint: disable=too-few-public-methods
119
"""Represents a single node in the tree."""

2018/day09/day09.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
https://adventofcode.com/2018/day/9
55
"""
66

7-
from __future__ import print_function
8-
97
import re
108
from collections import defaultdict
119

2018/day10/day10.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
https://adventofcode.com/2018/day/10
55
"""
66

7-
from __future__ import print_function
8-
97
import re
108

119
_ENTRY_REGEX = re.compile(

2018/day11/day11.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
https://adventofcode.com/2018/day/11
55
"""
66

7-
from __future__ import print_function
8-
97

108
def get_power_level(serial_number, coord_x, coord_y):
119
"""Gets the power level for a given coordinate."""

2018/day12/day12.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
https://adventofcode.com/2018/day/12
55
"""
66

7-
from __future__ import print_function
8-
97
import re
108
from collections import defaultdict, deque
119
from functools import reduce

2018/day13/day13.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
https://adventofcode.com/2018/day/13
55
"""
66

7-
from __future__ import print_function
8-
97
_TURN_ORDER = [
108
-1,
119
0,

2018/day14/day14.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
https://adventofcode.com/2018/day/14
55
"""
66

7-
from __future__ import print_function
8-
97

108
class RecipeGenerator:
119
"""Generator for the recipe combinations."""

2018/day15/day15.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
https://adventofcode.com/2018/day/15
55
"""
66

7-
from __future__ import print_function
8-
97
from collections import defaultdict, deque
108
from operator import attrgetter
119

2018/day16/day16.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
https://adventofcode.com/2018/day/16
55
"""
66

7-
from __future__ import print_function
8-
97
import re
108
from collections import defaultdict
119

2018/day17/day17.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
https://adventofcode.com/2018/day/17
55
"""
66

7-
from __future__ import print_function
8-
97
import re
108
from collections import defaultdict
119
from functools import reduce

2018/day18/day18.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,11 @@
44
https://adventofcode.com/2018/day/18
55
"""
66

7-
from __future__ import print_function
8-
97
from collections import Counter
108
from operator import itemgetter
119

1210

13-
try:
14-
xrange # pylint: disable=used-before-assignment
15-
except NameError:
16-
xrange = range # pylint: disable=invalid-name
11+
1712

1813

1914
class LumberArea:
@@ -33,9 +28,9 @@ def __init__(self, file_content):
3328

3429
def __str__(self):
3530
lines = []
36-
for row_index in xrange(self.max_rows + 1):
31+
for row_index in range(self.max_rows + 1):
3732
line = []
38-
for cell_index in xrange(self.max_cells + 1):
33+
for cell_index in range(self.max_cells + 1):
3934
line.append(self.area[(row_index, cell_index)])
4035
lines.append(''.join(line))
4136

@@ -48,8 +43,8 @@ def get_counts(self):
4843
def execute_minute(self):
4944
"""Executes a single minute of growth."""
5045
area_copy = self.area.copy()
51-
for row_index in xrange(self.max_rows + 1):
52-
for cell_index in xrange(self.max_cells + 1):
46+
for row_index in range(self.max_rows + 1):
47+
for cell_index in range(self.max_cells + 1):
5348
position = (row_index, cell_index)
5449
cell = self.area[position]
5550
if cell == '.':
@@ -94,7 +89,7 @@ def run_part1(file_content):
9489
"""Implmentation for Part 1."""
9590
area = LumberArea(file_content)
9691

97-
for _ in xrange(10):
92+
for _ in range(10):
9893
area.execute_minute()
9994

10095
counts = area.get_counts()
@@ -108,7 +103,7 @@ def run_part2(file_content):
108103
cycle_index = None
109104
cycle_patterns = []
110105

111-
for minute in xrange(1000000000):
106+
for minute in range(1000000000):
112107
area.execute_minute()
113108

114109
pattern = str(area)

2018/day19/day19.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
https://adventofcode.com/2018/day/19
55
"""
66

7-
from __future__ import print_function
8-
97
import re
108

119
_IP_REGEX = re.compile(r'^#ip (\d)$')

2018/day20/day20.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
https://adventofcode.com/2018/day/20
55
"""
66

7-
from __future__ import print_function
8-
97
from collections import defaultdict, deque
108
from operator import itemgetter
119
from sys import maxsize

2018/day21/day21.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
https://adventofcode.com/2018/day/21
55
"""
66

7-
from __future__ import print_function
8-
97
import re
108

119
_IP_REGEX = re.compile(r'^#ip (\d)$')

2018/day22/day22.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
https://adventofcode.com/2018/day/22
55
"""
66

7-
from __future__ import print_function
8-
97
import re
108
from collections import defaultdict
119
from operator import itemgetter

2018/day23/day23.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
https://adventofcode.com/2018/day/23
55
"""
66

7-
from __future__ import print_function
8-
97
import heapq
108
import re
119
from operator import attrgetter

2018/day24/day24.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
https://adventofcode.com/2018/day/24
55
"""
66

7-
from __future__ import print_function
8-
97
import re
108
from collections import defaultdict
119
from functools import reduce

2018/day25/day25.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
https://adventofcode.com/2018/day/25
55
"""
66

7-
from __future__ import print_function
8-
97
from collections import deque
108

119

0 commit comments

Comments
 (0)