11 "pi3 = open('advent03.txt').read().strip()"
29 "output_type": "execute_result"
33 "import collections\n",
36 "houses = collections.defaultdict(int)\n",
37 "houses[(0,0)] = 1\n",
39 "for direction in pi3:\n",
40 " if direction == \"^\":\n",
42 " if direction == 'v':\n",
44 " if direction == '>':\n",
46 " if direction == '<':\n",
48 " houses[(x, y)] += 1\n",
67 "output_type": "execute_result"
71 "import collections\n",
73 "x, y, rx, ry = 0, 0, 0, 0\n",
74 "houses = collections.defaultdict(int)\n",
75 "houses[(0,0)] = 2\n",
77 "for i in range(0, len(pi3), 2):\n",
78 " direction = pi3[i]\n",
79 " rdirection = pi3[i+1]\n",
80 " if direction == \"^\":\n",
82 " if direction == 'v':\n",
84 " if direction == '>':\n",
86 " if direction == '<':\n",
88 " houses[(x, y)] += 1\n",
89 " if rdirection == \"^\":\n",
91 " if rdirection == 'v':\n",
93 " if rdirection == '>':\n",
95 " if rdirection == '<':\n",
97 " houses[(rx, ry)] += 1\n",
103 "execution_count": null,
113 "display_name": "Python 3",
114 "language": "python",
122 "file_extension": ".py",
123 "mimetype": "text/x-python",
125 "nbconvert_exporter": "python",
126 "pygments_lexer": "ipython3",