From: Neil Smith Date: Sun, 13 Dec 2015 10:21:49 +0000 (+0000) Subject: Solutions up to day 13 X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=934a8916953ce74afa69a26ab9ff60cf2f91ad87;p=advent-of-code-15.git Solutions up to day 13 --- 934a8916953ce74afa69a26ab9ff60cf2f91ad87 diff --git a/.directory b/.directory new file mode 100644 index 0000000..eefeb2a --- /dev/null +++ b/.directory @@ -0,0 +1,4 @@ +[Dolphin] +Timestamp=2015,12,13,10,20,52 +Version=3 +ViewMode=1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0546add --- /dev/null +++ b/.gitignore @@ -0,0 +1,45 @@ +*.py[cod] + +# C extensions +*.so + +# Packages +*.egg +*.egg-info +dist +build +eggs +parts +bin +var +sdist +develop-eggs +.installed.cfg +lib +lib64 +__pycache__ + +# Installer logs +pip-log.txt + +# Unit test / coverage reports +.coverage +.tox +nosetests.xml + +# Translations +*.mo + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# IPython +.ipynb* + +# Sublime text +*.sublime-workspace + +# Logs +*.log diff --git a/SIGNED.md b/SIGNED.md new file mode 100644 index 0000000..8164edc --- /dev/null +++ b/SIGNED.md @@ -0,0 +1,108 @@ +##### Signed by https://keybase.io/neilnjae +``` +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v2 + +iQIcBAABCAAGBQJWbUbDAAoJEJPB2e07Pgbqq3MP/iuE0wAquzTghllO0Bh8Zk33 +y2/JLPlQ/WHV082bsP4tiMj/roMA/P6+D8oCf9AW95fdioPq7C9HMpu3l3qXY/7Y +XTIGN/AXkJX9RAiE1vdne7uinC1jx50OlyvLDiPv3dBgjZp1OfEY5iNzZ8XlYFOb +RcmpYr+0OX06oGdB7ydBQKhiSeWsASwmlL8Lhb6V4YikaUnD7ig4UkKD52srOMTH +2v/RJs/RVNtA/fSiCoXt65Lkfo/dYAkPJF6WMYeJi+s8P/y+Mp37FcJh7NyvPboM +AZ5ravIlS6SMihXBKjpgYUf/w5oTiL9EpTwk8RPsNHylY3QxpUfdd8I4IVqsm86T +FDrv/aL2CyzxnnGLcg73GiX3TI9+A+lg5gupjgkKqQk9i2JK6I9Jrv1+01BwijN7 +NOQ0dpb4UefJ0JS/2iHrPhVhGNsgNAaVuztyrAsFN3cZ+/qDjtsenWk7NLbn7/LL +pTgnmqeV1VZ8KEbAW51kM6JNnxQIYU4GxoPDj7nLLmd34qLW/AwvfIBrV9TCn54r +vwfVmfFfSVPCxbko1bQWAXJBMffkMGplRKLjVqJXK45VAcv2jzLXSJl/6afV1D31 +1x+2sYETRbhANJn2RYsePZWH18j5mASHweJkRakVkeMfV7VBgwcFvIX8PqsEbGnu +vQbRn1r9Z/UEdZzjJ+XC +=k7v/ +-----END PGP SIGNATURE----- + +``` + + + +### Begin signed statement + +#### Expect + +``` +size exec file contents + ./ +61 .directory 98a10e4b61e7a0e5156f6e0d5d3227255fd60f57ea34ae1b81bdd87c16bababb +384 .gitignore a93de2ae5c2a47a38599751d1f914566569dfa09dd1778e207117db6c71421dd +6394 advent-of-code-01.html 6155b76a1468f83176616650ca67af4a63c223442b7250571415225740627d17 +6521 advent-of-code-02.html dece9d48e80b27f854be07606fb0f3b1da6599d69cba1594fcda631010e57c07 +6253 advent-of-code-03.html 7dd8766e6ec8b92438657ad36326ce302432d526793a804ea7f6e62e6fdcec04 +5435 advent-of-code-04.html c550f004a8b0f5af1faf870ef0789008c3c5a9122a81ea3617cbb45cd93940e0 +7035 advent-of-code-05.html b538cae1feb365958c65882a323d2eccec214c1bebfccc2f2f3348d817ebd054 +6705 advent-of-code-06.html 76a0a89f9751e5a8b584b3c9bc0f33ab7ddee481d16f98ad71e61c0c6f3d6d08 +7190 advent-of-code-07.html 8555bc50c00f5b3d3e83b29e37169c553d4917c4cff517afbf73efb5ccd8ea23 +7936 advent-of-code-08.html 5d25c8ef68a3a34233d31e37bdef96381c7a777ef0bdf71209c1d9e163749b7a +5586 advent-of-code-09.html d26140599aa30b87beb1126eebbe78476cff57d5f950fbe729a449f4d7aa0fb6 +5929 advent-of-code-10.html a4936eee59d96d9eedbe177299ac8c5fc94595db7f2959b6d54070ba79599b6f +6562 advent-of-code-11.html f6ef213572c945e0f55ea5cef3dbeffa7a6c22e5fda2c2d56365117886d88863 +5919 advent-of-code-12.html cc84ec3c04da02c7d566f7c0f3ea08a4abf57f2931d7dc87915b2a88d1944e8c +7192 advent-of-code-13.html 9b84752c8f387cd03f85299c78837cea35c64a0276db7dbef9e33f82971b47e2 +109395 advent-of-code.ipynb 7292eeb9a8019f6931037c70105ab96bf691074dbe963736b6429cb4d4373f51 +25607 advent01.ipynb c33ad39a77803a6870dd74998da98e3bb9c2c2db37c34167b330a01d663717e7 +7001 advent01.txt 79312922877bdedd09ce0886a42b3d7f7ed092e2218579fb7d6ac1cb38cedebe +2422 advent02.ipynb 7576c0aa7bdb2eff73fddf62007271be781c19fd7ad91fd0dd75053a8c391884 +8112 advent02.txt b292113c3aa7b376a88a6ea57a5f30edef6c50e6aba7e947fad6f7a6a11e5156 +2676 advent03.ipynb 3078936407038050d75235c1367b83d30a8d6cce8d8fde8063e3c0928cc9277d +8193 advent03.txt a76a8c8606405157a5a28d79960a5125212c6d5b1db57f222fc52272bf4f95b4 +2611 advent04.ipynb 7698d77125561b78e8965c6b26150f7d2e6ca23e918ed4c7a95fa36c534ffd5d +3514 advent05.ipynb b726978b2fc36660e7afa2433db3cc94c962cf46b30e05b5c1f73825a4186093 +17000 advent05.txt 101c771d218044ec73cd83ff97d73b004df99475447f9fe66b8e9b58d01b0f8c +11641 advent06.ipynb 9ff7b2a9760e5551a3c51e978f4696c9872c7467bdaa93a1675c5d86aa41a719 +9525 advent06.txt 0e9c027e1983a02fec4d3d856630b1fad112879cfc1dfb630ffa8a98f2953a67 +24067 advent07.ipynb b9a2fb8436ee35b0e4e743d5927d38802edede5d27ae02d09671da7c5bd2f56b +5303 advent07.txt 808248ff71a40272677ae61d4270cfbbe911c1cca7023f19a30ec70ad777ae2d +5012 advent08.ipynb d4508791aa6ce8f0618da68e58c30089e0e8a9954a617ba8530e9c32519eeb44 +6495 advent08.txt fed7e63100a843e538fe07f1fab2ea2236a9f4fc1b10ec309c5e30812647bb19 +13073 advent09.ipynb 8f69c9554c3bf05750460f2f98bc96799ae1a9e079e02696d6429f9591f6dc90 +715 advent09.txt b7fe7bf169dbd6e35de3cf1aff257046edf9919986ce92175d62c7abf28da736 +3696 advent10.ipynb 814d99c479c133f06c1176617807db41df95727445c2130654a8cf0f2891048c +5892 advent11.ipynb f2321f15d9ebe936f0e3305672a789f48919f605a9ac341d3704f398ba7233b4 +3217 advent12.ipynb b794e2f0b624e9b1b9ed11065a5298b09daa9116c38ae07ab2731c7fce797289 +42142 advent12.json f7b94a7f5aa11f94edea6a1727fcf81613306c53a9a84078ff557d216cfbb6c9 +10185 advent13.ipynb 30e1bfd714003c6ee5a4e23f8e1d5874658be3fae51b1e709451d1d55086469e +3465 advent13.txt a8610959b8c1388f53a7720828c8a1cad08b1c95661d198e01157fc83ef08605 +``` + +#### Ignore + +``` +/SIGNED.md +``` + +#### Presets + +``` +git # ignore .git and anything as described by .gitignore files +``` + + + +### End signed statement + +
+ +#### Notes + +With keybase you can sign any directory's contents, whether it's a git repo, +source code distribution, or a personal documents folder. It aims to replace the drudgery of: + + 1. comparing a zipped file to a detached statement + 2. downloading a public key + 3. confirming it is in fact the author's by reviewing public statements they've made, using it + +All in one simple command: + +```bash +keybase dir verify +``` + +There are lots of options, including assertions for automating your checks. + +For more info, check out https://keybase.io/docs/command_line/code_signing \ No newline at end of file diff --git a/advent-of-code-01.html b/advent-of-code-01.html new file mode 100644 index 0000000..30aa36d --- /dev/null +++ b/advent-of-code-01.html @@ -0,0 +1,152 @@ + + + + +Day 1 - Advent of Code + + + + + + +

Advent of Code

Neil Smith 26*
+ + + +
+

--- Day 1: Not Quite Lisp ---

Santa was hoping for a white Christmas, but his weather machine's "snow" function is powered by stars, and he's fresh out! To save Christmas, he needs you to collect fifty stars by December 25th.

+

Collect stars by helping Santa solve puzzles. Two puzzles will be made available on each day in the advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle grants one star. Good luck!

+

Here's an easy puzzle to warm you up.

+

Santa is trying to deliver presents in a large apartment building, but he can't find the right floor - the directions he got are a little confusing. He starts on the ground floor (floor 0) and then follows the instructions one character at a time.

+

An opening parenthesis, (, means he should go up one floor, and a closing parenthesis, ), means he should go down one floor.

+

The apartment building is very tall, and the basement is very deep; he will never find the top or bottom floors.

+

For example:

+
    +
  • (()) and ()() both result in floor 0.
  • +
  • ((( and (()(()( both result in floor 3.
  • +
  • ))((((( also results in floor 3.
  • +
  • ()) and ))( both result in floor -1 (the first basement level).
  • +
  • ))) and )())()) both result in floor -3.
  • +
+

To what floor do the instructions take Santa?

+
+

Your puzzle answer was 138.

--- Part Two ---

Now, given the same instructions, find the position of the first character that causes him to enter the basement (floor -1). The first character in the instructions has position 1, the second character has position 2, and so on.

+

For example:

+
    +
  • ) causes him to enter the basement at character position 1.
  • +
  • ()()) causes him to enter the basement at character position 5.
  • +
+

What is the position of the character that causes Santa to first enter the basement?

+
+

Your puzzle answer was 1771.

Both parts of this puzzle are complete! They provide two gold stars: **

+

At this point, you should return to your advent calendar and try another puzzle.

+

If you still want to see it, you can get your puzzle input.

+

You can also + this puzzle.

+
+ + + + + + diff --git a/advent-of-code-02.html b/advent-of-code-02.html new file mode 100644 index 0000000..cfd81fb --- /dev/null +++ b/advent-of-code-02.html @@ -0,0 +1,146 @@ + + + + +Day 2 - Advent of Code + + + + + + +

Advent of Code

Neil Smith 26*
+ + + +
+

--- Day 2: I Was Told There Would Be No Math ---

The elves are running low on wrapping paper, and so they need to submit an order for more. They have a list of the dimensions (length l, width w, and height h) of each present, and only want to order exactly as much as they need.

+

Fortunately, every present is a box (a perfect right rectangular prism), which makes calculating the required wrapping paper for each gift a little easier: find the surface area of the box, which is 2*l*w + 2*w*h + 2*h*l. The elves also need a little extra paper for each present: the area of the smallest side.

+

For example:

+
    +
  • A present with dimensions 2x3x4 requires 2*6 + 2*12 + 2*8 = 52 square feet of wrapping paper plus 6 square feet of slack, for a total of 58 square feet.
  • +
  • A present with dimensions 1x1x10 requires 2*1 + 2*10 + 2*10 = 42 square feet of wrapping paper plus 1 square foot of slack, for a total of 43 square feet.
  • +
+

All numbers in the elves' list are in feet. How many total square feet of wrapping paper should they order?

+
+

Your puzzle answer was 1588178.

--- Part Two ---

The elves are also running low on ribbon. Ribbon is all the same width, so they only have to worry about the length they need to order, which they would again like to be exact.

+

The ribbon required to wrap a present is the shortest distance around its sides, or the smallest perimeter of any one face. Each present also requires a bow made out of ribbon as well; the feet of ribbon required for the perfect bow is equal to the cubic feet of volume of the present. Don't ask how they tie the bow, though; they'll never tell.

+

For example:

+
    +
  • A present with dimensions 2x3x4 requires 2+2+3+3 = 10 feet of ribbon to wrap the present plus 2*3*4 = 24 feet of ribbon for the bow, for a total of 34 feet.
  • +
  • A present with dimensions 1x1x10 requires 1+1+1+1 = 4 feet of ribbon to wrap the present plus 1*1*10 = 10 feet of ribbon for the bow, for a total of 14 feet.
  • +
+

How many total feet of ribbon should they order?

+
+

Your puzzle answer was 3783758.

Both parts of this puzzle are complete! They provide two gold stars: **

+

At this point, you should return to your advent calendar and try another puzzle.

+

If you still want to see it, you can get your puzzle input.

+

You can also + this puzzle.

+
+ + + + + + diff --git a/advent-of-code-03.html b/advent-of-code-03.html new file mode 100644 index 0000000..a0313dd --- /dev/null +++ b/advent-of-code-03.html @@ -0,0 +1,148 @@ + + + + +Day 3 - Advent of Code + + + + + + +

Advent of Code

Neil Smith 26*
+ + + +
+

--- Day 3: Perfectly Spherical Houses in a Vacuum ---

Santa is delivering presents to an infinite two-dimensional grid of houses.

+

He begins by delivering a present to the house at his starting location, and then an elf at the North Pole calls him via radio and tells him where to move next. Moves are always exactly one house to the north (^), south (v), east (>), or west (<). After each move, he delivers another present to the house at his new location.

+

However, the elf back at the north pole has had a little too much eggnog, and so his directions are a little off, and Santa ends up visiting some houses more than once. How many houses receive at least one present?

+

For example:

+
    +
  • > delivers presents to 2 houses: one at the starting location, and one to the east.
  • +
  • ^>v< delivers presents to 4 houses in a square, including twice to the house at his starting/ending location.
  • +
  • ^v^v^v^v^v delivers a bunch of presents to some very lucky children at only 2 houses.
  • +
+
+

Your puzzle answer was 2081.

--- Part Two ---

The next year, to speed up the process, Santa creates a robot version of himself, Robo-Santa, to deliver presents with him.

+

Santa and Robo-Santa start at the same location (delivering two presents to the same starting house), then take turns moving based on instructions from the elf, who is eggnoggedly reading from the same script as the previous year.

+

This year, how many houses receive at least one present?

+

For example:

+
    +
  • ^v delivers presents to 3 houses, because Santa goes north, and then Robo-Santa goes south.
  • +
  • ^>v< now delivers presents to 3 houses, and Santa and Robo-Santa end up back where they started.
  • +
  • ^v^v^v^v^v now delivers presents to 11 houses, with Santa going one direction and Robo-Santa going the other.
  • +
+
+

Your puzzle answer was 2341.

Both parts of this puzzle are complete! They provide two gold stars: **

+

At this point, you should return to your advent calendar and try another puzzle.

+

If you still want to see it, you can get your puzzle input.

+

You can also + this puzzle.

+
+ + + + + + diff --git a/advent-of-code-04.html b/advent-of-code-04.html new file mode 100644 index 0000000..bc37137 --- /dev/null +++ b/advent-of-code-04.html @@ -0,0 +1,138 @@ + + + + +Day 4 - Advent of Code + + + + + + +

Advent of Code

Neil Smith 26*
+ + + +
+

--- Day 4: The Ideal Stocking Stuffer ---

Santa needs help mining some AdventCoins (very similar to bitcoins) to use as gifts for all the economically forward-thinking little girls and boys.

+

To do this, he needs to find MD5 hashes which, in hexadecimal, start with at least five zeroes. The input to the MD5 hash is some secret key (your puzzle input, given below) followed by a number in decimal. To mine AdventCoins, you must find Santa the lowest positive number (no leading zeroes: 1, 2, 3, ...) that produces such a hash.

+

For example:

+
    +
  • If your secret key is abcdef, the answer is 609043, because the MD5 hash of abcdef609043 starts with five zeroes (000001dbbfa...), and it is the lowest such number to do so.
  • +
  • If your secret key is pqrstuv, the lowest number it combines with to make an MD5 hash starting with five zeroes is 1048970; that is, the MD5 hash of pqrstuv1048970 looks like 000006136ef....
  • +
+
+

Your puzzle answer was 346386.

--- Part Two ---

Now find one that starts with six zeroes.

+
+

Your puzzle answer was 9958218.

Both parts of this puzzle are complete! They provide two gold stars: **

+

At this point, you should return to your advent calendar and try another puzzle.

+

Your puzzle input was iwrupvqb.

+

You can also + this puzzle.

+
+ + + + + + diff --git a/advent-of-code-05.html b/advent-of-code-05.html new file mode 100644 index 0000000..c22e0a9 --- /dev/null +++ b/advent-of-code-05.html @@ -0,0 +1,160 @@ + + + + +Day 5 - Advent of Code + + + + + + +

Advent of Code

Neil Smith 26*
+ + + +
+

--- Day 5: Doesn't He Have Intern-Elves For This? ---

Santa needs help figuring out which strings in his text file are naughty or nice.

+

A nice string is one with all of the following properties:

+
    +
  • It contains at least three vowels (aeiou only), like aei, xazegov, or aeiouaeiouaeiou.
  • +
  • It contains at least one letter that appears twice in a row, like xx, abcdde (dd), or aabbccdd (aa, bb, cc, or dd).
  • +
  • It does not contain the strings ab, cd, pq, or xy, even if they are part of one of the other requirements.
  • +
+

For example:

+
    +
  • ugknbfddgicrmopn is nice because it has at least three vowels (u...i...o...), a double letter (...dd...), and none of the disallowed substrings.
  • +
  • aaa is nice because it has at least three vowels and a double letter, even though the letters used by different rules overlap.
  • +
  • jchzalrnumimnmhp is naughty because it has no double letter.
  • +
  • haegwjzuvuyypxyu is naughty because it contains the string xy.
  • +
  • dvszwmarrgswjxmb is naughty because it contains only one vowel.
  • +
+

How many strings are nice?

+
+

Your puzzle answer was 255.

--- Part Two ---

Realizing the error of his ways, Santa has switched to a better model of determining whether a string is naughty or nice. None of the old rules apply, as they are all clearly ridiculous.

+

Now, a nice string is one with all of the following properties:

+
    +
  • It contains a pair of any two letters that appears at least twice in the string without overlapping, like xyxy (xy) or aabcdefgaa (aa), but not like aaa (aa, but it overlaps).
  • +
  • It contains at least one letter which repeats with exactly one letter between them, like xyx, abcdefeghi (efe), or even aaa.
  • +
+

For example:

+
    +
  • qjhvhtzxzqqjkmpb is nice because is has a pair that appears twice (qj) and a letter that repeats with exactly one letter between them (zxz).
  • +
  • xxyxx is nice because it has a pair that appears twice and a letter that repeats with one between, even though the letters used by each rule overlap.
  • +
  • uurcxstgmygtbstg is naughty because it has a pair (tg) but no repeat with a single letter between them.
  • +
  • ieodomkazucvgmuy is naughty because it has a repeating letter with one between (odo), but no pair that appears twice.
  • +
+

How many strings are nice under these new rules?

+
+

Your puzzle answer was 55.

Both parts of this puzzle are complete! They provide two gold stars: **

+

At this point, you should return to your advent calendar and try another puzzle.

+

If you still want to see it, you can get your puzzle input.

+

You can also + this puzzle.

+
+ + + + + + diff --git a/advent-of-code-06.html b/advent-of-code-06.html new file mode 100644 index 0000000..61f3995 --- /dev/null +++ b/advent-of-code-06.html @@ -0,0 +1,152 @@ + + + + +Day 6 - Advent of Code + + + + + + +

Advent of Code

Neil Smith 26*
+ + + +
+

--- Day 6: Probably a Fire Hazard ---

Because your neighbors keep defeating you in the holiday house decorating contest year after year, you've decided to deploy one million lights in a 1000x1000 grid.

+

Furthermore, because you've been especially nice this year, Santa has mailed you instructions on how to display the ideal lighting configuration.

+

Lights in your grid are numbered from 0 to 999 in each direction; the lights at each corner are at 0,0, 0,999, 999,999, and 999,0. The instructions include whether to turn on, turn off, or toggle various inclusive ranges given as coordinate pairs. Each coordinate pair represents opposite corners of a rectangle, inclusive; a coordinate pair like 0,0 through 2,2 therefore refers to 9 lights in a 3x3 square. The lights all start turned off. +

To defeat your neighbors this year, all you have to do is set up your lights by doing the instructions Santa sent you in order.

+

For example:

+
    +
  • turn on 0,0 through 999,999 would turn on (or leave on) every light.
  • +
  • toggle 0,0 through 999,0 would toggle the first line of 1000 lights, turning off the ones that were on, and turning on the ones that were off.
  • +
  • turn off 499,499 through 500,500 would turn off (or leave off) the middle four lights.
  • +
+

After following the instructions, how many lights are lit?

+
+

Your puzzle answer was 569999.

--- Part Two ---

You just finish implementing your winning light pattern when you realize you mistranslated Santa's message from Ancient Nordic Elvish.

+

The light grid you bought actually has individual brightness controls; each light can have a brightness of zero or more. The lights all start at zero.

+

The phrase turn on actually means that you should increase the brightness of those lights by 1.

+

The phrase turn off actually means that you should decrease the brightness of those lights by 1, to a minimum of zero.

+

The phrase toggle actually means that you should increase the brightness of those lights by 2.

+

What is the total brightness of all lights combined after following Santa's instructions?

+

For example:

+
    +
  • turn on 0,0 through 0,0 would increase the total brightness by 1.
  • +
  • toggle 0,0 through 999,999 would increase the total brightness by 2000000.
  • +
+
+

Your puzzle answer was 17836115.

Both parts of this puzzle are complete! They provide two gold stars: **

+

At this point, you should return to your advent calendar and try another puzzle.

+

If you still want to see it, you can get your puzzle input.

+

You can also + this puzzle.

+
+ + + + + + diff --git a/advent-of-code-07.html b/advent-of-code-07.html new file mode 100644 index 0000000..c48149f --- /dev/null +++ b/advent-of-code-07.html @@ -0,0 +1,163 @@ + + + + +Day 7 - Advent of Code + + + + + + +

Advent of Code

Neil Smith 26*
+ + + +
+

--- Day 7: Some Assembly Required ---

This year, Santa brought little Bobby Tables a set of wires and bitwise logic gates! Unfortunately, little Bobby is a little under the recommended age range, and he needs help assembling the circuit.

+

Each wire has an identifier (some lowercase letters) and can carry a 16-bit signal (a number from 0 to 65535). A signal is provided to each wire by a gate, another wire, or some specific value. Each wire can only get a signal from one source, but can provide its signal to multiple destinations. A gate provides no signal until all of its inputs have a signal.

+

The included instructions booklet describes how to connect the parts together: x AND y -> z means to connect wires x and y to an AND gate, and then connect its output to wire z.

+

For example:

+
    +
  • 123 -> x means that the signal 123 is provided to wire x.
  • +
  • x AND y -> z means that the bitwise AND of wire x and wire y is provided to wire z.
  • +
  • p LSHIFT 2 -> q means that the value from wire p is left-shifted by 2 and then provided to wire q.
  • +
  • NOT e -> f means that the bitwise complement of the value from wire e is provided to wire f.
  • +
+

Other possible gates include OR (bitwise OR) and RSHIFT (right-shift). If, for some reason, you'd like to emulate the circuit instead, almost all programming languages (for example, C, JavaScript, or Python) provide operators for these gates.

+

For example, here is a simple circuit:

+
123 -> x
+456 -> y
+x AND y -> d
+x OR y -> e
+x LSHIFT 2 -> f
+y RSHIFT 2 -> g
+NOT x -> h
+NOT y -> i
+
+

After it is run, these are the signals on the wires:

+
d: 72
+e: 507
+f: 492
+g: 114
+h: 65412
+i: 65079
+x: 123
+y: 456
+
+

In little Bobby's kit's instructions booklet (provided as your puzzle input), what signal is ultimately provided to wire a?

+
+

Your puzzle answer was 16076.

--- Part Two ---

Now, take the signal you got on wire a, override wire b to that signal, and reset the other wires (including wire a). What new signal is ultimately provided to wire a?

+
+

Your puzzle answer was 2797.

Both parts of this puzzle are complete! They provide two gold stars: **

+

At this point, you should return to your advent calendar and try another puzzle.

+

If you still want to see it, you can get your puzzle input.

+

You can also + this puzzle.

+
+ + + + + + diff --git a/advent-of-code-08.html b/advent-of-code-08.html new file mode 100644 index 0000000..4c46c0a --- /dev/null +++ b/advent-of-code-08.html @@ -0,0 +1,152 @@ + + + + +Day 8 - Advent of Code + + + + + + +

Advent of Code

Neil Smith 26*
+ + + +
+

--- Day 8: Matchsticks ---

Space on the sleigh is limited this year, and so Santa will be bringing his list as a digital copy. He needs to know how much space it will take up when stored.

+

It is common in many programming languages to provide a way to escape special characters in strings. For example, C, JavaScript, Perl, Python, and even PHP handle special characters in very similar ways.

+

However, it is important to realize the difference between the number of characters in the code representation of the string literal and the number of characters in the in-memory string itself.

+

For example:

+
    +
  • "" is 2 characters of code (the two double quotes), but the string contains zero characters.
  • +
  • "abc" is 5 characters of code, but 3 characters in the string data.
  • +
  • "aaa\"aaa" is 10 characters of code, but the string itself contains six "a" characters and a single, escaped quote character, for a total of 7 characters in the string data.
  • +
  • "\x27" is 6 characters of code, but the string itself contains just one - an apostrophe ('), escaped using hexadecimal notation.
  • +
+

Santa's list is a file that contains many double-quoted string literals, one on each line. The only escape sequences used are \\ (which represents a single backslash), \" (which represents a lone double-quote character), and \x plus two hexadecimal characters (which represents a single character with that ASCII code).

+

Disregarding the whitespace in the file, what is the number of characters of code for string literals minus the number of characters in memory for the values of the strings in total for the entire file?

+

For example, given the four strings above, the total number of characters of string code (2 + 5 + 10 + 6 = 23) minus the total number of characters in memory for string values (0 + 3 + 7 + 1 = 11) is 23 - 11 = 12.

+
+

Your puzzle answer was 1350.

--- Part Two ---

Now, let's go the other way. In addition to finding the number of characters of code, you should now encode each code representation as a new string and find the number of characters of the new encoded representation, including the surrounding double quotes.

+

For example:

+
    +
  • "" encodes to "\"\"", an increase from 2 characters to 6.
  • +
  • "abc" encodes to "\"abc\"", an increase from 5 characters to 9.
  • +
  • "aaa\"aaa" encodes to "\"aaa\\\"aaa\"", an increase from 10 characters to 16.
  • +
  • "\x27" encodes to "\"\\x27\"", an increase from 6 characters to 11.
  • +
+

Your task is to find the total number of characters to represent the newly encoded strings minus the number of characters of code in each original string literal. For example, for the strings above, the total encoded length (6 + 9 + 16 + 11 = 42) minus the characters in the original code representation (23, just like in the first part of this puzzle) is 42 - 23 = 19.

+
+

Your puzzle answer was 2085.

Both parts of this puzzle are complete! They provide two gold stars: **

+

At this point, you should return to your advent calendar and try another puzzle.

+

If you still want to see it, you can get your puzzle input.

+

You can also + this puzzle.

+
+ + + + + + diff --git a/advent-of-code-09.html b/advent-of-code-09.html new file mode 100644 index 0000000..067ca81 --- /dev/null +++ b/advent-of-code-09.html @@ -0,0 +1,151 @@ + + + + +Day 9 - Advent of Code + + + + + + +

Advent of Code

Neil Smith 26*
+ + + +
+

--- Day 9: All in a Single Night ---

Every year, Santa manages to deliver all of his presents in a single night.

+

This year, however, he has some new locations to visit; his elves have provided him the distances between every pair of locations. He can start and end at any two (different) locations he wants, but he must visit each location exactly once. What is the shortest distance he can travel to achieve this?

+

For example, given the following distances:

+
London to Dublin = 464
+London to Belfast = 518
+Dublin to Belfast = 141
+
+

The possible routes are therefore:

+
Dublin -> London -> Belfast = 982
+London -> Dublin -> Belfast = 605
+London -> Belfast -> Dublin = 659
+Dublin -> Belfast -> London = 659
+Belfast -> Dublin -> London = 605
+Belfast -> London -> Dublin = 982
+
+

The shortest of these is London -> Dublin -> Belfast = 605, and so the answer is 605 in this example.

+

What is the distance of the shortest route?

+
+

Your puzzle answer was 207.

--- Part Two ---

The next year, just to show off, Santa decides to take the route with the longest distance instead.

+

He can still start and end at any two (different) locations he wants, and he still must visit each location exactly once.

+

For example, given the distances above, the longest route would be 982 via (for example) Dublin -> London -> Belfast.

+

What is the distance of the longest route?

+
+

Your puzzle answer was 804.

Both parts of this puzzle are complete! They provide two gold stars: **

+

At this point, you should return to your advent calendar and try another puzzle.

+

If you still want to see it, you can get your puzzle input.

+

You can also + this puzzle.

+
+ + + + + + diff --git a/advent-of-code-10.html b/advent-of-code-10.html new file mode 100644 index 0000000..ea880c6 --- /dev/null +++ b/advent-of-code-10.html @@ -0,0 +1,143 @@ + + + + +Day 10 - Advent of Code + + + + + + +

Advent of Code

Neil Smith 26*
+ + + +
+

--- Day 10: Elves Look, Elves Say ---

Today, the Elves are playing a game called look-and-say. They take turns making sequences by reading aloud the previous sequence and using that reading as the next sequence. For example, 211 is read as "one two, two ones", which becomes 1221 (1 2, 2 1s).

+

Look-and-say sequences are generated iteratively, using the previous value as input for the next step. For each step, take the previous value, and replace each run of digits (like 111) with the number of digits (3) followed by the digit itself (1).

+

For example:

+
    +
  • 1 becomes 11 (1 copy of digit 1).
  • +
  • 11 becomes 21 (2 copies of digit 1).
  • +
  • 21 becomes 1211 (one 2 followed by one 1).
  • +
  • 1211 becomes 111221 (one 1, one 2, and two 1s).
  • +
  • 111221 becomes 312211 (three 1s, two 2s, and one 1).
  • +
+

Starting with the digits in your puzzle input, apply this process 40 times. What is the length of the result?

+
+

Your puzzle answer was 329356.

--- Part Two ---

Neat, right? You might also enjoy hearing John Conway talking about this sequence (that's Conway of Conway's Game of Life fame).

+

Now, starting again with the digits in your puzzle input, apply this process 50 times. What is the length of the new result?

+
+

Your puzzle answer was 4666278.

Both parts of this puzzle are complete! They provide two gold stars: **

+

At this point, you should return to your advent calendar and try another puzzle.

+

Your puzzle input was 3113322113.

+

You can also + this puzzle.

+
+ + + + + + diff --git a/advent-of-code-11.html b/advent-of-code-11.html new file mode 100644 index 0000000..9c393bd --- /dev/null +++ b/advent-of-code-11.html @@ -0,0 +1,149 @@ + + + + +Day 11 - Advent of Code + + + + + + +

Advent of Code

Neil Smith 26*
+ + + +
+

--- Day 11: Corporate Policy ---

Santa's previous password expired, and he needs help choosing a new one.

+

To help him remember his new password after the old one expires, Santa has devised a method of coming up with a password based on the previous one. Corporate policy dictates that passwords must be exactly eight lowercase letters (for security reasons), so he finds his new password by incrementing his old password string repeatedly until it is valid.

+

Incrementing is just like counting with numbers: xx, xy, xz, ya, yb, and so on. Increase the rightmost letter one step; if it was z, it wraps around to a, and repeat with the next letter to the left until one doesn't wrap around.

+

Unfortunately for Santa, a new Security-Elf recently started, and he has imposed some additional password requirements:

+
    +
  • Passwords must include one increasing straight of at least three letters, like abc, bcd, cde, and so on, up to xyz. They cannot skip letters; abd doesn't count.
  • +
  • Passwords may not contain the letters i, o, or l, as these letters can be mistaken for other characters and are therefore confusing.
  • +
  • Passwords must contain at least two different, non-overlapping pairs of letters, like aa, bb, or zz.
  • +
+

For example:

+
    +
  • hijklmmn meets the first requirement (because it contains the straight hij) but fails the second requirement requirement (because it contains i and l).
  • +
  • abbceffg meets the third requirement (because it repeats bb and ff) but fails the first requirement.
  • +
  • abbcegjk fails the third requirement, because it only has one double letter (bb).
  • +
  • The next password after abcdefgh is abcdffaa.
  • +
  • The next password after ghijklmn is ghjaabcc, because you eventually skip all the passwords that start with ghi..., since i is not allowed.
  • +
+

Given Santa's current password (your puzzle input), what should his next password be?

+
+

Your puzzle answer was hxbxxyzz.

--- Part Two ---

Santa's password expired again. What's the next one?

+
+

Your puzzle answer was hxcaabcc.

Both parts of this puzzle are complete! They provide two gold stars: **

+

At this point, you should return to your advent calendar and try another puzzle.

+

Your puzzle input was hxbxwxba.

+

You can also + this puzzle.

+
+ + + + + + diff --git a/advent-of-code-12.html b/advent-of-code-12.html new file mode 100644 index 0000000..b4ffa2f --- /dev/null +++ b/advent-of-code-12.html @@ -0,0 +1,149 @@ + + + + +Day 12 - Advent of Code + + + + + + +

Advent of Code

Neil Smith 26*
+ + + +
+

--- Day 12: JSAbacusFramework.io ---

Santa's Accounting-Elves need help balancing the books after a recent order. Unfortunately, their accounting software uses a peculiar storage format. That's where you come in.

+

They have a JSON document which contains a variety of things: arrays ([1,2,3]), objects ({"a":1, "b":2}), numbers, and strings. Your first job is to simply find all of the numbers throughout the document and add them together.

+

For example:

+
    +
  • [1,2,3] and {"a":2,"b":4} both have a sum of 6.
  • +
  • [[[3]]] and {"a":{"b":4},"c":-1} both have a sum of 3.
  • +
  • {"a":[-1,1]} and [-1,{"a":1}] both have a sum of 0.
  • +
  • [] and {} both have a sum of 0.
  • +
+

You will not encounter any strings containing numbers.

+

What is the sum of all numbers in the document?

+
+

Your puzzle answer was 191164.

--- Part Two ---

Uh oh - the Accounting-Elves have realized that they double-counted everything red.

+

Ignore any object (and all of its children) which has any property with the value "red". Do this only for objects ({...}), not arrays ([...]).

+
    +
  • [1,2,3] still has a sum of 6.
  • +
  • [1,{"c":"red","b":2},3] now has a sum of 4, because the middle object is ignored.
  • +
  • {"d":"red","e":[1,2,3,4],"f":5} now has a sum of 0, because the entire structure is ignored.
  • +
  • [1,"red",5] has a sum of 6, because "red" in an array has no effect.
  • +
+
+

Your puzzle answer was 87842.

Both parts of this puzzle are complete! They provide two gold stars: **

+

At this point, you should return to your advent calendar and try another puzzle.

+

If you still want to see it, you can get your puzzle input.

+

You can also + this puzzle.

+
+ + + + + + diff --git a/advent-of-code-13.html b/advent-of-code-13.html new file mode 100644 index 0000000..b2825cb --- /dev/null +++ b/advent-of-code-13.html @@ -0,0 +1,159 @@ + + + + +Day 13 - Advent of Code + + + + + + +

Advent of Code

Neil Smith 26*
+ + + +
+

--- Day 13: Knights of the Dinner Table ---

In years past, the holiday feast with your family hasn't gone so well. Not everyone gets along! This year, you resolve, will be different. You're going to find the optimal seating arrangement and avoid all those awkward conversations.

+

You start by writing up a list of everyone invited and the amount their happiness would increase or decrease if they were to find themselves sitting next to each other person. You have a circular table that will be just big enough to fit everyone comfortably, and so each person will have exactly two neighbors.

+

For example, suppose you have only four attendees planned, and you calculate their potential happiness as follows:

+
Alice would gain 54 happiness units by sitting next to Bob.
+Alice would lose 79 happiness units by sitting next to Carol.
+Alice would lose 2 happiness units by sitting next to David.
+Bob would gain 83 happiness units by sitting next to Alice.
+Bob would lose 7 happiness units by sitting next to Carol.
+Bob would lose 63 happiness units by sitting next to David.
+Carol would lose 62 happiness units by sitting next to Alice.
+Carol would gain 60 happiness units by sitting next to Bob.
+Carol would gain 55 happiness units by sitting next to David.
+David would gain 46 happiness units by sitting next to Alice.
+David would lose 7 happiness units by sitting next to Bob.
+David would gain 41 happiness units by sitting next to Carol.
+
+

Then, if you seat Alice next to David, Alice would lose 2 happiness units (because David talks so much), but David would gain 46 happiness units (because Alice is such a good listener), for a total change of 44.

+

If you continue around the table, you could then seat Bob next to Alice (Bob gains 83, Alice gains 54). Finally, seat Carol, who sits next to Bob (Carol gains 60, Bob loses 7) and David (Carol gains 55, David gains 41). The arrangement looks like this:

+
     +41 +46
++55   David    -2
+Carol       Alice
++60    Bob    +54
+     -7  +83
+
+

After trying every other seating arrangement in this hypothetical scenario, you find that this one is the most optimal, with a total change in happiness of 330.

+

What is the total change in happiness for the optimal seating arrangement of the actual guest list?

+
+

Your puzzle answer was 709.

--- Part Two ---

In all the commotion, you realize that you forgot to seat yourself. At this point, you're pretty apathetic toward the whole thing, and your happiness wouldn't really go up or down regardless of who you sit next to. You assume everyone else would be just as ambivalent about sitting next to you, too.

+

So, add yourself to the list, and give all happiness relationships that involve you a score of 0.

+

What is the total change in happiness for the optimal seating arrangement that actually includes yourself?

+
+

Your puzzle answer was 668.

Both parts of this puzzle are complete! They provide two gold stars: **

+

At this point, you should return to your advent calendar and try another puzzle.

+

If you still want to see it, you can get your puzzle input.

+

You can also + this puzzle.

+
+ + + + + + diff --git a/advent-of-code.ipynb b/advent-of-code.ipynb new file mode 100644 index 0000000..d2e366a --- /dev/null +++ b/advent-of-code.ipynb @@ -0,0 +1,4376 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "http://adventofcode.com/" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "pi = \"()(((()))(()()()((((()(((())(()(()((((((()(()(((())))((()(((()))((())(()((()()()()(((())(((((((())))()()(()(()(())(((((()()()((())(((((()()))))()(())(((())(())((((((())())))(()())))()))))()())()())((()()((()()()()(()((((((((()()())((()()(((((()(((())((())(()))()((((()((((((((())()((()())(())((()))())((((()())(((((((((((()()(((((()(()))())(((()(()))())((()(()())())())(()(((())(())())()()(()(()((()))((()))))((((()(((()))))((((()(()(()())())()(((()((((())((((()(((()()(())()()()())((()((((((()((()()))()((()))()(()()((())))(((()(((()))((()((()(()))(((()()(()(()()()))))()()(((()(((())())))))((()(((())()(()(())((()())))((((())))(()(()(()())()((()())))(((()((()(())()()((()((())(()()((())(())()))()))((()(())()))())(((((((()(()()(()(())())))))))(()((((((())((((())((())())(()()))))()(())(()())()())((())(()))))(()))(()((()))()(()((((((()()()()((((((((()(()(())((()()(()()))(())()())()((())))()))()())(((()))(())()(())()))()((()((()(()()())(())()()()((())())))((()()(()()((()(())()()())(((()(()()))))(())))(()(()())()))()()))))))()))))((((((())))())))(()(())())(()())))))(()))()))))))()((()))))()))))(()(()((()())())(()()))))(((())()))())())())(((()(()()))(())()(())(())((((((()()))))((()(()))))))(()))())(((()()(()))()())()()()())))))))))))))(())(()))(()))((()(())(()())(())())(()())(())()()(()())))()()()))(())())()))())())(())((())))))))(())))(())))))()))))((())(()(((()))))(()))()((()(())))(()())(((((()))()())()()))))()))))()))())(()(()()()))()))))))((()))))))))))()((()))((()(())((())()()(()()))()(()))))()()(()))()))(((())))(())()((())(())(()())()())())))))))())))()((())))()))(()))()()))(((((((()))())(()()))(()()(()))()(()((()())()))))))(((()()()())))(())()))()())(()()))()()))))))))(())))()))()()))))))()))()())))()(())(())))))()(())()()(()()))))())((()))))()))))(()(((((()))))))))())))())()(())()()))))(())))())()()())()()())()(()))))()))()))))))))())))((()))()))()))())))()())()()())))())))(()((())()((()))())))))())()(())((())))))))))))())()())(())())())(()))(()))()))())(()(())())()())()()(()))))(()(())))))))(())))())(())))))))())()()(())())())))(())))))()))()(()())()(()))())())))))()()(()))()))))())))))))))()))))()))))))())()())()()))))()())))())))))))))))()()))))()()(((()))()()(())()))))((()))))(()))(())())))(())()))))))(()))()))))(())())))))()))(()())))))))))))))())))))))))()((()())(()())))))))((()))))(())(())))()(()())())))())())(()()()())))()))))))())))))())()()())))))))))))()()(()))))()())()))((()())(()))))()(()))))))))))()())())(((())(()))))())()))()))()))))))()))))))(()))))()))))()(())))(())))(()))())()()(()()))()))(()()))))))))()))(()))())(()()(()(()())()()))()))))))))(())))))((()()(()))())())))))()))())(()())()()))())))()(()()()()))((())())))())()(()()))()))))))))(()))(())))()))))(()(()())(()))))()())())()))()()))())))))))))))())()))))))()))))))))())))))()))))())(()())))(())()))())())))))()()(()()())(()())))()()))(((()))(()()()))))()))))()))))((())))()((((((()()))))))())))))))))))(((()))))))))))))(())())))))())(()))))))(()))((()))())))()(()((()))()))()))))))))))())()))()(()()))))())))())(())()(()))()))())(()))()))))(()()))()()(())))))()))(())(()(()()))(()()())))))(((()))))))()))))))))))))(())(()))))()())())()()((()()))())))))(()))))())))))))()()()))))))))())))()(((()()))(())))))(((())())))))((()))()(()))(()))))(()())))(()))())))))()))))(())(())))()((()))(())())))()()))()))))))))()))(()()()(()()()(()))())(())()())(((()))(())))))))))(((()())))()()))))))))()(())(()))()((((())(())(()())))()))(((())()()()))((()))(()))())())))())))(()))())()())())(()(())())()()()(())))())(())))(())))(())()))()))(()((()))))))))())(()))))))())(()()))()()))()(()(()())))()()(()((()((((((()))(())))()()()))())()))((()()(()))())((()(()(()))(()()))))()())))()))()())))))))()()((()())(())))()))(()))(())(()))())(()(())))()()))))))(((()(((()()))()(()(())())((()()))()))()))()))()(()()()(()))((()())()(())))()()))(((())()()())(())()((()()()()(()(())(()()))()(((((()())))((())))))(()()()))))(((()(())))()))((()((()(())()(()((())))((()())()(()))(((()())()()(()))(())(((()((()())()((())()())(((()()))((()((())(()))(()())(()()()))((()))(())(()((()()())((()))(())))(())(())(())))(()())))(((((()(()(((((()())((((()(()())(())(()()(((())((()(((()()(((()()((((((())))())(()((((((()(()))()))()()((()((()))))()(()()(()((()()))))))(((((()(((((())()()()(())())))))))()))((()()(())))(())(()()()())))))(()((((())))))))()()(((()(()(()(()(()())()()()(((((((((()()())()(()))((()()()()()(((((((()())()((())()))((((((()(()(()(()())(((()(((((((()(((())(((((((((())(())())()))((()(()))(((()()())(())(()(()()(((()(())()))())))(())((((((())(()()())()()(((()(((())(()(((())(((((((()(((((((((()))(())(()(()(()))))((()))()(())())())((()(()((()()))((()()((()(())(())(()((())(((())(((()()()((((((()()(())((((())()))))(())((()(()((())))(((((()(()()())())((())())))((())((()((()()((((((())(((()()(()())())(()(()))(()(()))())())()(((((((()(((()(())()()((())((()(()()((()(()()(((((((((((())((())((((((())((()((((()(()((((()(((((((())()((()))))())()((()((((()(()(((()((()())))(())())(((()(((())((((((()(((((((((()()(())))(()(((((()((((()())))((()((()((()(()()(((())((((((((((((()(((())(()(((((()))(()()(()()()()()()((())(((((((())(((((())))))())()(()()(()(()(((()()(((((())(()((()((()(((()()((()((((())()))()((((())(())))()())(((())(())(()()((()(((()()((((((((((()()(()())())(((((((((())((((()))()()((((())(()((((()(((())())(((((((((((()((((())))(())(()(((()(((()((())(((((()((()()(()(()()((((((()((((()((()(()((()(()((((((()))))()()(((((()((()(()(())()))(())(((((((()((((()())(()((()((()(()))())))(())((()))))(((((((()()()())(()))(()()((()())()((()((()()()(()(()()))(()())(())(((((()(((((((((((()((()(((()(((((((()()((((((()(((((()(()((()(((((())((((((()))((((())((()()((())(((())()(((((()()(((((()((()(()(((((((()(((((()((()((()((())(())((())(()))()()))(()()(()(()()(((((((()(((()(((())()(((((()((((((()())((((())()((()((()(()()())(()))((((()()((((((()((()(()(()((((()((()((())((((((()(()(())((((((()((((((((((()((())()))()(()(()(((((()()()))((())))()(()((((((((((((((()(((()((((()((())((()((()(((()()(()(((()((())(()()())))()(()(()(((((()()(()(()((((()(((((())()(()(()))(((((()()(((()()(())((((((((((((((())((())(((((((((((())()()()(())()(()(()(((((((((())(((()))(()()())(()((((()(())(((((()())(())((((((((())()((((()((((((())(()((()(())(((()((((()))(((((((((()()))((((()(())()()()(())(()((())((()()))()(((())(((((())((((((()()))(((((((((()((((((())))(((((((()((()(()(())))())(()(()))()(((((()())(()))()(()(())(((()))))())()())))(((((()))())()((()(()))))((()()()((((((()))()()((((((((())((()(()(((()(()((())((()())(()((((())(()(((()()()(()(()()))())())((((((((((())())((()))()((())(())(())))())()(()()(())))())(()))(((()(()()(((()(((())))()(((()(())()((((((())()))()))()((((((()(()(((((()())))()))))())()()(((()(((((())((()()(()((()((()(()(()(())))(()()()()((()(())(((()((()))((((()))())(())))())(()))()()()())()))(((()()())()((())))(())(()()()()(()())((()(()()((((())))((()((()(())((()(()((())()(()()(((()())()()())((()))((())(((()()(())))()()))(((()((())()(((((()())(())((())()())())((((((()(()(((((()))(()(\"" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "138" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len([c for c in pi if c == '(']) - len([c for c in pi if c == ')'])" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " ...]" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "deltas = [1 if c == '(' else -1 for c in pi]\n", + "deltas" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "import itertools" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "1771" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(list(itertools.takewhile(lambda f: f >= -1, itertools.accumulate(deltas))))" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "pi2 = \"\"\"3x11x24\n", + "13x5x19\n", + "1x9x27\n", + "24x8x21\n", + "6x8x17\n", + "19x18x22\n", + "10x9x12\n", + "12x2x5\n", + "26x6x11\n", + "9x23x15\n", + "12x8x17\n", + "13x29x10\n", + "28x18x6\n", + "22x28x26\n", + "1x5x11\n", + "29x26x12\n", + "8x28x29\n", + "27x4x21\n", + "12x7x16\n", + "7x4x23\n", + "15x24x8\n", + "15x14x2\n", + "11x6x29\n", + "28x19x9\n", + "10x3x1\n", + "5x20x13\n", + "10x25x1\n", + "22x17x7\n", + "16x29x3\n", + "18x22x8\n", + "18x11x19\n", + "21x24x20\n", + "4x7x17\n", + "22x27x12\n", + "1x26x6\n", + "5x27x24\n", + "29x21x3\n", + "25x30x2\n", + "21x26x2\n", + "10x24x27\n", + "10x16x28\n", + "18x16x23\n", + "6x5x26\n", + "19x12x20\n", + "6x24x25\n", + "11x20x7\n", + "4x8x5\n", + "2x13x11\n", + "11x17x1\n", + "13x24x6\n", + "22x29x16\n", + "4x24x20\n", + "10x25x10\n", + "12x29x23\n", + "23x27x12\n", + "11x21x9\n", + "13x2x6\n", + "15x30x2\n", + "8x26x24\n", + "24x7x30\n", + "22x22x8\n", + "29x27x8\n", + "28x23x27\n", + "13x16x14\n", + "9x28x20\n", + "21x4x30\n", + "21x20x20\n", + "11x17x30\n", + "9x14x22\n", + "20x2x6\n", + "10x11x14\n", + "1x8x23\n", + "23x19x19\n", + "26x10x13\n", + "21x12x12\n", + "25x7x24\n", + "1x28x17\n", + "20x23x9\n", + "2x24x27\n", + "20x24x29\n", + "1x3x10\n", + "5x20x14\n", + "25x21x3\n", + "15x5x22\n", + "14x17x19\n", + "27x3x18\n", + "29x23x19\n", + "14x21x19\n", + "20x8x3\n", + "22x27x12\n", + "24x15x18\n", + "9x10x19\n", + "29x25x28\n", + "14x22x6\n", + "4x19x28\n", + "4x24x14\n", + "17x19x17\n", + "7x19x29\n", + "28x8x26\n", + "7x20x16\n", + "11x26x29\n", + "2x18x3\n", + "12x7x18\n", + "11x15x21\n", + "24x7x26\n", + "2x22x23\n", + "2x30x5\n", + "1x19x8\n", + "15x29x10\n", + "15x26x22\n", + "20x16x14\n", + "25x29x22\n", + "3x13x19\n", + "1x12x30\n", + "3x15x27\n", + "19x9x11\n", + "30x8x21\n", + "26x12x20\n", + "11x17x19\n", + "17x25x1\n", + "19x24x12\n", + "30x6x20\n", + "11x19x18\n", + "18x15x29\n", + "18x8x9\n", + "25x15x5\n", + "15x6x26\n", + "13x27x19\n", + "23x24x12\n", + "3x15x28\n", + "17x10x10\n", + "15x4x7\n", + "15x27x7\n", + "21x8x11\n", + "9x18x2\n", + "7x20x20\n", + "17x23x12\n", + "2x19x1\n", + "7x26x26\n", + "13x23x8\n", + "10x3x12\n", + "11x1x9\n", + "1x11x19\n", + "25x14x26\n", + "16x10x15\n", + "7x6x11\n", + "8x1x27\n", + "20x28x17\n", + "3x25x9\n", + "30x7x5\n", + "17x17x4\n", + "23x25x27\n", + "23x8x5\n", + "13x11x1\n", + "15x10x21\n", + "22x16x1\n", + "12x15x28\n", + "27x18x26\n", + "25x18x5\n", + "21x3x27\n", + "15x25x5\n", + "29x27x19\n", + "11x10x12\n", + "22x16x21\n", + "11x8x18\n", + "6x10x23\n", + "21x21x2\n", + "13x27x28\n", + "2x5x20\n", + "23x16x20\n", + "1x21x7\n", + "22x2x13\n", + "11x10x4\n", + "7x3x4\n", + "19x2x5\n", + "21x11x1\n", + "7x27x26\n", + "12x4x23\n", + "12x3x15\n", + "25x7x4\n", + "20x7x15\n", + "16x5x11\n", + "1x18x26\n", + "11x27x10\n", + "17x6x24\n", + "19x13x16\n", + "6x3x11\n", + "4x19x18\n", + "16x15x15\n", + "1x11x17\n", + "19x11x29\n", + "18x19x1\n", + "1x25x7\n", + "8x22x14\n", + "15x6x19\n", + "5x30x18\n", + "30x24x22\n", + "11x16x2\n", + "21x29x19\n", + "20x29x11\n", + "27x1x18\n", + "20x5x30\n", + "12x4x28\n", + "3x9x30\n", + "26x20x15\n", + "18x25x18\n", + "20x28x28\n", + "21x5x3\n", + "20x21x25\n", + "19x27x22\n", + "8x27x9\n", + "1x5x15\n", + "30x6x19\n", + "16x5x15\n", + "18x30x21\n", + "4x15x8\n", + "9x3x28\n", + "18x15x27\n", + "25x11x6\n", + "17x22x15\n", + "18x12x18\n", + "14x30x30\n", + "1x7x23\n", + "27x21x12\n", + "15x7x18\n", + "16x17x24\n", + "11x12x19\n", + "18x15x21\n", + "6x18x15\n", + "2x21x4\n", + "12x9x14\n", + "19x7x25\n", + "22x3x1\n", + "29x19x7\n", + "30x25x7\n", + "6x27x27\n", + "5x13x9\n", + "21x4x18\n", + "13x1x16\n", + "11x21x25\n", + "27x20x27\n", + "14x25x9\n", + "23x11x15\n", + "22x10x26\n", + "15x16x4\n", + "14x16x21\n", + "1x1x24\n", + "17x27x3\n", + "25x28x16\n", + "12x2x29\n", + "9x19x28\n", + "12x7x17\n", + "6x9x19\n", + "15x14x24\n", + "25x21x23\n", + "26x27x25\n", + "7x18x13\n", + "15x10x6\n", + "22x28x2\n", + "15x2x14\n", + "3x24x18\n", + "30x22x7\n", + "18x27x17\n", + "29x18x7\n", + "20x2x4\n", + "4x20x26\n", + "23x30x15\n", + "5x7x3\n", + "4x24x12\n", + "24x30x20\n", + "26x18x17\n", + "6x28x3\n", + "29x19x29\n", + "14x10x4\n", + "15x5x23\n", + "12x25x4\n", + "7x15x19\n", + "26x21x19\n", + "18x2x23\n", + "19x20x3\n", + "3x13x9\n", + "29x21x24\n", + "26x13x29\n", + "30x27x4\n", + "20x10x29\n", + "21x18x8\n", + "7x26x10\n", + "29x16x21\n", + "22x5x11\n", + "17x15x2\n", + "7x29x5\n", + "6x18x15\n", + "23x6x14\n", + "10x30x14\n", + "26x6x16\n", + "24x13x25\n", + "17x29x20\n", + "4x27x19\n", + "28x12x11\n", + "23x20x3\n", + "22x6x20\n", + "29x9x19\n", + "10x16x22\n", + "30x26x4\n", + "29x26x11\n", + "2x11x15\n", + "1x3x30\n", + "30x30x29\n", + "9x1x3\n", + "30x13x16\n", + "20x4x5\n", + "23x28x11\n", + "24x27x1\n", + "4x25x10\n", + "9x3x6\n", + "14x4x15\n", + "4x5x25\n", + "27x14x13\n", + "20x30x3\n", + "28x15x25\n", + "5x19x2\n", + "10x24x29\n", + "29x30x18\n", + "30x1x25\n", + "7x7x15\n", + "1x13x16\n", + "23x18x4\n", + "1x28x8\n", + "24x11x8\n", + "22x26x19\n", + "30x30x14\n", + "2x4x13\n", + "27x20x26\n", + "16x20x17\n", + "11x12x13\n", + "28x2x17\n", + "15x26x13\n", + "29x15x25\n", + "30x27x9\n", + "2x6x25\n", + "10x26x19\n", + "16x8x23\n", + "12x17x18\n", + "26x14x22\n", + "13x17x4\n", + "27x27x29\n", + "17x13x22\n", + "9x8x3\n", + "25x15x20\n", + "14x13x16\n", + "8x7x13\n", + "12x4x21\n", + "27x16x15\n", + "6x14x5\n", + "28x29x17\n", + "23x17x25\n", + "10x27x28\n", + "1x28x21\n", + "18x2x30\n", + "25x30x16\n", + "25x21x7\n", + "2x3x4\n", + "9x6x13\n", + "19x6x10\n", + "28x17x8\n", + "13x24x28\n", + "24x12x7\n", + "5x19x5\n", + "18x10x27\n", + "16x1x6\n", + "12x14x30\n", + "1x2x28\n", + "23x21x2\n", + "13x3x23\n", + "9x22x10\n", + "10x17x2\n", + "24x20x11\n", + "30x6x14\n", + "28x1x16\n", + "24x20x1\n", + "28x7x7\n", + "1x24x21\n", + "14x9x7\n", + "22x8x15\n", + "20x1x21\n", + "6x3x7\n", + "7x26x14\n", + "5x7x28\n", + "5x4x4\n", + "15x7x28\n", + "30x16x23\n", + "7x26x2\n", + "1x2x30\n", + "24x28x20\n", + "5x17x28\n", + "4x15x20\n", + "15x26x2\n", + "1x3x23\n", + "22x30x24\n", + "9x20x16\n", + "7x15x2\n", + "6x21x18\n", + "21x21x29\n", + "29x10x10\n", + "4x3x23\n", + "23x2x18\n", + "29x24x14\n", + "29x29x16\n", + "22x28x24\n", + "21x18x24\n", + "16x21x6\n", + "3x9x22\n", + "9x18x4\n", + "22x9x9\n", + "12x9x13\n", + "18x21x14\n", + "7x8x29\n", + "28x28x14\n", + "1x6x24\n", + "11x11x3\n", + "8x28x6\n", + "11x16x10\n", + "9x16x16\n", + "6x6x19\n", + "21x5x12\n", + "15x17x12\n", + "3x6x29\n", + "19x1x26\n", + "10x30x25\n", + "24x26x21\n", + "1x10x18\n", + "6x1x16\n", + "4x17x27\n", + "17x11x27\n", + "15x15x21\n", + "14x23x1\n", + "8x9x30\n", + "22x22x25\n", + "20x27x22\n", + "12x7x9\n", + "9x26x19\n", + "26x25x12\n", + "8x8x16\n", + "28x15x10\n", + "29x18x2\n", + "25x22x6\n", + "4x6x15\n", + "12x18x4\n", + "10x3x20\n", + "17x28x17\n", + "14x25x13\n", + "14x10x3\n", + "14x5x10\n", + "7x7x22\n", + "21x2x14\n", + "1x21x5\n", + "27x29x1\n", + "6x20x4\n", + "7x19x23\n", + "28x19x27\n", + "3x9x18\n", + "13x17x17\n", + "18x8x15\n", + "26x23x17\n", + "10x10x13\n", + "11x5x21\n", + "25x15x29\n", + "6x23x24\n", + "10x7x2\n", + "19x10x30\n", + "4x3x23\n", + "22x12x6\n", + "11x17x16\n", + "6x8x12\n", + "18x20x11\n", + "6x2x2\n", + "17x4x11\n", + "20x23x22\n", + "29x23x24\n", + "25x11x21\n", + "22x11x15\n", + "29x3x9\n", + "13x30x5\n", + "17x10x12\n", + "10x30x8\n", + "21x16x17\n", + "1x5x26\n", + "22x15x16\n", + "27x7x11\n", + "16x8x18\n", + "29x9x7\n", + "25x4x17\n", + "10x21x25\n", + "2x19x21\n", + "29x11x16\n", + "18x26x21\n", + "2x8x20\n", + "17x29x27\n", + "25x27x4\n", + "14x3x14\n", + "25x29x29\n", + "26x18x11\n", + "8x24x28\n", + "7x30x24\n", + "12x30x22\n", + "29x20x6\n", + "3x17x1\n", + "6x15x14\n", + "6x22x20\n", + "13x26x26\n", + "12x2x1\n", + "7x14x12\n", + "15x16x11\n", + "3x21x4\n", + "30x17x29\n", + "9x18x27\n", + "11x28x16\n", + "22x3x25\n", + "18x15x15\n", + "2x30x12\n", + "3x27x22\n", + "10x8x8\n", + "26x16x14\n", + "15x2x29\n", + "12x10x7\n", + "21x20x15\n", + "2x15x25\n", + "4x14x13\n", + "3x15x13\n", + "29x8x3\n", + "7x7x28\n", + "15x10x24\n", + "23x15x5\n", + "5x7x14\n", + "24x1x22\n", + "1x11x13\n", + "26x4x19\n", + "19x16x26\n", + "5x25x5\n", + "17x25x14\n", + "23x7x14\n", + "24x6x17\n", + "5x13x12\n", + "20x20x5\n", + "22x29x17\n", + "11x17x29\n", + "25x6x4\n", + "29x8x16\n", + "28x22x24\n", + "24x23x17\n", + "16x17x4\n", + "17x8x25\n", + "22x9x13\n", + "24x4x8\n", + "18x10x20\n", + "21x23x21\n", + "13x14x12\n", + "23x26x4\n", + "4x10x29\n", + "2x18x18\n", + "19x5x21\n", + "2x27x23\n", + "6x29x30\n", + "21x9x20\n", + "6x5x16\n", + "25x10x27\n", + "5x29x21\n", + "24x14x19\n", + "19x11x8\n", + "2x28x6\n", + "19x25x6\n", + "27x1x11\n", + "6x8x29\n", + "18x25x30\n", + "4x27x26\n", + "8x12x1\n", + "7x17x25\n", + "7x14x27\n", + "12x9x5\n", + "14x29x13\n", + "18x17x5\n", + "23x1x3\n", + "28x5x13\n", + "3x2x26\n", + "3x7x11\n", + "1x8x7\n", + "12x5x4\n", + "2x30x21\n", + "16x30x11\n", + "3x26x4\n", + "16x9x4\n", + "11x9x22\n", + "23x5x6\n", + "13x20x3\n", + "4x3x2\n", + "14x10x29\n", + "11x8x12\n", + "26x15x16\n", + "7x17x29\n", + "18x19x18\n", + "8x28x4\n", + "22x6x13\n", + "9x23x7\n", + "11x23x20\n", + "13x11x26\n", + "15x30x13\n", + "1x5x8\n", + "5x10x24\n", + "22x25x17\n", + "27x20x25\n", + "30x10x21\n", + "16x28x24\n", + "20x12x8\n", + "17x25x1\n", + "30x14x9\n", + "14x18x6\n", + "8x28x29\n", + "12x18x29\n", + "9x7x18\n", + "6x12x25\n", + "20x13x24\n", + "22x3x12\n", + "5x23x22\n", + "8x10x17\n", + "7x23x5\n", + "10x26x27\n", + "14x26x19\n", + "10x18x24\n", + "8x4x4\n", + "16x15x11\n", + "3x14x9\n", + "18x5x30\n", + "29x12x26\n", + "16x13x12\n", + "15x10x7\n", + "18x5x26\n", + "14x1x6\n", + "10x8x29\n", + "3x4x9\n", + "19x4x23\n", + "28x17x23\n", + "30x7x17\n", + "19x5x9\n", + "26x29x28\n", + "22x13x17\n", + "28x2x1\n", + "20x30x8\n", + "15x13x21\n", + "25x23x19\n", + "27x23x1\n", + "4x6x23\n", + "29x29x24\n", + "5x18x7\n", + "4x6x30\n", + "17x15x2\n", + "27x4x2\n", + "25x24x14\n", + "28x8x30\n", + "24x29x5\n", + "14x30x14\n", + "10x18x19\n", + "15x26x22\n", + "24x19x21\n", + "29x23x27\n", + "21x10x16\n", + "7x4x29\n", + "14x21x3\n", + "21x4x28\n", + "17x16x15\n", + "24x7x13\n", + "21x24x15\n", + "25x11x16\n", + "10x26x13\n", + "23x20x14\n", + "20x29x27\n", + "14x24x14\n", + "14x23x12\n", + "18x6x5\n", + "3x18x9\n", + "8x18x19\n", + "20x26x15\n", + "16x14x13\n", + "30x16x3\n", + "17x13x4\n", + "15x19x30\n", + "20x3x8\n", + "13x4x5\n", + "12x10x15\n", + "8x23x26\n", + "16x8x15\n", + "22x8x11\n", + "12x11x18\n", + "28x3x30\n", + "15x8x4\n", + "13x22x13\n", + "21x26x21\n", + "29x1x15\n", + "28x9x5\n", + "27x3x26\n", + "22x19x30\n", + "4x11x22\n", + "21x27x20\n", + "22x26x7\n", + "19x28x20\n", + "24x23x16\n", + "26x12x9\n", + "13x22x9\n", + "5x6x23\n", + "20x7x2\n", + "18x26x30\n", + "3x6x28\n", + "24x18x13\n", + "28x19x16\n", + "25x21x25\n", + "25x19x23\n", + "22x29x10\n", + "29x19x30\n", + "4x7x27\n", + "5x12x28\n", + "8x26x6\n", + "14x14x25\n", + "17x17x2\n", + "5x27x11\n", + "8x2x2\n", + "3x20x24\n", + "26x10x9\n", + "22x28x27\n", + "18x15x20\n", + "12x11x1\n", + "5x14x30\n", + "7x3x16\n", + "2x16x16\n", + "18x20x15\n", + "13x14x29\n", + "1x17x12\n", + "13x5x23\n", + "19x4x10\n", + "25x19x11\n", + "15x17x14\n", + "1x28x27\n", + "11x9x28\n", + "9x10x18\n", + "30x11x22\n", + "21x21x20\n", + "2x1x5\n", + "2x25x1\n", + "7x3x4\n", + "22x15x29\n", + "21x28x15\n", + "12x12x4\n", + "21x30x6\n", + "15x10x7\n", + "10x14x6\n", + "21x26x18\n", + "14x25x6\n", + "9x7x11\n", + "22x3x1\n", + "1x16x27\n", + "1x14x23\n", + "2x13x8\n", + "14x19x11\n", + "21x26x1\n", + "4x28x13\n", + "12x16x20\n", + "21x13x9\n", + "3x4x13\n", + "14x9x8\n", + "21x21x12\n", + "27x10x17\n", + "6x20x6\n", + "28x23x23\n", + "2x28x12\n", + "8x10x10\n", + "3x9x2\n", + "20x3x29\n", + "19x4x16\n", + "29x24x9\n", + "26x20x8\n", + "15x28x26\n", + "18x17x10\n", + "7x22x10\n", + "20x15x9\n", + "6x10x8\n", + "7x26x21\n", + "8x8x16\n", + "15x6x29\n", + "22x30x11\n", + "18x25x8\n", + "6x21x20\n", + "7x23x25\n", + "8x25x26\n", + "11x25x27\n", + "22x18x23\n", + "3x2x14\n", + "16x16x1\n", + "15x13x11\n", + "3x9x25\n", + "29x25x24\n", + "9x15x1\n", + "12x4x1\n", + "23x30x20\n", + "3x1x23\n", + "6x10x29\n", + "28x13x24\n", + "4x19x17\n", + "6x6x25\n", + "27x29x17\n", + "12x13x2\n", + "10x7x13\n", + "14x15x8\n", + "22x2x3\n", + "27x17x19\n", + "23x10x16\n", + "5x9x25\n", + "9x25x14\n", + "11x18x6\n", + "18x10x12\n", + "9x4x15\n", + "7x16x14\n", + "17x24x10\n", + "11x4x6\n", + "12x9x17\n", + "22x18x12\n", + "6x24x24\n", + "6x22x23\n", + "5x17x30\n", + "6x9x5\n", + "17x20x10\n", + "6x8x12\n", + "14x17x13\n", + "29x10x17\n", + "22x4x5\n", + "10x19x30\n", + "22x29x11\n", + "10x12x29\n", + "21x22x26\n", + "16x6x25\n", + "1x26x24\n", + "30x17x16\n", + "27x28x5\n", + "30x13x22\n", + "7x26x12\n", + "11x24x30\n", + "1x17x25\n", + "22x1x3\n", + "29x24x6\n", + "4x8x24\n", + "13x9x20\n", + "8x12x9\n", + "21x25x4\n", + "23x23x28\n", + "5x2x19\n", + "29x3x15\n", + "22x1x14\n", + "3x23x30\n", + "8x25x3\n", + "15x8x14\n", + "30x14x6\n", + "23x27x24\n", + "19x1x2\n", + "10x9x13\n", + "13x8x7\n", + "8x13x22\n", + "5x15x20\n", + "17x14x8\n", + "5x11x20\n", + "5x10x27\n", + "24x17x19\n", + "21x2x3\n", + "15x30x26\n", + "21x19x15\n", + "2x7x23\n", + "13x17x25\n", + "30x15x19\n", + "26x4x10\n", + "2x25x8\n", + "9x9x10\n", + "2x25x8\n", + "19x21x30\n", + "17x26x12\n", + "7x5x10\n", + "2x22x14\n", + "10x17x30\n", + "1x8x5\n", + "23x2x25\n", + "22x29x8\n", + "13x26x1\n", + "26x3x30\n", + "25x17x8\n", + "25x18x26\n", + "26x19x15\n", + "8x28x10\n", + "12x16x29\n", + "30x6x29\n", + "28x19x4\n", + "27x26x18\n", + "15x23x17\n", + "5x21x30\n", + "8x11x13\n", + "2x26x7\n", + "19x9x24\n", + "3x22x23\n", + "6x7x18\n", + "4x26x30\n", + "13x25x20\n", + "17x3x15\n", + "8x20x18\n", + "23x18x23\n", + "28x23x9\n", + "16x3x4\n", + "1x29x14\n", + "20x26x22\n", + "3x2x22\n", + "23x8x17\n", + "19x5x17\n", + "21x18x20\n", + "17x21x8\n", + "30x28x1\n", + "29x19x23\n", + "12x12x11\n", + "24x18x7\n", + "21x18x14\n", + "14x26x25\n", + "9x11x3\n", + "10x7x15\n", + "27x6x28\n", + "14x26x4\n", + "28x4x1\n", + "22x25x29\n", + "6x26x6\n", + "1x3x13\n", + "26x22x12\n", + "6x21x26\n", + "23x4x27\n", + "26x13x24\n", + "5x24x28\n", + "22x16x7\n", + "3x27x24\n", + "19x28x2\n", + "11x13x9\n", + "29x16x22\n", + "30x10x24\n", + "14x14x22\n", + "22x23x16\n", + "14x8x3\n", + "20x5x14\n", + "28x6x13\n", + "3x15x25\n", + "4x12x22\n", + "15x12x25\n", + "10x11x24\n", + "7x7x6\n", + "8x11x9\n", + "21x10x29\n", + "23x28x30\n", + "8x29x26\n", + "16x27x11\n", + "1x10x2\n", + "24x20x16\n", + "7x12x28\n", + "28x8x20\n", + "14x10x30\n", + "1x19x6\n", + "4x12x20\n", + "18x2x7\n", + "24x18x17\n", + "16x11x10\n", + "1x12x22\n", + "30x16x28\n", + "18x12x11\n", + "28x9x8\n", + "23x6x17\n", + "10x3x11\n", + "5x12x8\n", + "22x2x23\n", + "9x19x14\n", + "15x28x13\n", + "27x20x23\n", + "19x16x12\n", + "19x30x15\n", + "8x17x4\n", + "10x22x18\n", + "13x22x4\n", + "3x12x19\n", + "22x16x23\n", + "11x8x19\n", + "8x11x6\n", + "7x14x7\n", + "29x17x29\n", + "21x8x12\n", + "21x9x11\n", + "20x1x27\n", + "1x22x11\n", + "5x28x4\n", + "26x7x26\n", + "30x12x18\n", + "29x11x20\n", + "3x12x15\n", + "24x25x17\n", + "14x6x11\"\"\"" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['24x25x17', '14x6x11']" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pi2.splitlines()[-2:]" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "1588178" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "total = 0\n", + "for package in pi2.splitlines():\n", + " dims = [int(d) for d in package.split('x')]\n", + " areas = [dims[0]*dims[1], dims[0]*dims[2], dims[1]*dims[2]]\n", + " slack = min(areas)\n", + " paper = slack + sum(areas)*2\n", + " total += paper\n", + "total" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "3783758" + ] + }, + "execution_count": 33, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "total = 0\n", + "for package in pi2.splitlines():\n", + " dims = [int(d) for d in package.split('x')]\n", + " perims = [p*2 for p in [dims[0]+dims[1], dims[0]+dims[2], dims[1]+dims[2]]]\n", + " length = min(perims)\n", + " vol = dims[0] * dims[1] * dims[2]\n", + " ribbon = length + vol\n", + " total += ribbon\n", + "total" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "pi3 = \"\"\"^><^>>>^<^v<<^<><^<^v>^vv<>v>>^^^v<<<^>^<^v<^>^v><<<^>><>v>v^<<^>^<<^^^>v>>v^^>^>vv>>^>>v^>^v>^<^^v>^>^^v^^>v^^v><^><^<<>v^<^<^vv^>>>v^v^>^<>^v<^^vv^>^<>^^<vv<>^>v<^>^v>v^>^v<>^><>>v^v<><>v^v>>>>v^^>^><^^<^>^v^v<>v<<<^<v^^^<^^^>v<^v>>>>>v<^^^^>v<^<>>>>>>v^vvvv^^^v<^v^>v><^>^v<<>>vv^>v>v^^>vv^<^vvv<>><>><><^^^^<^^^<^v>>v>^v^^^>v^^^v>>^v^^<^>>^>^<>>^^<>>^vv>v^<^>>>><><^^v<><<<<^^<>>^<>vv^<^>v^^><^v>^^>v<>^v^<>^vv^>vvv>v>^>^>>^>><>>>^^^^v^<>v^^>^<>v<^^v><^v><>^^^^^v^v>>^^v><<><^^^^><^>v>><<<^v>v^^>^v^<^^v>v<^<<>>^v<<>v<^v^>v^>^v<<v>v>>v>v^^v>^v^>>>><>^>v>^v^>>>>v^<<<>vvv>><^^>^<><^^<^v^v^<^^>^<^v^<<<^^v^v>>><>^^>vv<<^v^<<<<^^>>>v>v<<<>^^>>>v>^>v>vv<<>^<^>^^<^>^v^<>v^><^^^>vv>><^v<^<<<><<^^<><>v>^>^<>>^^v>vv^<^^v>><^vv^<<<>vv^v<^<>v^^>><>^<^v<<<^<<^>>>^^<^^v>v^vvvv>v<>><^>^<<<v^^^v<>v>^^<v>>v>>v^>^<>v><>>>v^>^v<^<><<^>^^^>^><>^><^<>vv<>>v^v>^>^>^<^><>v<><>>>^^^<^v>>^<>>>vv^>vvvv>>><^>v<>^^^>v>>v^v^>^^<<^>^>>v<<><>v^^>v^><<^v^>^^<v><<<^v^<>^<>^>>^<^^<>^v<>v^>>><>^><>>vv>v^<^^^>v>^^>^v<><>>><>><^<>>v>v^^>^^<^^>^>>v>vv^^v<^<^v>><<^>^v>^^^<<>v^<^^v<<<>^^vv<^>vv>^>^<><<>vv<^>v^vv>^^^v><<^vv>^v<>vv^^<^<>^^v^<^vvv>v^^<>^^>^^>^<><<^v>^><^^vvvv<><>^v<>^><>v>><>vv^<<><<>><>v<^>^v>>^^v><<<>>^<^v^^^<^<><><^><<<<^^<>><><>>v><<vvvv^^vv><<^v^vvv><>v><>v<<<^><^^>v^>^^^v^v>><<>^v<>v^v<<<<^^^v^v<<>>>v>>vv>^^<><^v<>>v^>>>>>^>v^v^<^v^v^vvv>vvv^<vv>>v^^vv<^v>>>>vv<>v<>^^vv^v^>>vvv<<v>v>^><<<^>v^>^v^^^><<><<<^^<^^<>^^v<^v>^v<^>^>><>^v^v<<^>^>v><^>^vv^^^v^v^>^<<>>>>>v^<>^>v^vv^><<>>^^<>v^>^vvv^>v^v><>^><<>v>v<^<^><^^vv<<><>>v>>v>>^v<<>^vv<>^vv>v>v>^>^>>><><<>v^<<^v^^<<<>>vv<^<<>v<^^^<<^v^>^v>^^^v^v>>>v>v^v>^>^vv<^^<^<<v^<><<^vvv^^><>vv^v>v>^><<^^^^vvv^><^v<^>^<>>^>>vv^<>>^v>^>v>^<^<^^^<>>>>>>v>^<>^^v^><>><^v^^><>v^v<^<<<<^>^^>vv>><^v^vvv>v^^><^^<^<>>^^v^vv<>v<^<<v>v<>^v^><>v<^v>><<^<^v^>><^<^><>v>>^vv<^v>^>v<^>>^>>v^>^v<^v^v><<><>^><<<><>^<>^^^^v>^>^vvvvv>v>>v><<<^><<^v><^v>>>>^v<^v<<>>^>^<v>><<^>^>^v><><>^><v^><<^v^<^^><^^v^<<^v^^>>^v^<^>v^^<<^^^<><>^>v^v>v^>^v^vv>^^>>>>^^<^>>>^^v<^^v><<<>^>^^>^>^v<<<<>>^<<>>>v>^^<^v<>v<>v^>v^><^<^^>^^vv><>v>^<<<^><^^<^<^^v<^>v^v^^^><^>v^v>>^^v^>>>>><<>^>v>v<>>>v>^^^^>>v^<<^>>><^v^<<>>v><>^v^^><<>>^>^>vv<^<>^vvv^vv^v>^^<<<<<>^v^>^<>v^^<>v^v^<>vv^<^vv>>><<>v^^^>^>^^>>>vvv>^>v>v>>>^>vv^><>^><>v>^^^><><<<>>v^v<^<>^^<>^^<<><>^v<><>>>^vv<^<<^<^v>v<<<<<^^v<^v<><^>v>^v>>^v^><^^^^v<><><>vv^<>vv<^v<^^><^^v^v^<^^<<>v<>v^v<^>vvv><<^v>>v><>>>v<^>>v>^<>><>^v<^^>^<^v<^<<^^v<>>^>^>^v^^v^v>v>v<>v^>v^^>^^>><<>><<^^>><^v<<><<>>>>>>^^^^^<<>^<<^><<^^vvv<<>vv><<>v>v^v>>>>>^<>><^^^><<<<>>v<^>>>^^vvv>v<>>>>v>>^v^vvv<<>vvv<<^^^<>vv^^v<<>^^^>>^<^v^<^^>v^>>^<<^v<v^>>^>v^><^><>^>>>vv>><^^^>vv<<^^vv><^<>^>^^<^<>>^vv^>>^v><>v^>>><<<^^<^>^>v<^>^<^^<>>><^^<>^v^<<>vvv>v^v<<^^^><<^vv^v>v>v<<^v^<<<>^><>v>^vv^v<>vv^>^^<^>^>v^^v><>>^v<^<><><^vv<><<>v^^>^^<><<>^<^<<<>v>><^<<>^>^v^v<^>>^v<^>v<<>^^^<^v>>>^vvvv<vvvv>v<>v^<><>vvv<>^<<>^>>>>v^<^<><^v>v^>>v><>^><^<<>^>^v^>^v>^<>v^<^^>v>^>>>v^v>>>^<>^<>>>>>v>>vv^v<><<<><><<>>vv<^^v<<>v^v<^v<>>^v>>vvv^^v>>v>^>^>v><^>^^<<>^v<^<<<<^>v<^>>v^<^v>^v<<>^>^vvv<^^vv>^vv>vv<>>v>v>v^<<<<<^^v^>v>^<<>v^<<>>^<^>^^<>>>>^<^v<>v^^>^<^^v<^><>>>^v^vv<^v<^><><>><^^>^<^v^<^<>v<<<^v>v^^^<>v^^v^>><>^^<<^^v^<>^<^vv>>><^v>vv<^v<<>v>v^v>^v<^<>v^vvv>^vv<<<<^>>^^>><^v><<^>v^^<<<<<>^v<<^^>v<<<<^>^>^>>^>>>v^<>^^v>>>^vvv<^v<>>>vv>^^><^v>vv^>>v>v^<>^^>^<<^>^^^>>^vv>^^>vvvv<>>^^^^>>>v>v^^>vv>vv^<<>^><^><<>>^>^><^v^>v^<>^>v^^v^>^^>v<<<<^<<^>>v>v^^^<<>>^^v>v<<<<^^^v>^vv^>><>^v<>>>v>vvv^v^^v^>>vv>^>><>^v><^v^><^^>vv>^<^<^>>v>><><>^>^>v>vv>vv>^^>v>v^>^>^v>^^v>^<^v<>>vvv^^>^>vvv^^v<^<^>vv^^<^^^>v>vv<v<^>^v^<^>v<^>^<>vv^><>>^>>^<^><<>^<^>v>v><>>>^<<^><<^v<>>vv<^>>v>v>>>>^^>v<^v^>><<^<>>v><^><<^>^<<>>^^<><^^v>^^>vv>^v>^^v^<^<<>>v^^^<^><^<<><><<>^v>vvv^vvv^^>>^<^><>^<<<<^^<>>>v^<<^^v>><><v>^vv>vv^><>^><<><^^>^>^<><>><^^<><>^>><^v<<<<>>^v>^^vv^v^<><<vv>>v>>^v^<>>vv^<^>^<<>v<<<^vv<^vv^vv<^v^^^v>>v<^^<^^vvv<^^v<>>>^>v^>^^><>vv>v>v<<<^^v<^vv^v>^^^>>>^^<>^^<^vvv>><><<><^><<>^>^^vv>vv^^<^^<<><><v><<>v>vvv<^^^^<^>>><<<^^^<^>vv^^v>>v<vvv^^v^^<^v<^<>^<^v>>^><><>v>>>^^>>v^>><>v<><>>><>>>>><<^vvv<<><><<>^><><<^^v><<^>v>^>^v>v>>^^<><^>vv<^<^v>v<><^<<^><>^^^^^v>><>^>^vvv>v^vv^v^>v><>v^><>v>^^^^><^v^^^>^^><<^^>v>v<^v^^vv^<<<<^>v>v^v><>^><><>^v^<>^v>^v>v^<><^>>v<<^><^vv^<><^<>><>><<^^^^>v<^<^vv<><^vv><<^<v^>>^v>^>v^^v>vvv<v<>^>>vv^>>><>^v^^<^>v<<^<^^v^^v^<vv^><^v<^>>>vv^^^^v>^><^^^<><<^^>v<><><><>vv^><<^>^><^v<^<^v^v<<<<<<><vv>v<^><<><><<>>v>><^>^v>^v^<>v^^^><^^<<<^vv^vv>^v^vvv^^>v^><^<^<^<>^vv^^^>vv^v>>><<<^<>>v>v<^^<>>><><^v^^<<><<<>^<^^v^>v><^<^>^>>^<>^v><>>^vv^>^^<<<^v<>>^v<>vvv<<^^<<>>>>^^<><>^><>^vv^v<^>^v<>v^vv<><^vvv<><<^>>^^><><>^<>^>v^^v^><>>v>><^v>^v<<<>vvv^<^^v^<>^>>v<>^^><>>^><^^vv>><<>><^><>>^vv>vv^v^^v<<^^v^^vv<<^<<><>^<><^<^<>>^vvv>>^<^vv>^vv^>v>^<><^><^<>v^v^^<^<>^^v>>><^v<>v^v<<^>v><>^^<v^>>v>^<>^>^>^<^>v><<><><><<<>^>><^>>>^v<<<^<<>^><<^>>>>>v<^>v>>v^^>v^^><>v^v^vvvvv>>><<>^<v>^>^vv^^<^>>v>vv^v<^<>^v^<^<<><<<^vvv^>^^<<>>>vv<<^<><^v<^<><<^^>vv^v>v^^^>>>>^>vv<v>>^^v^^><>v<<^><^>^>v^v>><^v^>v<<^<^<^<^<>>v^^>><<<>vv<^^>^vv<<<^^v^^>v<<><^<>^^>^v<>v>><^^^vv^>^><>v^^>^v>^<<^v>^>>>>><^^^<>v>v^^<^v^>>v^<^>v^v>>>>^>>vv<>^<^v>v>v^v>^<>^>v<<>^<>>^<>>^<>v^><<>^v>>^^^^<<^v><>^<^>^^v><^^<^^v>v<<^>^>><<^^^vvv<<^vv<^^>v^^vv^<^^<<^^>>^^<v^>>v^^>v<^>^>vv>><v><^<^vv>^^v>^>v<<^vv><^^^^^^><<^>>>^v<>^^v<<<>><<<>^<<v^>^^^<^>^^^v<<>v^><<^^<<^v<<>^v>>vv>><<^v^^>v^v>^^v<><^^^<^^>v>^<>vvv^v^^^>v^^v<^>^^>>^v<><^><^<<^vv^<><<>v^vv^<<<^^>v<<>>>v<>v<><<^v>^^v>^^>v>^>^>v<>><>^>^>^vvvv<^^^^^v>v>><>^>^><>^^>v^^<<><^><<<<>v>^^>^v<<<>vvv>>v<^v>>v>v^<<<>^>^>^<>v<^^vv><^v<<^vv<^<<^^vv^^>vv<^>v>^^<^>v<<^^<^>^^^v^^>>v^vv^<^v>^<>^<^>>^<^v<>v><^^<><>^>v<^<^vv>><^v>^<>^^>^<><<>^<>><<>vvv^<<^^>>v<^>>vv>^v^^^v<>v<>><>^vv^>vv^\"\"\"" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "2081" + ] + }, + "execution_count": 39, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import collections\n", + "\n", + "x, y = 0, 0\n", + "houses = collections.defaultdict(int)\n", + "houses[(0,0)] = 1\n", + "\n", + "for direction in pi3:\n", + " if direction == \"^\":\n", + " x += 1\n", + " if direction == 'v':\n", + " x -= 1\n", + " if direction == '>':\n", + " y += 1\n", + " if direction == '<':\n", + " y -= 1\n", + " houses[(x, y)] += 1\n", + "len(houses)" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "2341" + ] + }, + "execution_count": 42, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import collections\n", + "\n", + "x, y, rx, ry = 0, 0, 0, 0\n", + "houses = collections.defaultdict(int)\n", + "houses[(0,0)] = 2\n", + "\n", + "for i in range(0, len(pi3), 2):\n", + " direction = pi3[i]\n", + " rdirection = pi3[i+1]\n", + " if direction == \"^\":\n", + " x += 1\n", + " if direction == 'v':\n", + " x -= 1\n", + " if direction == '>':\n", + " y += 1\n", + " if direction == '<':\n", + " y -= 1\n", + " houses[(x, y)] += 1\n", + " if rdirection == \"^\":\n", + " rx += 1\n", + " if rdirection == 'v':\n", + " rx -= 1\n", + " if rdirection == '>':\n", + " ry += 1\n", + " if rdirection == '<':\n", + " ry -= 1\n", + " houses[(rx, ry)] += 1\n", + "len(houses)" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "import hashlib" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'000001dbbfa3a5c83a2d506429c7b00e'" + ] + }, + "execution_count": 47, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "hashlib.md5(b\"abcdef609043\").hexdigest()" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "53" + ] + }, + "execution_count": 52, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "bytes(str(75), 'ascii')[1]" + ] + }, + { + "cell_type": "code", + "execution_count": 59, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "346386" + ] + }, + "execution_count": 59, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "i = 0\n", + "salt = b\"iwrupvqb\"\n", + "hd = hashlib.md5(salt + bytes(str(i), 'ascii')).hexdigest()\n", + "while not hd.startswith('00000'):\n", + " i+=1\n", + " hd = hashlib.md5(salt + bytes(str(i), 'ascii')).hexdigest()\n", + "i" + ] + }, + { + "cell_type": "code", + "execution_count": 60, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "9958218" + ] + }, + "execution_count": 60, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "i = 0\n", + "salt = b\"iwrupvqb\"\n", + "hd = hashlib.md5(salt + bytes(str(i), 'ascii')).hexdigest()\n", + "while not hd.startswith('000000'):\n", + " i+=1\n", + " hd = hashlib.md5(salt + bytes(str(i), 'ascii')).hexdigest()\n", + "i" + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 55, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "hd.startswith('cb')" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "pi5 = \"\"\"sszojmmrrkwuftyv\n", + "isaljhemltsdzlum\n", + "fujcyucsrxgatisb\n", + "qiqqlmcgnhzparyg\n", + "oijbmduquhfactbc\n", + "jqzuvtggpdqcekgk\n", + "zwqadogmpjmmxijf\n", + "uilzxjythsqhwndh\n", + "gtssqejjknzkkpvw\n", + "wrggegukhhatygfi\n", + "vhtcgqzerxonhsye\n", + "tedlwzdjfppbmtdx\n", + "iuvrelxiapllaxbg\n", + "feybgiimfthtplui\n", + "qxmmcnirvkzfrjwd\n", + "vfarmltinsriqxpu\n", + "oanqfyqirkraesfq\n", + "xilodxfuxphuiiii\n", + "yukhnchvjkfwcbiq\n", + "bdaibcbzeuxqplop\n", + "ivegnnpbiyxqsion\n", + "ybahkbzpditgwdgt\n", + "dmebdomwabxgtctu\n", + "ibtvimgfaeonknoh\n", + "jsqraroxudetmfyw\n", + "dqdbcwtpintfcvuz\n", + "tiyphjunlxddenpj\n", + "fgqwjgntxagidhah\n", + "nwenhxmakxqkeehg\n", + "zdoheaxqpcnlhnen\n", + "tfetfqojqcdzlpbm\n", + "qpnxkuldeiituggg\n", + "xwttlbdwxohahwar\n", + "hjkwzadmtrkegzye\n", + "koksqrqcfwcaxeof\n", + "wulwmrptktliyxeq\n", + "gyufbedqhhyqgqzj\n", + "txpunzodohikzlmj\n", + "jloqfuejfkemcrvu\n", + "amnflshcheuddqtc\n", + "pdvcsduggcogbiia\n", + "yrioavgfmeafjpcz\n", + "uyhbtmbutozzqfvq\n", + "mwhgfwsgyuwcdzik\n", + "auqylgxhmullxpaa\n", + "lgelzivplaeoivzh\n", + "uyvcepielfcmswoa\n", + "qhirixgwkkccuzlp\n", + "zoonniyosmkeejfg\n", + "iayfetpixkedyana\n", + "ictqeyzyqswdskiy\n", + "ejsgqteafvmorwxe\n", + "lhaiqrlqqwfbrqdx\n", + "ydjyboqwhfpqfydc\n", + "dwhttezyanrnbybv\n", + "edgzkqeqkyojowvr\n", + "rmjfdwsqamjqehdq\n", + "ozminkgnkwqctrxz\n", + "bztjhxpjthchhfcd\n", + "vrtioawyxkivrpiq\n", + "dpbcsznkpkaaclyy\n", + "vpoypksymdwttpvz\n", + "hhdlruwclartkyap\n", + "bqkrcbrksbzcggbo\n", + "jerbbbnxlwfvlaiw\n", + "dwkasufidwjrjfbf\n", + "kkfxtjhbnmqbmfwf\n", + "vmnfziwqxmioukmj\n", + "rqxvcultipkecdtu\n", + "fhmfdibhtjzkiqsd\n", + "hdpjbuzzbyafqrpd\n", + "emszboysjuvwwvts\n", + "msyigmwcuybfiooq\n", + "druyksfnbluvnwoh\n", + "fvgstvynnfbvxhsx\n", + "bmzalvducnqtuune\n", + "lzwkzfzttsvpllei\n", + "olmplpvjamynfyfd\n", + "padcwfkhystsvyfb\n", + "wjhbvxkwtbfqdilb\n", + "hruaqjwphonnterf\n", + "bufjobjtvxtzjpmj\n", + "oiedrjvmlbtwyyuy\n", + "sgiemafwfztwsyju\n", + "nsoqqfudrtwszyqf\n", + "vonbxquiiwxnazyl\n", + "yvnmjxtptujwqudn\n", + "rrnybqhvrcgwvrkq\n", + "taktoxzgotzxntfu\n", + "quffzywzpxyaepxa\n", + "rfvjebfiddcfgmwv\n", + "iaeozntougqwnzoh\n", + "scdqyrhoqmljhoil\n", + "bfmqticltmfhxwld\n", + "brbuktbyqlyfpsdl\n", + "oidnyhjkeqenjlhd\n", + "kujsaiqojopvrygg\n", + "vebzobmdbzvjnjtk\n", + "uunoygzqjopwgmbg\n", + "piljqxgicjzgifso\n", + "ikgptwcjzywswqnw\n", + "pujqsixoisvhdvwi\n", + "trtuxbgigogfsbbk\n", + "mplstsqclhhdyaqk\n", + "gzcwflvmstogdpvo\n", + "tfjywbkmimyyqcjd\n", + "gijutvhruqcsiznq\n", + "ibxkhjvzzxgavkha\n", + "btnxeqvznkxjsgmq\n", + "tjgofgauxaelmjoq\n", + "sokshvyhlkxerjrv\n", + "ltogbivktqmtezta\n", + "uduwytzvqvfluyuf\n", + "msuckpthtgzhdxan\n", + "fqmcglidvhvpirzr\n", + "gwztkqpcwnutvfga\n", + "bsjfgsrntdhlpqbx\n", + "xloczbqybxmiopwt\n", + "orvevzyjliomkkgu\n", + "mzjbhmfjjvaziget\n", + "tlsdxuhwdmghdyjb\n", + "atoecyjhwmznaewi\n", + "pyxpyvvipbqibiox\n", + "ajbfmpqqobfsmesj\n", + "siknbzefjblnohgd\n", + "eqfhgewbblwdfkmc\n", + "opylbscrotckkrbk\n", + "lbwxbofgjkzdxkle\n", + "ceixfjstaptdomvm\n", + "hnkrqxifjmmjktie\n", + "aqykzeuzvvetoygd\n", + "fouahjimfcisxima\n", + "prkzhutbqsyrhjzx\n", + "qqwliakathnsbzne\n", + "sayhgqtlcqqidqhj\n", + "ygduolbysehdudra\n", + "zricvxhdzznuxuce\n", + "ucvzakslykpgsixd\n", + "udirhgcttmyspgsb\n", + "yuwzppjzfsjhhdzi\n", + "gtqergjiuwookwre\n", + "xvxexbjyjkxovvwf\n", + "mlpaqhnnkqxrmwmm\n", + "ezuqbrjozwuqafhb\n", + "mcarusdthcbsonoq\n", + "weeguqeheeiigrue\n", + "pngtfugozxofaqxv\n", + "copphvbjcmfspenv\n", + "jiyahihykjjkdaya\n", + "gdqnmesvptuyrfwp\n", + "vbdscfywqmfxbohh\n", + "crtrfuxyjypzubrg\n", + "seihvevtxywxhflp\n", + "fvvpmgttnapklwou\n", + "qmqaqsajmqwhetpk\n", + "zetxvrgjmblxvakr\n", + "kpvwblrizaabmnhz\n", + "mwpvvzaaicntrkcp\n", + "clqyjiegtdsswqfm\n", + "ymrcnqgcpldgfwtm\n", + "nzyqpdenetncgnwq\n", + "cmkzevgacnmdkqro\n", + "kzfdsnamjqbeirhi\n", + "kpxrvgvvxapqlued\n", + "rzskbnfobevzrtqu\n", + "vjoahbfwtydugzap\n", + "ykbbldkoijlvicbl\n", + "mfdmroiztsgjlasb\n", + "quoigfyxwtwprmdr\n", + "ekxjqafwudgwfqjm\n", + "obtvyjkiycxfcdpb\n", + "lhoihfnbuqelthof\n", + "eydwzitgxryktddt\n", + "rxsihfybacnpoyny\n", + "bsncccxlplqgygtw\n", + "rvmlaudsifnzhcqh\n", + "huxwsyjyebckcsnn\n", + "gtuqzyihwhqvjtes\n", + "zreeyomtngvztveq\n", + "nwddzjingsarhkxb\n", + "nuqxqtctpoldrlsh\n", + "wkvnrwqgjooovhpf\n", + "kwgueyiyffudtbyg\n", + "tpkzapnjxefqnmew\n", + "ludwccvkihagvxal\n", + "lfdtzhfadvabghna\n", + "njqmlsnrkcfhtvbb\n", + "cajzbqleghhnlgap\n", + "vmitdcozzvqvzatp\n", + "eelzefwqwjiywbcz\n", + "uyztcuptfqvymjpi\n", + "aorhnrpkjqqtgnfo\n", + "lfrxfdrduoeqmwwp\n", + "vszpjvbctblplinh\n", + "zexhadgpqfifcqrz\n", + "ueirfnshekpemqua\n", + "qfremlntihbwabtb\n", + "nwznunammfexltjc\n", + "zkyieokaaogjehwt\n", + "vlrxgkpclzeslqkq\n", + "xrqrwfsuacywczhs\n", + "olghlnfjdiwgdbqc\n", + "difnlxnedpqcsrdf\n", + "dgpuhiisybjpidsj\n", + "vlwmwrikmitmoxbt\n", + "sazpcmcnviynoktm\n", + "pratafauetiknhln\n", + "ilgteekhzwlsfwcn\n", + "ywvwhrwhkaubvkbl\n", + "qlaxivzwxyhvrxcf\n", + "hbtlwjdriizqvjfb\n", + "nrmsononytuwslsa\n", + "mpxqgdthpoipyhjc\n", + "mcdiwmiqeidwcglk\n", + "vfbaeavmjjemfrmo\n", + "qzcbzmisnynzibrc\n", + "shzmpgxhehhcejhb\n", + "wirtjadsqzydtyxd\n", + "qjlrnjfokkqvnpue\n", + "dxawdvjntlbxtuqc\n", + "wttfmnrievfestog\n", + "eamjfvsjhvzzaobg\n", + "pbvfcwzjgxahlrag\n", + "omvmjkqqnobvnzkn\n", + "lcwmeibxhhlxnkzv\n", + "uiaeroqfbvlazegs\n", + "twniyldyuonfyzqw\n", + "wgjkmsbwgfotdabi\n", + "hnomamxoxvrzvtew\n", + "ycrcfavikkrxxfgw\n", + "isieyodknagzhaxy\n", + "mgzdqwikzullzyco\n", + "mumezgtxjrrejtrs\n", + "nwmwjcgrqiwgfqel\n", + "wjgxmebfmyjnxyyp\n", + "durpspyljdykvzxf\n", + "zuslbrpooyetgafh\n", + "kuzrhcjwbdouhyme\n", + "wyxuvbciodscbvfm\n", + "kbnpvuqwmxwfqtqe\n", + "zddzercqogdpxmft\n", + "sigrdchxtgavzzjh\n", + "lznjolnorbuddgcs\n", + "ycnqabxlcajagwbt\n", + "bnaudeaexahdgxsj\n", + "rlnykxvoctfwanms\n", + "jngyetkoplrstfzt\n", + "tdpxknwacksotdub\n", + "yutqgssfoptvizgr\n", + "lzmqnxeqjfnsxmsa\n", + "iqpgfsfmukovsdgu\n", + "qywreehbidowtjyz\n", + "iozamtgusdctvnkw\n", + "ielmujhtmynlwcfd\n", + "hzxnhtbnmmejlkyf\n", + "ftbslbzmiqkzebtd\n", + "bcwdqgiiizmohack\n", + "dqhfkzeddjzbdlxu\n", + "mxopokqffisxosci\n", + "vciatxhtuechbylk\n", + "khtkhcvelidjdena\n", + "blatarwzfqcapkdt\n", + "elamngegnczctcck\n", + "xeicefdbwrxhuxuf\n", + "sawvdhjoeahlgcdr\n", + "kmdcimzsfkdfpnir\n", + "axjayzqlosrduajb\n", + "mfhzreuzzumvoggr\n", + "iqlbkbhrkptquldb\n", + "xcvztvlshiefuhgb\n", + "pkvwyqmyoazocrio\n", + "ajsxkdnerbmhyxaj\n", + "tudibgsbnpnizvsi\n", + "cxuiydkgdccrqvkh\n", + "cyztpjesdzmbcpot\n", + "nnazphxpanegwitx\n", + "uphymczbmjalmsct\n", + "yyxiwnlrogyzwqmg\n", + "gmqwnahjvvdyhnfa\n", + "utolskxpuoheugyl\n", + "mseszdhyzoyavepd\n", + "ycqknvbuvcjfgmlc\n", + "sknrxhxbfpvpeorn\n", + "zqxqjetooqcodwml\n", + "sesylkpvbndrdhsy\n", + "fryuxvjnsvnjrxlw\n", + "mfxusewqurscujnu\n", + "mbitdjjtgzchvkfv\n", + "ozwlyxtaalxofovd\n", + "wdqcduaykxbunpie\n", + "rlnhykxiraileysk\n", + "wgoqfrygttlamobg\n", + "kflxzgxvcblkpsbz\n", + "tmkisflhativzhde\n", + "owsdrfgkaamogjzd\n", + "gaupjkvkzavhfnes\n", + "wknkurddcknbdleg\n", + "lltviwincmbtduap\n", + "qwzvspgbcksyzzmb\n", + "ydzzkumecryfjgnk\n", + "jzvmwgjutxoysaam\n", + "icrwpyhxllbardkr\n", + "jdopyntshmvltrve\n", + "afgkigxcuvmdbqou\n", + "mfzzudntmvuyhjzt\n", + "duxhgtwafcgrpihc\n", + "tsnhrkvponudumeb\n", + "sqtvnbeiigdzbjgv\n", + "eczmkqwvnsrracuo\n", + "mhehsgqwiczaiaxv\n", + "kaudmfvifovrimpd\n", + "lupikgivechdbwfr\n", + "mwaaysrndiutuiqx\n", + "aacuiiwgaannunmm\n", + "tjqjbftaqitukwzp\n", + "lrcqyskykbjpaekn\n", + "lirrvofbcqpjzxmr\n", + "jurorvzpplyelfml\n", + "qonbllojmloykjqe\n", + "sllkzqujfnbauuqp\n", + "auexjwsvphvikali\n", + "usuelbssqmbrkxyc\n", + "wyuokkfjexikptvv\n", + "wmfedauwjgbrgytl\n", + "sfwvtlzzebxzmuvw\n", + "rdhqxuechjsjcvaf\n", + "kpavhqkukugocsxu\n", + "ovnjtumxowbxduts\n", + "zgerpjufauptxgat\n", + "pevvnzjfwhjxdoxq\n", + "pmmfwxajgfziszcs\n", + "difmeqvaghuitjhs\n", + "icpwjbzcmlcterwm\n", + "ngqpvhajttxuegyh\n", + "mosjlqswdngwqsmi\n", + "frlvgpxrjolgodlu\n", + "eazwgrpcxjgoszeg\n", + "bbtsthgkjrpkiiyk\n", + "tjonoglufuvsvabe\n", + "xhkbcrofytmbzrtk\n", + "kqftfzdmpbxjynps\n", + "kmeqpocbnikdtfyv\n", + "qjjymgqxhnjwxxhp\n", + "dmgicrhgbngdtmjt\n", + "zdxrhdhbdutlawnc\n", + "afvoekuhdboxghvx\n", + "hiipezngkqcnihty\n", + "bbmqgheidenweeov\n", + "suprgwxgxwfsgjnx\n", + "adeagikyamgqphrj\n", + "zzifqinoeqaorjxg\n", + "adhgppljizpaxzld\n", + "lvxyieypvvuqjiyc\n", + "nljoakatwwwoovzn\n", + "fcrkfxclcacshhmx\n", + "ownnxqtdhqbgthch\n", + "lmfylrcdmdkgpwnj\n", + "hlwjfbvlswbzpbjr\n", + "mkofhdtljdetcyvp\n", + "synyxhifbetzarpo\n", + "agnggugngadrcxoc\n", + "uhttadmdmhidpyjw\n", + "ohfwjfhunalbubpr\n", + "pzkkkkwrlvxiuysn\n", + "kmidbxmyzkjrwjhu\n", + "egtitdydwjxmajnw\n", + "civoeoiuwtwgbqqs\n", + "dfptsguzfinqoslk\n", + "tdfvkreormspprer\n", + "zvnvbrmthatzztwi\n", + "ffkyddccrrfikjde\n", + "hrrmraevdnztiwff\n", + "qaeygykcpbtjwjbr\n", + "purwhitkmrtybslh\n", + "qzziznlswjaussel\n", + "dfcxkvdpqccdqqxj\n", + "tuotforulrrytgyn\n", + "gmtgfofgucjywkev\n", + "wkyoxudvdkbgpwhd\n", + "qbvktvfvipftztnn\n", + "otckgmojziezmojb\n", + "inxhvzbtgkjxflay\n", + "qvxapbiatuudseno\n", + "krpvqosbesnjntut\n", + "oqeukkgjsfuqkjbb\n", + "prcjnyymnqwqksiz\n", + "vuortvjxgckresko\n", + "orqlyobvkuwgathr\n", + "qnpyxlnazyfuijox\n", + "zwlblfkoklqmqzkw\n", + "hmwurwtpwnrcsanl\n", + "jzvxohuakopuzgpf\n", + "sfcpnxrviphhvxmx\n", + "qtwdeadudtqhbely\n", + "dbmkmloasqphnlgj\n", + "olylnjtkxgrubmtk\n", + "nxsdbqjuvwrrdbpq\n", + "wbabpirnpcsmpipw\n", + "hjnkyiuxpqrlvims\n", + "enzpntcjnxdpuqch\n", + "vvvqhlstzcizyimn\n", + "triozhqndbttglhv\n", + "fukvgteitwaagpzx\n", + "uhcvukfbmrvskpen\n", + "tizcyupztftzxdmt\n", + "vtkpnbpdzsaluczz\n", + "wodfoyhoekidxttm\n", + "otqocljrmwfqbxzu\n", + "linfbsnfvixlwykn\n", + "vxsluutrwskslnye\n", + "zbshygtwugixjvsi\n", + "zdcqwxvwytmzhvoo\n", + "wrseozkkcyctrmei\n", + "fblgtvogvkpqzxiy\n", + "opueqnuyngegbtnf\n", + "qxbovietpacqqxok\n", + "zacrdrrkohfygddn\n", + "gbnnvjqmkdupwzpq\n", + "qgrgmsxeotozvcak\n", + "hnppukzvzfmlokid\n", + "dzbheurndscrrtcl\n", + "wbgdkadtszebbrcw\n", + "fdmzppzphhpzyuiz\n", + "bukomunhrjrypohj\n", + "ohodhelegxootqbj\n", + "rsplgzarlrknqjyh\n", + "punjjwpsxnhpzgvu\n", + "djdfahypfjvpvibm\n", + "mlgrqsmhaozatsvy\n", + "xwktrgyuhqiquxgn\n", + "wvfaoolwtkbrisvf\n", + "plttjdmguxjwmeqr\n", + "zlvvbwvlhauyjykw\n", + "cigwkbyjhmepikej\n", + "masmylenrusgtyxs\n", + "hviqzufwyetyznze\n", + "nzqfuhrooswxxhus\n", + "pdbdetaqcrqzzwxf\n", + "oehmvziiqwkzhzib\n", + "icgpyrukiokmytoy\n", + "ooixfvwtiafnwkce\n", + "rvnmgqggpjopkihs\n", + "wywualssrmaqigqk\n", + "pdbvflnwfswsrirl\n", + "jeaezptokkccpbuj\n", + "mbdwjntysntsaaby\n", + "ldlgcawkzcwuxzpz\n", + "lwktbgrzswbsweht\n", + "ecspepmzarzmgpjm\n", + "qmfyvulkmkxjncai\n", + "izftypvwngiukrns\n", + "zgmnyjfeqffbooww\n", + "nyrkhggnprhedows\n", + "yykzzrjmlevgffah\n", + "mavaemfxhlfejfki\n", + "cmegmfjbkvpncqwf\n", + "zxidlodrezztcrij\n", + "fseasudpgvgnysjv\n", + "fupcimjupywzpqzp\n", + "iqhgokavirrcvyys\n", + "wjmkcareucnmfhui\n", + "nftflsqnkgjaexhq\n", + "mgklahzlcbapntgw\n", + "kfbmeavfxtppnrxn\n", + "nuhyvhknlufdynvn\n", + "nviogjxbluwrcoec\n", + "tyozixxxaqiuvoys\n", + "kgwlvmvgtsvxojpr\n", + "moeektyhyonfdhrb\n", + "kahvevmmfsmiiqex\n", + "xcywnqzcdqtvhiwd\n", + "fnievhiyltbvtvem\n", + "jlmndqufirwgtdxd\n", + "muypbfttoeelsnbs\n", + "rypxzbnujitfwkou\n", + "ubmmjbznskildeoj\n", + "ofnmizdeicrmkjxp\n", + "rekvectjbmdnfcib\n", + "yohrojuvdexbctdh\n", + "gwfnfdeibynzjmhz\n", + "jfznhfcqdwlpjull\n", + "scrinzycfhwkmmso\n", + "mskutzossrwoqqsi\n", + "rygoebkzgyzushhr\n", + "jpjqiycflqkexemx\n", + "arbufysjqmgaapnl\n", + "dbjerflevtgweeoj\n", + "snybnnjlmwjvhois\n", + "fszuzplntraprmbj\n", + "mkvaatolvuggikvg\n", + "zpuzuqygoxesnuyc\n", + "wnpxvmxvllxalulm\n", + "eivuuafkvudeouwy\n", + "rvzckdyixetfuehr\n", + "qgmnicdoqhveahyx\n", + "miawwngyymshjmpj\n", + "pvckyoncpqeqkbmx\n", + "llninfenrfjqxurv\n", + "kzbjnlgsqjfuzqtp\n", + "rveqcmxomvpjcwte\n", + "bzotkawzbopkosnx\n", + "ktqvpiribpypaymu\n", + "wvlzkivbukhnvram\n", + "uohntlcoguvjqqdo\n", + "ajlsiksjrcnzepkt\n", + "xsqatbldqcykwusd\n", + "ihbivgzrwpmowkop\n", + "vfayesfojmibkjpb\n", + "uaqbnijtrhvqxjtb\n", + "hhovshsfmvkvymba\n", + "jerwmyxrfeyvxcgg\n", + "hncafjwrlvdcupma\n", + "qyvigggxfylbbrzt\n", + "hiiixcyohmvnkpgk\n", + "mmitpwopgxuftdfu\n", + "iaxderqpceboixoa\n", + "zodfmjhuzhnsqfcb\n", + "sthtcbadrclrazsi\n", + "bkkkkcwegvypbrio\n", + "wmpcofuvzemunlhj\n", + "gqwebiifvqoeynro\n", + "juupusqdsvxcpsgv\n", + "rbhdfhthxelolyse\n", + "kjimpwnjfrqlqhhz\n", + "rcuigrjzarzpjgfq\n", + "htxcejfyzhydinks\n", + "sxucpdxhvqjxxjwf\n", + "omsznfcimbcwaxal\n", + "gufmtdlhgrsvcosb\n", + "bssshaqujtmluerz\n", + "uukotwjkstgwijtr\n", + "kbqkneobbrdogrxk\n", + "ljqopjcjmelgrakz\n", + "rwtfnvnzryujwkfb\n", + "dedjjbrndqnilbeh\n", + "nzinsxnpptzagwlb\n", + "lwqanydfirhnhkxy\n", + "hrjuzfumbvfccxno\n", + "okismsadkbseumnp\n", + "sfkmiaiwlktxqvwa\n", + "hauwpjjwowbunbjj\n", + "nowkofejwvutcnui\n", + "bqzzppwoslaeixro\n", + "urpfgufwbtzenkpj\n", + "xgeszvuqwxeykhef\n", + "yxoldvkyuikwqyeq\n", + "onbbhxrnmohzskgg\n", + "qcikuxakrqeugpoa\n", + "lnudcqbtyzhlpers\n", + "nxduvwfrgzaailgl\n", + "xniuwvxufzxjjrwz\n", + "ljwithcqmgvntjdj\n", + "awkftfagrfzywkhs\n", + "uedtpzxyubeveuek\n", + "bhcqdwidbjkqqhzl\n", + "iyneqjdmlhowwzxx\n", + "kvshzltcrrururty\n", + "zgfpiwajegwezupo\n", + "tkrvyanujjwmyyri\n", + "ercsefuihcmoaiep\n", + "ienjrxpmetinvbos\n", + "jnwfutjbgenlipzq\n", + "bgohjmrptfuamzbz\n", + "rtsyamajrhxbcncw\n", + "tfjdssnmztvbnscs\n", + "bgaychdlmchngqlp\n", + "kfjljiobynhwfkjo\n", + "owtdxzcpqleftbvn\n", + "ltjtimxwstvzwzjj\n", + "wbrvjjjajuombokf\n", + "zblpbpuaqbkvsxye\n", + "gwgdtbpnlhyqspdi\n", + "abipqjihjqfofmkx\n", + "nlqymnuvjpvvgova\n", + "avngotmhodpoufzn\n", + "qmdyivtzitnrjuae\n", + "xfwjmqtqdljuerxi\n", + "csuellnlcyqaaamq\n", + "slqyrcurcyuoxquo\n", + "dcjmxyzbzpohzprl\n", + "uqfnmjwniyqgsowb\n", + "rbmxpqoblyxdocqc\n", + "ebjclrdbqjhladem\n", + "ainnfhxnsgwqnmyo\n", + "eyytjjwhvodtzquf\n", + "iabjgmbbhilrcyyp\n", + "pqfnehkivuelyccc\n", + "xgjbyhfgmtseiimt\n", + "jwxyqhdbjiqqqeyy\n", + "gxsbrncqkmvaryln\n", + "vhjisxjkinaejytk\n", + "seexagcdmaedpcvh\n", + "lvudfgrcpjxzdpvd\n", + "fxtegyrqjzhmqean\n", + "dnoiseraqcoossmc\n", + "nwrhmwwbykvwmgep\n", + "udmzskejvizmtlce\n", + "hbzvqhvudfdlegaa\n", + "cghmlfqejbxewskv\n", + "bntcmjqfwomtbwsb\n", + "qezhowyopjdyhzng\n", + "todzsocdkgfxanbz\n", + "zgjkssrjlwxuhwbk\n", + "eibzljqsieriyrzr\n", + "wamxvzqyycrxotjp\n", + "epzvfkispwqynadu\n", + "dwlpfhtrafrxlyie\n", + "qhgzujhgdruowoug\n", + "girstvkahaemmxvh\n", + "baitcrqmxhazyhbl\n", + "xyanqcchbhkajdmc\n", + "gfvjmmcgfhvgnfdq\n", + "tdfdbslwncbnkzyz\n", + "jojuselkpmnnbcbb\n", + "hatdslkgxtqpmavj\n", + "dvelfeddvgjcyxkj\n", + "gnsofhkfepgwltse\n", + "mdngnobasfpewlno\n", + "qssnbcyjgmkyuoga\n", + "glvcmmjytmprqwvn\n", + "gwrixumjbcdffsdl\n", + "lozravlzvfqtsuiq\n", + "sicaflbqdxbmdlch\n", + "inwfjkyyqbwpmqlq\n", + "cuvszfotxywuzhzi\n", + "igfxyoaacoarlvay\n", + "ucjfhgdmnjvgvuni\n", + "rvvkzjsytqgiposh\n", + "jduinhjjntrmqroz\n", + "yparkxbgsfnueyll\n", + "lyeqqeisxzfsqzuj\n", + "woncskbibjnumydm\n", + "lltucklragtjmxtl\n", + "ubiyvmyhlesfxotj\n", + "uecjseeicldqrqww\n", + "xxlxkbcthufnjbnm\n", + "lhqijovvhlffpxga\n", + "fzdgqpzijitlogjz\n", + "efzzjqvwphomxdpd\n", + "jvgzvuyzobeazssc\n", + "hejfycgxywfjgbfw\n", + "yhjjmvkqfbnbliks\n", + "sffvfyywtlntsdsz\n", + "dwmxqudvxqdenrur\n", + "asnukgppdemxrzaz\n", + "nwqfnumblwvdpphx\n", + "kqsmkkspqvxzuket\n", + "cpnraovljzqiquaz\n", + "qrzgrdlyyzbyykhg\n", + "opoahcbiydyhsmqe\n", + "hjknnfdauidjeydr\n", + "hczdjjlygoezadow\n", + "rtflowzqycimllfv\n", + "sfsrgrerzlnychhq\n", + "bpahuvlblcolpjmj\n", + "albgnjkgmcrlaicl\n", + "pijyqdhfxpaxzdex\n", + "eeymiddvcwkpbpux\n", + "rqwkqoabywgggnln\n", + "vckbollyhgbgmgwh\n", + "ylzlgvnuvpynybkm\n", + "hpmbxtpfosbsjixt\n", + "ocebeihnhvkhjfqz\n", + "tvctyxoujdgwayze\n", + "efvhwxtuhapqxjen\n", + "rusksgefyidldmpo\n", + "nkmtjvddfmhirmzz\n", + "whvtsuadwofzmvrt\n", + "iiwjqvsdxudhdzzk\n", + "gucirgxaxgcassyo\n", + "rmhfasfzexeykwmr\n", + "hynlxcvsbgosjbis\n", + "huregszrcaocueen\n", + "pifezpoolrnbdqtv\n", + "unatnixzvdbqeyox\n", + "xtawlpduxgacchfe\n", + "bdvdbflqfphndduf\n", + "xtdsnjnmzccfptyt\n", + "nkhsdkhqtzqbphhg\n", + "aqcubmfkczlaxiyb\n", + "moziflxpsfubucmv\n", + "srdgnnjtfehiimqx\n", + "pwfalehdfyykrohf\n", + "sysxssmvewyfjrve\n", + "brsemdzosgqvvlxe\n", + "bimbjoshuvflkiat\n", + "hkgjasmljkpkwwku\n", + "sbnmwjvodygobpqc\n", + "bbbqycejueruihhd\n", + "corawswvlvneipyc\n", + "gcyhknmwsczcxedh\n", + "kppakbffdhntmcqp\n", + "ynulzwkfaemkcefp\n", + "pyroowjekeurlbii\n", + "iwksighrswdcnmxf\n", + "glokrdmugreygnsg\n", + "xkmvvumnfzckryop\n", + "aesviofpufygschi\n", + "csloawlirnegsssq\n", + "fkqdqqmlzuxbkzbc\n", + "uzlhzcfenxdfjdzp\n", + "poaaidrktteusvyf\n", + "zrlyfzmjzfvivcfr\n", + "qwjulskbniitgqtx\n", + "gjeszjksbfsuejki\n", + "vczdejdbfixbduaq\n", + "knjdrjthitjxluth\n", + "jweydeginrnicirl\n", + "bottrfgccqhyycsl\n", + "eiquffofoadmbuhk\n", + "lbqfutmzoksscswf\n", + "xfmdvnvfcnzjprba\n", + "uvugkjbkhlaoxmyx\n", + "wadlgtpczgvcaqqv\n", + "inzrszbtossflsxk\n", + "dbzbtashaartczrj\n", + "qbjiqpccefcfkvod\n", + "hluujmokjywotvzy\n", + "thwlliksfztcmwzh\n", + "arahybspdaqdexrq\n", + "nuojrmsgyipdvwyx\n", + "hnajdwjwmzattvst\n", + "sulcgaxezkprjbgu\n", + "rjowuugwdpkjtypw\n", + "oeugzwuhnrgiaqga\n", + "wvxnyymwftfoswij\n", + "pqxklzkjpcqscvde\n", + "tuymjzknntekglqj\n", + "odteewktugcwlhln\n", + "exsptotlfecmgehc\n", + "eeswfcijtvzgrqel\n", + "vjhrkiwmunuiwqau\n", + "zhlixepkeijoemne\n", + "pavfsmwesuvebzdd\n", + "jzovbklnngfdmyws\n", + "nbajyohtzfeoiixz\n", + "ciozmhrsjzrwxvhz\n", + "gwucrxieqbaqfjuv\n", + "uayrxrltnohexawc\n", + "flmrbhwsfbcquffm\n", + "gjyabmngkitawlxc\n", + "rwwtggvaygfbovhg\n", + "xquiegaisynictjq\n", + "oudzwuhexrwwdbyy\n", + "lengxmguyrwhrebb\n", + "uklxpglldbgqsjls\n", + "dbmvlfeyguydfsxq\n", + "zspdwdqcrmtmdtsc\n", + "mqfnzwbfqlauvrgc\n", + "amcrkzptgacywvhv\n", + "ndxmskrwrqysrndf\n", + "mwjyhsufeqhwisju\n", + "srlrukoaenyevykt\n", + "tnpjtpwawrxbikct\n", + "geczalxmgxejulcv\n", + "tvkcbqdhmuwcxqci\n", + "tiovluvwezwwgaox\n", + "zrjhtbgajkjqzmfo\n", + "vcrywduwsklepirs\n", + "lofequdigsszuioy\n", + "wxsdzomkjqymlzat\n", + "iabaczqtrfbmypuy\n", + "ibdlmudbajikcncr\n", + "rqcvkzsbwmavdwnv\n", + "ypxoyjelhllhbeog\n", + "fdnszbkezyjbttbg\n", + "uxnhrldastpdjkdz\n", + "xfrjbehtxnlyzcka\n", + "omjyfhbibqwgcpbv\n", + "eguucnoxaoprszmp\n", + "xfpypldgcmcllyzz\n", + "aypnmgqjxjqceelv\n", + "mgzharymejlafvgf\n", + "tzowgwsubbaigdok\n", + "ilsehjqpcjwmylxc\n", + "pfmouwntfhfnmrwk\n", + "csgokybgdqwnduwp\n", + "eaxwvxvvwbrovypz\n", + "nmluqvobbbmdiwwb\n", + "lnkminvfjjzqbmio\n", + "mjiiqzycqdhfietz\n", + "towlrzriicyraevq\n", + "obiloewdvbrsfwjo\n", + "lmeooaajlthsfltw\n", + "ichygipzpykkesrw\n", + "gfysloxmqdsfskvt\n", + "saqzntehjldvwtsx\n", + "pqddoemaufpfcaew\n", + "mjrxvbvwcreaybwe\n", + "ngfbrwfqnxqosoai\n", + "nesyewxreiqvhald\n", + "kqhqdlquywotcyfy\n", + "liliptyoqujensfi\n", + "nsahsaxvaepzneqq\n", + "zaickulfjajhctye\n", + "gxjzahtgbgbabtht\n", + "koxbuopaqhlsyhrp\n", + "jhzejdjidqqtjnwe\n", + "dekrkdvprfqpcqki\n", + "linwlombdqtdeyop\n", + "dvckqqbnigdcmwmx\n", + "yaxygbjpzkvnnebv\n", + "rlzkdkgaagmcpxah\n", + "cfzuyxivtknirqvt\n", + "obivkajhsjnrxxhn\n", + "lmjhayymgpseuynn\n", + "bbjyewkwadaipyju\n", + "lmzyhwomfypoftuu\n", + "gtzhqlgltvatxack\n", + "jfflcfaqqkrrltgq\n", + "txoummmnzfrlrmcg\n", + "ohemsbfuqqpucups\n", + "imsfvowcbieotlok\n", + "tcnsnccdszxfcyde\n", + "qkcdtkwuaquajazz\n", + "arcfnhmdjezdbqku\n", + "srnocgyqrlcvlhkb\n", + "mppbzvfmcdirbyfw\n", + "xiuarktilpldwgwd\n", + "ypufwmhrvzqmexpc\n", + "itpdnsfkwgrdujmj\n", + "cmpxnodtsswkyxkr\n", + "wayyxtjklfrmvbfp\n", + "mfaxphcnjczhbbwy\n", + "sjxhgwdnqcofbdra\n", + "pnxmujuylqccjvjm\n", + "ivamtjbvairwjqwl\n", + "deijtmzgpfxrclss\n", + "bzkqcaqagsynlaer\n", + "tycefobvxcvwaulz\n", + "ctbhnywezxkdsswf\n", + "urrxxebxrthtjvib\n", + "fpfelcigwqwdjucv\n", + "ngfcyyqpqulwcphb\n", + "rltkzsiipkpzlgpw\n", + "qfdsymzwhqqdkykc\n", + "balrhhxipoqzmihj\n", + "rnwalxgigswxomga\n", + "ghqnxeogckshphgr\n", + "lyyaentdizaumnla\n", + "exriodwfzosbeoib\n", + "speswfggibijfejk\n", + "yxmxgfhvmshqszrq\n", + "hcqhngvahzgawjga\n", + "qmhlsrfpesmeksur\n", + "eviafjejygakodla\n", + "kvcfeiqhynqadbzv\n", + "fusvyhowslfzqttg\n", + "girqmvwmcvntrwau\n", + "yuavizroykfkdekz\n", + "jmcwohvmzvowrhxf\n", + "kzimlcpavapynfue\n", + "wjudcdtrewfabppq\n", + "yqpteuxqgbmqfgxh\n", + "xdgiszbuhdognniu\n", + "jsguxfwhpftlcjoh\n", + "whakkvspssgjzxre\n", + "ggvnvjurlyhhijgm\n", + "krvbhjybnpemeptr\n", + "pqedgfojyjybfbzr\n", + "jzhcrsgmnkwwtpdo\n", + "yyscxoxwofslncmp\n", + "gzjhnxytmyntzths\n", + "iteigbnqbtpvqumi\n", + "zjevfzusnjukqpfw\n", + "xippcyhkfuounxqk\n", + "mcnhrcfonfdgpkyh\n", + "pinkcyuhjkexbmzj\n", + "lotxrswlxbxlxufs\n", + "fmqajrtoabpckbnu\n", + "wfkwsgmcffdgaqxg\n", + "qfrsiwnohoyfbidr\n", + "czfqbsbmiuyusaqs\n", + "ieknnjeecucghpoo\n", + "cevdgqnugupvmsge\n", + "gjkajcyjnxdrtuvr\n", + "udzhrargnujxiclq\n", + "zqqrhhmjwermjssg\n", + "ggdivtmgoqajydzz\n", + "wnpfsgtxowkjiivl\n", + "afbhqawjbotxnqpd\n", + "xjpkifkhfjeqifdn\n", + "oyfggzsstfhvticp\n", + "kercaetahymeawxy\n", + "khphblhcgmbupmzt\n", + "iggoqtqpvaebtiol\n", + "ofknifysuasshoya\n", + "qxuewroccsbogrbv\n", + "apsbnbkiopopytgu\n", + "zyahfroovfjlythh\n", + "bxhjwfgeuxlviydq\n", + "uvbhdtvaypasaswa\n", + "qamcjzrmesqgqdiz\n", + "hjnjyzrxntiycyel\n", + "wkcrwqwniczwdxgq\n", + "hibxlvkqakusswkx\n", + "mzjyuenepwdgrkty\n", + "tvywsoqslfsulses\n", + "jqwcwuuisrclircv\n", + "xanwaoebfrzhurct\n", + "ykriratovsvxxasf\n", + "qyebvtqqxbjuuwuo\n", + "telrvlwvriylnder\n", + "acksrrptgnhkeiaa\n", + "yemwfjhiqlzsvdxf\n", + "banrornfkcymmkcc\n", + "ytbhxvaeiigjpcgm\n", + "crepyazgxquposkn\n", + "xlqwdrytzwnxzwzv\n", + "xtrbfbwopxscftps\n", + "kwbytzukgseeyjla\n", + "qtfdvavvjogybxjg\n", + "ytbmvmrcxwfkgvzw\n", + "nbscbdskdeocnfzr\n", + "sqquwjbdxsxhcseg\n", + "ewqxhigqcgszfsuw\n", + "cvkyfcyfmubzwsee\n", + "dcoawetekigxgygd\n", + "ohgqnqhfimyuqhvi\n", + "otisopzzpvnhctte\n", + "bauieohjejamzien\n", + "ewnnopzkujbvhwce\n", + "aeyqlskpaehagdiv\n", + "pncudvivwnnqspxy\n", + "ytugesilgveokxcg\n", + "zoidxeelqdjesxpr\n", + "ducjccsuaygfchzj\n", + "smhgllqqqcjfubfc\n", + "nlbyyywergronmir\n", + "prdawpbjhrzsbsvj\n", + "nmgzhnjhlpcplmui\n", + "eflaogtjghdjmxxz\n", + "qolvpngucbkprrdc\n", + "ixywxcienveltgho\n", + "mwnpqtocagenkxut\n", + "iskrfbwxonkguywx\n", + "ouhtbvcaczqzmpua\n", + "srewprgddfgmdbao\n", + "dyufrltacelchlvu\n", + "czmzcbrkecixuwzz\n", + "dtbeojcztzauofuk\n", + "prrgoehpqhngfgmw\n", + "baolzvfrrevxsyke\n", + "zqadgxshwiarkzwh\n", + "vsackherluvurqqj\n", + "surbpxdulvcvgjbd\n", + "wqxytarcxzgxhvtx\n", + "vbcubqvejcfsgrac\n", + "zqnjfeapshjowzja\n", + "hekvbhtainkvbynx\n", + "knnugxoktxpvoxnh\n", + "knoaalcefpgtvlwm\n", + "qoakaunowmsuvkus\n", + "ypkvlzcduzlezqcb\n", + "ujhcagawtyepyogh\n", + "wsilcrxncnffaxjf\n", + "gbbycjuscquaycrk\n", + "aduojapeaqwivnly\n", + "ceafyxrakviagcjy\n", + "nntajnghicgnrlst\n", + "vdodpeherjmmvbje\n", + "wyyhrnegblwvdobn\n", + "xlfurpghkpbzhhif\n", + "xyppnjiljvirmqjo\n", + "kglzqahipnddanpi\n", + "omjateouxikwxowr\n", + "ocifnoopfglmndcx\n", + "emudcukfbadyijev\n", + "ooktviixetfddfmh\n", + "wtvrhloyjewdeycg\n", + "cgjncqykgutfjhvb\n", + "nkwvpswppeffmwad\n", + "hqbcmfhzkxmnrivg\n", + "mdskbvzguxvieilr\n", + "anjcvqpavhdloaqh\n", + "erksespdevjylenq\n", + "fadxwbmisazyegup\n", + "iyuiffjmcaahowhj\n", + "ygkdezmynmltodbv\n", + "fytneukxqkjattvh\n", + "woerxfadbfrvdcnz\n", + "iwsljvkyfastccoa\n", + "movylhjranlorofe\n", + "drdmicdaiwukemep\n", + "knfgtsmuhfcvvshg\n", + "ibstpbevqmdlhajn\n", + "tstwsswswrxlzrqs\n", + "estyydmzothggudf\n", + "jezogwvymvikszwa\n", + "izmqcwdyggibliet\n", + "nzpxbegurwnwrnca\n", + "kzkojelnvkwfublh\n", + "xqcssgozuxfqtiwi\n", + "tcdoigumjrgvczfv\n", + "ikcjyubjmylkwlwq\n", + "kqfivwystpqzvhan\n", + "bzukgvyoqewniivj\n", + "iduapzclhhyfladn\n", + "fbpyzxdfmkrtfaeg\n", + "yzsmlbnftftgwadz\"\"\"" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def nice(str):\n", + " n1 = len(list(c for c in str if c in \"aeiou\")) >= 3\n", + " n2 = any(str[i-1] == str[i] for i in range(1, len(str)))\n", + " n3 = all(s not in str for s in ['ab', 'cd', 'pq', 'xy'])\n", + " return n1 and n2 and n3 " + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "nice('dvszwmarrgswjxmb')" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "255" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sum(1 if nice(str.strip()) else 0 for str in pi5.splitlines())" + ] + }, + { + "cell_type": "code", + "execution_count": 67, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def nice2(st):\n", + " def n1(st):\n", + " for i in range(1, len(st)):\n", + " if st.find(st[i-1:i+1], i+1) > -1:\n", + " return True\n", + " return False\n", + " def n2(st):\n", + " return any(st[i-1] == st[i+1] for i in range(1, len(st)-1))\n", + " return n1(st) and n2(st)" + ] + }, + { + "cell_type": "code", + "execution_count": 72, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 72, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "nice2('ieodomkazucvgmuy')" + ] + }, + { + "cell_type": "code", + "execution_count": 69, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['ac', 'bd', 'ce', 'df']" + ] + }, + "execution_count": 69, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "['abcdef'[i-1] + 'abcdef'[i+1] for i in range(1, len('abcdef')-1)]" + ] + }, + { + "cell_type": "code", + "execution_count": 73, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "55" + ] + }, + "execution_count": 73, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sum(1 if nice2(st.strip()) else 0 for st in pi5.splitlines())" + ] + }, + { + "cell_type": "code", + "execution_count": 180, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "pi6 = \"\"\"turn on 489,959 through 759,964\n", + "turn off 820,516 through 871,914\n", + "turn off 427,423 through 929,502\n", + "turn on 774,14 through 977,877\n", + "turn on 410,146 through 864,337\n", + "turn on 931,331 through 939,812\n", + "turn off 756,53 through 923,339\n", + "turn off 313,787 through 545,979\n", + "turn off 12,823 through 102,934\n", + "toggle 756,965 through 812,992\n", + "turn off 743,684 through 789,958\n", + "toggle 120,314 through 745,489\n", + "toggle 692,845 through 866,994\n", + "turn off 587,176 through 850,273\n", + "turn off 674,321 through 793,388\n", + "toggle 749,672 through 973,965\n", + "turn on 943,30 through 990,907\n", + "turn on 296,50 through 729,664\n", + "turn on 212,957 through 490,987\n", + "toggle 171,31 through 688,88\n", + "turn off 991,989 through 994,998\n", + "turn off 913,943 through 958,953\n", + "turn off 278,258 through 367,386\n", + "toggle 275,796 through 493,971\n", + "turn off 70,873 through 798,923\n", + "toggle 258,985 through 663,998\n", + "turn on 601,259 through 831,486\n", + "turn off 914,94 through 941,102\n", + "turn off 558,161 through 994,647\n", + "turn on 119,662 through 760,838\n", + "toggle 378,775 through 526,852\n", + "turn off 384,670 through 674,972\n", + "turn off 249,41 through 270,936\n", + "turn on 614,742 through 769,780\n", + "turn on 427,70 through 575,441\n", + "turn on 410,478 through 985,753\n", + "turn off 619,46 through 931,342\n", + "turn on 284,55 through 768,922\n", + "turn off 40,592 through 728,685\n", + "turn on 825,291 through 956,950\n", + "turn on 147,843 through 592,909\n", + "turn off 218,675 through 972,911\n", + "toggle 249,291 through 350,960\n", + "turn off 556,80 through 967,675\n", + "toggle 609,148 through 968,279\n", + "toggle 217,605 through 961,862\n", + "toggle 407,177 through 548,910\n", + "toggle 400,936 through 599,938\n", + "turn off 721,101 through 925,455\n", + "turn on 268,631 through 735,814\n", + "toggle 549,969 through 612,991\n", + "toggle 553,268 through 689,432\n", + "turn off 817,668 through 889,897\n", + "toggle 801,544 through 858,556\n", + "toggle 615,729 through 832,951\n", + "turn off 427,477 through 958,948\n", + "turn on 164,49 through 852,946\n", + "turn on 542,449 through 774,776\n", + "turn off 923,196 through 980,446\n", + "toggle 90,310 through 718,846\n", + "turn off 657,215 through 744,252\n", + "turn off 800,239 through 811,712\n", + "turn on 502,90 through 619,760\n", + "toggle 649,512 through 862,844\n", + "turn off 334,903 through 823,935\n", + "turn off 630,233 through 839,445\n", + "turn on 713,67 through 839,865\n", + "turn on 932,50 through 982,411\n", + "turn off 480,729 through 984,910\n", + "turn on 100,219 through 796,395\n", + "turn on 758,108 through 850,950\n", + "turn off 427,276 through 439,938\n", + "turn on 178,284 through 670,536\n", + "toggle 540,27 through 625,102\n", + "turn off 906,722 through 936,948\n", + "toggle 345,418 through 859,627\n", + "toggle 175,775 through 580,781\n", + "toggle 863,28 through 929,735\n", + "turn off 824,858 through 905,973\n", + "toggle 752,312 through 863,425\n", + "turn on 985,716 through 988,852\n", + "turn off 68,504 through 763,745\n", + "toggle 76,209 through 810,720\n", + "turn off 657,607 through 676,664\n", + "toggle 596,869 through 896,921\n", + "turn off 915,411 through 968,945\n", + "turn off 368,39 through 902,986\n", + "turn on 11,549 through 393,597\n", + "turn off 842,893 through 976,911\n", + "toggle 274,106 through 581,329\n", + "toggle 406,403 through 780,950\n", + "toggle 408,988 through 500,994\n", + "toggle 217,73 through 826,951\n", + "turn on 917,872 through 961,911\n", + "toggle 394,34 through 510,572\n", + "toggle 424,603 through 583,626\n", + "toggle 106,159 through 755,738\n", + "turn off 244,610 through 472,709\n", + "turn on 350,265 through 884,690\n", + "turn on 688,184 through 928,280\n", + "toggle 279,443 through 720,797\n", + "turn off 615,493 through 888,610\n", + "toggle 118,413 through 736,632\n", + "turn on 798,782 through 829,813\n", + "turn off 250,934 through 442,972\n", + "turn on 68,503 through 400,949\n", + "toggle 297,482 through 313,871\n", + "toggle 710,3 through 839,859\n", + "turn on 125,300 through 546,888\n", + "toggle 482,39 through 584,159\n", + "turn off 536,89 through 765,962\n", + "turn on 530,518 through 843,676\n", + "turn on 994,467 through 994,676\n", + "turn on 623,628 through 744,927\n", + "toggle 704,912 through 837,983\n", + "turn on 154,364 through 517,412\n", + "toggle 344,409 through 780,524\n", + "turn off 578,740 through 725,879\n", + "turn on 251,933 through 632,957\n", + "turn on 827,705 through 971,789\n", + "toggle 191,282 through 470,929\n", + "toggle 324,525 through 446,867\n", + "toggle 534,343 through 874,971\n", + "toggle 550,650 through 633,980\n", + "toggle 837,404 through 881,915\n", + "toggle 338,881 through 845,905\n", + "turn on 469,462 through 750,696\n", + "turn on 741,703 through 892,870\n", + "turn off 570,215 through 733,562\n", + "turn on 445,576 through 870,775\n", + "turn on 466,747 through 554,878\n", + "turn off 820,453 through 868,712\n", + "turn off 892,706 through 938,792\n", + "turn off 300,238 through 894,746\n", + "turn off 306,44 through 457,444\n", + "turn off 912,569 through 967,963\n", + "toggle 109,756 through 297,867\n", + "turn on 37,546 through 41,951\n", + "turn on 321,637 through 790,910\n", + "toggle 66,50 through 579,301\n", + "toggle 933,221 through 933,791\n", + "turn on 486,676 through 878,797\n", + "turn on 417,231 through 556,317\n", + "toggle 904,468 through 981,873\n", + "turn on 417,675 through 749,712\n", + "turn on 692,371 through 821,842\n", + "toggle 324,73 through 830,543\n", + "turn on 912,490 through 977,757\n", + "turn off 634,872 through 902,949\n", + "toggle 266,779 through 870,798\n", + "turn on 772,982 through 990,996\n", + "turn off 607,46 through 798,559\n", + "turn on 295,602 through 963,987\n", + "turn on 657,86 through 944,742\n", + "turn off 334,639 through 456,821\n", + "turn off 997,667 through 997,670\n", + "turn off 725,832 through 951,945\n", + "turn off 30,120 through 952,984\n", + "turn on 860,965 through 917,976\n", + "toggle 471,997 through 840,998\n", + "turn off 319,307 through 928,504\n", + "toggle 823,631 through 940,908\n", + "toggle 969,984 through 981,993\n", + "turn off 691,319 through 865,954\n", + "toggle 911,926 through 938,929\n", + "turn on 953,937 through 968,991\n", + "toggle 914,643 through 975,840\n", + "turn on 266,982 through 436,996\n", + "turn off 101,896 through 321,932\n", + "turn off 193,852 through 751,885\n", + "turn off 576,532 through 863,684\n", + "turn on 761,456 through 940,783\n", + "turn on 20,290 through 398,933\n", + "turn off 435,335 through 644,652\n", + "turn on 830,569 through 905,770\n", + "turn off 630,517 through 905,654\n", + "turn on 664,53 through 886,976\n", + "toggle 275,416 through 408,719\n", + "turn on 370,621 through 515,793\n", + "turn on 483,373 through 654,749\n", + "turn on 656,786 through 847,928\n", + "turn off 532,752 through 945,974\n", + "toggle 301,150 through 880,792\n", + "turn off 951,488 through 958,952\n", + "turn on 207,729 through 882,828\n", + "toggle 694,532 through 973,961\n", + "toggle 676,639 through 891,802\n", + "turn off 653,6 through 905,519\n", + "toggle 391,109 through 418,312\n", + "turn on 877,423 through 957,932\n", + "turn on 340,145 through 563,522\n", + "turn off 978,467 through 988,895\n", + "turn off 396,418 through 420,885\n", + "turn off 31,308 through 816,316\n", + "turn on 107,675 through 758,824\n", + "turn on 61,82 through 789,876\n", + "turn on 750,743 through 754,760\n", + "toggle 88,733 through 736,968\n", + "turn off 754,349 through 849,897\n", + "toggle 157,50 through 975,781\n", + "turn off 230,231 through 865,842\n", + "turn off 516,317 through 630,329\n", + "turn off 697,820 through 829,903\n", + "turn on 218,250 through 271,732\n", + "toggle 56,167 through 404,431\n", + "toggle 626,891 through 680,927\n", + "toggle 370,207 through 791,514\n", + "toggle 860,74 through 949,888\n", + "turn on 416,527 through 616,541\n", + "turn off 745,449 through 786,908\n", + "turn on 485,554 through 689,689\n", + "turn on 586,62 through 693,141\n", + "toggle 506,759 through 768,829\n", + "turn on 473,109 through 929,166\n", + "turn on 760,617 through 773,789\n", + "toggle 595,683 through 618,789\n", + "turn off 210,775 through 825,972\n", + "toggle 12,426 through 179,982\n", + "turn on 774,539 through 778,786\n", + "turn on 102,498 through 121,807\n", + "turn off 706,897 through 834,965\n", + "turn off 678,529 through 824,627\n", + "turn on 7,765 through 615,870\n", + "turn off 730,872 through 974,943\n", + "turn off 595,626 through 836,711\n", + "turn off 215,424 through 841,959\n", + "toggle 341,780 through 861,813\n", + "toggle 507,503 through 568,822\n", + "turn on 252,603 through 349,655\n", + "toggle 93,521 through 154,834\n", + "turn on 565,682 through 951,954\n", + "turn on 544,318 through 703,418\n", + "toggle 756,953 through 891,964\n", + "turn on 531,123 through 856,991\n", + "turn on 148,315 through 776,559\n", + "turn off 925,835 through 963,971\n", + "turn on 895,944 through 967,964\n", + "turn off 102,527 through 650,747\n", + "toggle 626,105 through 738,720\n", + "turn off 160,75 through 384,922\n", + "toggle 813,724 through 903,941\n", + "turn on 207,107 through 982,849\n", + "toggle 750,505 through 961,697\n", + "toggle 105,410 through 885,819\n", + "turn on 226,104 through 298,283\n", + "turn off 224,604 through 508,762\n", + "turn on 477,368 through 523,506\n", + "turn off 477,901 through 627,936\n", + "turn off 887,131 through 889,670\n", + "turn on 896,994 through 938,999\n", + "toggle 401,580 through 493,728\n", + "toggle 987,184 through 991,205\n", + "turn on 821,643 through 882,674\n", + "toggle 784,940 through 968,959\n", + "turn off 251,293 through 274,632\n", + "turn off 339,840 through 341,844\n", + "turn off 675,351 through 675,836\n", + "toggle 918,857 through 944,886\n", + "toggle 70,253 through 918,736\n", + "turn off 612,604 through 772,680\n", + "turn off 277,40 through 828,348\n", + "toggle 692,139 through 698,880\n", + "toggle 124,446 through 883,453\n", + "toggle 969,932 through 990,945\n", + "toggle 855,692 through 993,693\n", + "toggle 722,472 through 887,899\n", + "toggle 978,149 through 985,442\n", + "toggle 837,540 through 916,889\n", + "turn off 612,2 through 835,82\n", + "toggle 560,767 through 878,856\n", + "turn on 461,734 through 524,991\n", + "toggle 206,824 through 976,912\n", + "turn on 826,610 through 879,892\n", + "turn on 577,699 through 956,933\n", + "turn off 9,250 through 50,529\n", + "turn off 77,657 through 817,677\n", + "turn on 68,419 through 86,426\n", + "turn on 991,720 through 992,784\n", + "turn on 668,20 through 935,470\n", + "turn off 133,418 through 613,458\n", + "turn off 487,286 through 540,328\n", + "toggle 247,874 through 840,955\n", + "toggle 301,808 through 754,970\n", + "turn off 34,194 through 578,203\n", + "turn off 451,49 through 492,921\n", + "turn on 907,256 through 912,737\n", + "turn off 479,305 through 702,587\n", + "turn on 545,583 through 732,749\n", + "toggle 11,16 through 725,868\n", + "turn on 965,343 through 986,908\n", + "turn on 674,953 through 820,965\n", + "toggle 398,147 through 504,583\n", + "turn off 778,194 through 898,298\n", + "turn on 179,140 through 350,852\n", + "turn off 241,118 through 530,832\n", + "turn off 41,447 through 932,737\n", + "turn off 820,663 through 832,982\n", + "turn on 550,460 through 964,782\n", + "turn on 31,760 through 655,892\n", + "toggle 628,958 through 811,992\"\"\"" + ] + }, + { + "cell_type": "code", + "execution_count": 181, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[[False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False]]" + ] + }, + "execution_count": 181, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "grid = [list([False]*10) for _ in range(10)]\n", + "grid" + ] + }, + { + "cell_type": "code", + "execution_count": 182, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[[False, False, False, False, False, False, False, False, False, False],\n", + " [False, True, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False]]" + ] + }, + "execution_count": 182, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "grid[1][1] = True\n", + "grid" + ] + }, + { + "cell_type": "code", + "execution_count": 185, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def print_grid(grid):\n", + " print('\\n'.join(''.join('*' if l else '.' for l in line) for line in grid))" + ] + }, + { + "cell_type": "code", + "execution_count": 186, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "..........\n", + ".*........\n", + "..........\n", + "..........\n", + "..........\n", + "..........\n", + "..........\n", + "..........\n", + "..........\n", + "..........\n" + ] + } + ], + "source": [ + "print_grid(grid)" + ] + }, + { + "cell_type": "code", + "execution_count": 187, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def turn_on(r1, c1, r2, c2, grid):\n", + " for r in range(r1, r2+1):\n", + " for c in range(c1, c2+1):\n", + " grid[r][c] = True " + ] + }, + { + "cell_type": "code", + "execution_count": 188, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def turn_off(r1, c1, r2, c2, grid):\n", + " for r in range(r1, r2+1):\n", + " for c in range(c1, c2+1):\n", + " grid[r][c] = False " + ] + }, + { + "cell_type": "code", + "execution_count": 189, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def toggle(r1, c1, r2, c2, grid):\n", + " for r in range(r1, r2+1):\n", + " for c in range(c1, c2+1):\n", + " grid[r][c] = not grid[r][c] " + ] + }, + { + "cell_type": "code", + "execution_count": 190, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "****......\n", + "****......\n", + "****......\n", + "**..***...\n", + "**........\n", + "**.....**.\n", + "****...**.\n", + ".........*\n", + ".......***\n", + ".......***\n" + ] + } + ], + "source": [ + "grid = [list([False]*10) for _ in range(10)]\n", + "turn_on(3, 2, 5, 6, grid)\n", + "turn_off(4, 4, 7, 7, grid)\n", + "toggle(0, 0, 6, 3, grid)\n", + "turn_on(7, 7, 9, 9, grid)\n", + "toggle(5, 7, 7, 8, grid)\n", + "print_grid(grid)" + ] + }, + { + "cell_type": "code", + "execution_count": 191, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "36" + ] + }, + "execution_count": 191, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sum(sum(line) for line in grid)" + ] + }, + { + "cell_type": "code", + "execution_count": 192, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def parse(line):\n", + " words = line.split(' ')\n", + " if line.startswith('turn'):\n", + " command = words[1]\n", + " s = words[2].split(',')\n", + " f = words[4].split(',')\n", + " else:\n", + " command = words[0]\n", + " s = words[1].split(',')\n", + " f = words[3].split(',')\n", + " # print(command, s, f)\n", + " r1 = min(int(s[0]), int(f[0]))\n", + " r2 = max(int(s[0]), int(f[0]))\n", + " c1 = min(int(s[1]), int(f[1]))\n", + " c2 = max(int(s[1]), int(f[1]))\n", + " return command, r1, c1, r2, c2" + ] + }, + { + "cell_type": "code", + "execution_count": 193, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "('toggle', 489, 959, 759, 964)" + ] + }, + "execution_count": 193, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "parse('toggle 489,959 through 759,964')" + ] + }, + { + "cell_type": "code", + "execution_count": 194, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def do_line(line, grid):\n", + " command, r1, c1, r2, c2 = parse(line)\n", + " if command == 'on':\n", + " turn_on(r1, c1, r2, c2, grid)\n", + " elif command == 'off':\n", + " turn_off(r1, c1, r2, c2, grid)\n", + " else:\n", + " toggle(r1, c1, r2, c2, grid)" + ] + }, + { + "cell_type": "code", + "execution_count": 195, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "grid = [list([False]*1000) for _ in range(1000)]" + ] + }, + { + "cell_type": "code", + "execution_count": 196, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "569999" + ] + }, + "execution_count": 196, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "grid = [list([False]*1000) for _ in range(1000)]\n", + "for line in pi6.splitlines():\n", + " do_line(line.strip(), grid)\n", + "sum(sum(line) for line in grid)" + ] + }, + { + "cell_type": "code", + "execution_count": 175, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "turn on 489,959 through 759,964\n" + ] + }, + { + "data": { + "text/plain": [ + "1626" + ] + }, + "execution_count": 175, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "grid = [list([False]*1000) for _ in range(1000)]\n", + "do_line(pi6.splitlines()[0].strip(), grid)\n", + "print(pi6.splitlines()[0].strip())\n", + "sum(sum(line) for line in grid)" + ] + }, + { + "cell_type": "code", + "execution_count": 171, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "1626" + ] + }, + "execution_count": 171, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "((759-489)+1)*((964-959)+1)" + ] + }, + { + "cell_type": "code", + "execution_count": 197, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def do_line2(line, grid):\n", + " command, r1, c1, r2, c2 = parse(line)\n", + " if command == 'on':\n", + " turn_on2(r1, c1, r2, c2, grid)\n", + " elif command == 'off':\n", + " turn_off2(r1, c1, r2, c2, grid)\n", + " else:\n", + " toggle2(r1, c1, r2, c2, grid)" + ] + }, + { + "cell_type": "code", + "execution_count": 198, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def turn_on2(r1, c1, r2, c2, grid):\n", + " for r in range(r1, r2+1):\n", + " for c in range(c1, c2+1):\n", + " grid[r][c] +=1 \n", + "\n", + "def turn_off2(r1, c1, r2, c2, grid):\n", + " for r in range(r1, r2+1):\n", + " for c in range(c1, c2+1):\n", + " grid[r][c] -= 1\n", + " if grid[r][c] < 0:\n", + " grid[r][c] = 0\n", + "\n", + "def toggle2(r1, c1, r2, c2, grid):\n", + " for r in range(r1, r2+1):\n", + " for c in range(c1, c2+1):\n", + " grid[r][c] += 2" + ] + }, + { + "cell_type": "code", + "execution_count": 203, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "17836115" + ] + }, + "execution_count": 203, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "grid2 = [list([0]*1000) for _ in range(1000)]\n", + "for line in pi6.splitlines():\n", + " do_line2(line.strip(), grid2)\n", + "sum(sum(line) for line in grid2)" + ] + }, + { + "cell_type": "code", + "execution_count": 201, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", + " [0, 2, 0, 0, 0, 0, 0, 0, 0, 0],\n", + " [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", + " [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", + " [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", + " [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", + " [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", + " [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", + " [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", + " [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]" + ] + }, + "execution_count": 201, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "grid = [list([0]*10) for _ in range(10)]\n", + "grid[1][1] += 2\n", + "grid" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.4.3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/advent01.ipynb b/advent01.ipynb new file mode 100644 index 0000000..efb9efc --- /dev/null +++ b/advent01.ipynb @@ -0,0 +1,1128 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'()(((()))(()()()((((()(((())(()(()((((((()(()(((())))((()(((()))((())(()((()()()()(((())(((((((())))()()(()(()(())(((((()()()((())(((((()()))))()(())(((())(())((((((())())))(()())))()))))()())()())((()()((()()()()(()((((((((()()())((()()(((((()(((())((())(()))()((((()((((((((())()((()())(())((()))())((((()())(((((((((((()()(((((()(()))())(((()(()))())((()(()())())())(()(((())(())())()()(()(()((()))((()))))((((()(((()))))((((()(()(()())())()(((()((((())((((()(((()()(())()()()())((()((((((()((()()))()((()))()(()()((())))(((()(((()))((()((()(()))(((()()(()(()()()))))()()(((()(((())())))))((()(((())()(()(())((()())))((((())))(()(()(()())()((()())))(((()((()(())()()((()((())(()()((())(())()))()))((()(())()))())(((((((()(()()(()(())())))))))(()((((((())((((())((())())(()()))))()(())(()())()())((())(()))))(()))(()((()))()(()((((((()()()()((((((((()(()(())((()()(()()))(())()())()((())))()))()())(((()))(())()(())()))()((()((()(()()())(())()()()((())())))((()()(()()((()(())()()())(((()(()()))))(())))(()(()())()))()()))))))()))))((((((())))())))(()(())())(()())))))(()))()))))))()((()))))()))))(()(()((()())())(()()))))(((())()))())())())(((()(()()))(())()(())(())((((((()()))))((()(()))))))(()))())(((()()(()))()())()()()())))))))))))))(())(()))(()))((()(())(()())(())())(()())(())()()(()())))()()()))(())())()))())())(())((())))))))(())))(())))))()))))((())(()(((()))))(()))()((()(())))(()())(((((()))()())()()))))()))))()))())(()(()()()))()))))))((()))))))))))()((()))((()(())((())()()(()()))()(()))))()()(()))()))(((())))(())()((())(())(()())()())())))))))())))()((())))()))(()))()()))(((((((()))())(()()))(()()(()))()(()((()())()))))))(((()()()())))(())()))()())(()()))()()))))))))(())))()))()()))))))()))()())))()(())(())))))()(())()()(()()))))())((()))))()))))(()(((((()))))))))())))())()(())()()))))(())))())()()())()()())()(()))))()))()))))))))())))((()))()))()))())))()())()()())))())))(()((())()((()))())))))())()(())((())))))))))))())()())(())())())(()))(()))()))())(()(())())()())()()(()))))(()(())))))))(())))())(())))))))())()()(())())())))(())))))()))()(()())()(()))())())))))()()(()))()))))())))))))))()))))()))))))())()())()()))))()())))())))))))))))()()))))()()(((()))()()(())()))))((()))))(()))(())())))(())()))))))(()))()))))(())())))))()))(()())))))))))))))())))))))))()((()())(()())))))))((()))))(())(())))()(()())())))())())(()()()())))()))))))())))))())()()())))))))))))()()(()))))()())()))((()())(()))))()(()))))))))))()())())(((())(()))))())()))()))()))))))()))))))(()))))()))))()(())))(())))(()))())()()(()()))()))(()()))))))))()))(()))())(()()(()(()())()()))()))))))))(())))))((()()(()))())())))))()))())(()())()()))())))()(()()()()))((())())))())()(()()))()))))))))(()))(())))()))))(()(()())(()))))()())())()))()()))())))))))))))())()))))))()))))))))())))))()))))())(()())))(())()))())())))))()()(()()())(()())))()()))(((()))(()()()))))()))))()))))((())))()((((((()()))))))())))))))))))(((()))))))))))))(())())))))())(()))))))(()))((()))())))()(()((()))()))()))))))))))())()))()(()()))))())))())(())()(()))()))())(()))()))))(()()))()()(())))))()))(())(()(()()))(()()())))))(((()))))))()))))))))))))(())(()))))()())())()()((()()))())))))(()))))())))))))()()()))))))))())))()(((()()))(())))))(((())())))))((()))()(()))(()))))(()())))(()))())))))()))))(())(())))()((()))(())())))()()))()))))))))()))(()()()(()()()(()))())(())()())(((()))(())))))))))(((()())))()()))))))))()(())(()))()((((())(())(()())))()))(((())()()()))((()))(()))())())))())))(()))())()())())(()(())())()()()(())))())(())))(())))(())()))()))(()((()))))))))())(()))))))())(()()))()()))()(()(()())))()()(()((()((((((()))(())))()()()))())()))((()()(()))())((()(()(()))(()()))))()())))()))()())))))))()()((()())(())))()))(()))(())(()))())(()(())))()()))))))(((()(((()()))()(()(())())((()()))()))()))()))()(()()()(()))((()())()(())))()()))(((())()()())(())()((()()()()(()(())(()()))()(((((()())))((())))))(()()()))))(((()(())))()))((()((()(())()(()((())))((()())()(()))(((()())()()(()))(())(((()((()())()((())()())(((()()))((()((())(()))(()())(()()()))((()))(())(()((()()())((()))(())))(())(())(())))(()())))(((((()(()(((((()())((((()(()())(())(()()(((())((()(((()()(((()()((((((())))())(()((((((()(()))()))()()((()((()))))()(()()(()((()()))))))(((((()(((((())()()()(())())))))))()))((()()(())))(())(()()()())))))(()((((())))))))()()(((()(()(()(()(()())()()()(((((((((()()())()(()))((()()()()()(((((((()())()((())()))((((((()(()(()(()())(((()(((((((()(((())(((((((((())(())())()))((()(()))(((()()())(())(()(()()(((()(())()))())))(())((((((())(()()())()()(((()(((())(()(((())(((((((()(((((((((()))(())(()(()(()))))((()))()(())())())((()(()((()()))((()()((()(())(())(()((())(((())(((()()()((((((()()(())((((())()))))(())((()(()((())))(((((()(()()())())((())())))((())((()((()()((((((())(((()()(()())())(()(()))(()(()))())())()(((((((()(((()(())()()((())((()(()()((()(()()(((((((((((())((())((((((())((()((((()(()((((()(((((((())()((()))))())()((()((((()(()(((()((()())))(())())(((()(((())((((((()(((((((((()()(())))(()(((((()((((()())))((()((()((()(()()(((())((((((((((((()(((())(()(((((()))(()()(()()()()()()((())(((((((())(((((())))))())()(()()(()(()(((()()(((((())(()((()((()(((()()((()((((())()))()((((())(())))()())(((())(())(()()((()(((()()((((((((((()()(()())())(((((((((())((((()))()()((((())(()((((()(((())())(((((((((((()((((())))(())(()(((()(((()((())(((((()((()()(()(()()((((((()((((()((()(()((()(()((((((()))))()()(((((()((()(()(())()))(())(((((((()((((()())(()((()((()(()))())))(())((()))))(((((((()()()())(()))(()()((()())()((()((()()()(()(()()))(()())(())(((((()(((((((((((()((()(((()(((((((()()((((((()(((((()(()((()(((((())((((((()))((((())((()()((())(((())()(((((()()(((((()((()(()(((((((()(((((()((()((()((())(())((())(()))()()))(()()(()(()()(((((((()(((()(((())()(((((()((((((()())((((())()((()((()(()()())(()))((((()()((((((()((()(()(()((((()((()((())((((((()(()(())((((((()((((((((((()((())()))()(()(()(((((()()()))((())))()(()((((((((((((((()(((()((((()((())((()((()(((()()(()(((()((())(()()())))()(()(()(((((()()(()(()((((()(((((())()(()(()))(((((()()(((()()(())((((((((((((((())((())(((((((((((())()()()(())()(()(()(((((((((())(((()))(()()())(()((((()(())(((((()())(())((((((((())()((((()((((((())(()((()(())(((()((((()))(((((((((()()))((((()(())()()()(())(()((())((()()))()(((())(((((())((((((()()))(((((((((()((((((())))(((((((()((()(()(())))())(()(()))()(((((()())(()))()(()(())(((()))))())()())))(((((()))())()((()(()))))((()()()((((((()))()()((((((((())((()(()(((()(()((())((()())(()((((())(()(((()()()(()(()()))())())((((((((((())())((()))()((())(())(())))())()(()()(())))())(()))(((()(()()(((()(((())))()(((()(())()((((((())()))()))()((((((()(()(((((()())))()))))())()()(((()(((((())((()()(()((()((()(()(()(())))(()()()()((()(())(((()((()))((((()))())(())))())(()))()()()())()))(((()()())()((())))(())(()()()()(()())((()(()()((((())))((()((()(())((()(()((())()(()()(((()())()()())((()))((())(((()()(())))()()))(((()((())()(((((()())(())((())()())())((((((()(()(((((()))(()('" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pi = open('advent01.txt').read().strip()\n", + "pi" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "138" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len([c for c in pi if c == '(']) - len([c for c in pi if c == ')'])" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " 1,\n", + " -1,\n", + " 1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " -1,\n", + " 1,\n", + " ...]" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "deltas = [1 if c == '(' else -1 for c in pi]\n", + "deltas" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "1771" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import itertools\n", + "\n", + "len(list(itertools.takewhile(lambda f: f >= -1, itertools.accumulate(deltas))))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.4.3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/advent01.txt b/advent01.txt new file mode 100644 index 0000000..2d4ad8f --- /dev/null +++ b/advent01.txt @@ -0,0 +1 @@ +()(((()))(()()()((((()(((())(()(()((((((()(()(((())))((()(((()))((())(()((()()()()(((())(((((((())))()()(()(()(())(((((()()()((())(((((()()))))()(())(((())(())((((((())())))(()())))()))))()())()())((()()((()()()()(()((((((((()()())((()()(((((()(((())((())(()))()((((()((((((((())()((()())(())((()))())((((()())(((((((((((()()(((((()(()))())(((()(()))())((()(()())())())(()(((())(())())()()(()(()((()))((()))))((((()(((()))))((((()(()(()())())()(((()((((())((((()(((()()(())()()()())((()((((((()((()()))()((()))()(()()((())))(((()(((()))((()((()(()))(((()()(()(()()()))))()()(((()(((())())))))((()(((())()(()(())((()())))((((())))(()(()(()())()((()())))(((()((()(())()()((()((())(()()((())(())()))()))((()(())()))())(((((((()(()()(()(())())))))))(()((((((())((((())((())())(()()))))()(())(()())()())((())(()))))(()))(()((()))()(()((((((()()()()((((((((()(()(())((()()(()()))(())()())()((())))()))()())(((()))(())()(())()))()((()((()(()()())(())()()()((())())))((()()(()()((()(())()()())(((()(()()))))(())))(()(()())()))()()))))))()))))((((((())))())))(()(())())(()())))))(()))()))))))()((()))))()))))(()(()((()())())(()()))))(((())()))())())())(((()(()()))(())()(())(())((((((()()))))((()(()))))))(()))())(((()()(()))()())()()()())))))))))))))(())(()))(()))((()(())(()())(())())(()())(())()()(()())))()()()))(())())()))())())(())((())))))))(())))(())))))()))))((())(()(((()))))(()))()((()(())))(()())(((((()))()())()()))))()))))()))())(()(()()()))()))))))((()))))))))))()((()))((()(())((())()()(()()))()(()))))()()(()))()))(((())))(())()((())(())(()())()())())))))))())))()((())))()))(()))()()))(((((((()))())(()()))(()()(()))()(()((()())()))))))(((()()()())))(())()))()())(()()))()()))))))))(())))()))()()))))))()))()())))()(())(())))))()(())()()(()()))))())((()))))()))))(()(((((()))))))))())))())()(())()()))))(())))())()()())()()())()(()))))()))()))))))))())))((()))()))()))())))()())()()())))())))(()((())()((()))())))))())()(())((())))))))))))())()())(())())())(()))(()))()))())(()(())())()())()()(()))))(()(())))))))(())))())(())))))))())()()(())())())))(())))))()))()(()())()(()))())())))))()()(()))()))))())))))))))()))))()))))))())()())()()))))()())))())))))))))))()()))))()()(((()))()()(())()))))((()))))(()))(())())))(())()))))))(()))()))))(())())))))()))(()())))))))))))))())))))))))()((()())(()())))))))((()))))(())(())))()(()())())))())())(()()()())))()))))))())))))())()()())))))))))))()()(()))))()())()))((()())(()))))()(()))))))))))()())())(((())(()))))())()))()))()))))))()))))))(()))))()))))()(())))(())))(()))())()()(()()))()))(()()))))))))()))(()))())(()()(()(()())()()))()))))))))(())))))((()()(()))())())))))()))())(()())()()))())))()(()()()()))((())())))())()(()()))()))))))))(()))(())))()))))(()(()())(()))))()())())()))()()))())))))))))))())()))))))()))))))))())))))()))))())(()())))(())()))())())))))()()(()()())(()())))()()))(((()))(()()()))))()))))()))))((())))()((((((()()))))))())))))))))))(((()))))))))))))(())())))))())(()))))))(()))((()))())))()(()((()))()))()))))))))))())()))()(()()))))())))())(())()(()))()))())(()))()))))(()()))()()(())))))()))(())(()(()()))(()()())))))(((()))))))()))))))))))))(())(()))))()())())()()((()()))())))))(()))))())))))))()()()))))))))())))()(((()()))(())))))(((())())))))((()))()(()))(()))))(()())))(()))())))))()))))(())(())))()((()))(())())))()()))()))))))))()))(()()()(()()()(()))())(())()())(((()))(())))))))))(((()())))()()))))))))()(())(()))()((((())(())(()())))()))(((())()()()))((()))(()))())())))())))(()))())()())())(()(())())()()()(())))())(())))(())))(())()))()))(()((()))))))))())(()))))))())(()()))()()))()(()(()())))()()(()((()((((((()))(())))()()()))())()))((()()(()))())((()(()(()))(()()))))()())))()))()())))))))()()((()())(())))()))(()))(())(()))())(()(())))()()))))))(((()(((()()))()(()(())())((()()))()))()))()))()(()()()(()))((()())()(())))()()))(((())()()())(())()((()()()()(()(())(()()))()(((((()())))((())))))(()()()))))(((()(())))()))((()((()(())()(()((())))((()())()(()))(((()())()()(()))(())(((()((()())()((())()())(((()()))((()((())(()))(()())(()()()))((()))(())(()((()()())((()))(())))(())(())(())))(()())))(((((()(()(((((()())((((()(()())(())(()()(((())((()(((()()(((()()((((((())))())(()((((((()(()))()))()()((()((()))))()(()()(()((()()))))))(((((()(((((())()()()(())())))))))()))((()()(())))(())(()()()())))))(()((((())))))))()()(((()(()(()(()(()())()()()(((((((((()()())()(()))((()()()()()(((((((()())()((())()))((((((()(()(()(()())(((()(((((((()(((())(((((((((())(())())()))((()(()))(((()()())(())(()(()()(((()(())()))())))(())((((((())(()()())()()(((()(((())(()(((())(((((((()(((((((((()))(())(()(()(()))))((()))()(())())())((()(()((()()))((()()((()(())(())(()((())(((())(((()()()((((((()()(())((((())()))))(())((()(()((())))(((((()(()()())())((())())))((())((()((()()((((((())(((()()(()())())(()(()))(()(()))())())()(((((((()(((()(())()()((())((()(()()((()(()()(((((((((((())((())((((((())((()((((()(()((((()(((((((())()((()))))())()((()((((()(()(((()((()())))(())())(((()(((())((((((()(((((((((()()(())))(()(((((()((((()())))((()((()((()(()()(((())((((((((((((()(((())(()(((((()))(()()(()()()()()()((())(((((((())(((((())))))())()(()()(()(()(((()()(((((())(()((()((()(((()()((()((((())()))()((((())(())))()())(((())(())(()()((()(((()()((((((((((()()(()())())(((((((((())((((()))()()((((())(()((((()(((())())(((((((((((()((((())))(())(()(((()(((()((())(((((()((()()(()(()()((((((()((((()((()(()((()(()((((((()))))()()(((((()((()(()(())()))(())(((((((()((((()())(()((()((()(()))())))(())((()))))(((((((()()()())(()))(()()((()())()((()((()()()(()(()()))(()())(())(((((()(((((((((((()((()(((()(((((((()()((((((()(((((()(()((()(((((())((((((()))((((())((()()((())(((())()(((((()()(((((()((()(()(((((((()(((((()((()((()((())(())((())(()))()()))(()()(()(()()(((((((()(((()(((())()(((((()((((((()())((((())()((()((()(()()())(()))((((()()((((((()((()(()(()((((()((()((())((((((()(()(())((((((()((((((((((()((())()))()(()(()(((((()()()))((())))()(()((((((((((((((()(((()((((()((())((()((()(((()()(()(((()((())(()()())))()(()(()(((((()()(()(()((((()(((((())()(()(()))(((((()()(((()()(())((((((((((((((())((())(((((((((((())()()()(())()(()(()(((((((((())(((()))(()()())(()((((()(())(((((()())(())((((((((())()((((()((((((())(()((()(())(((()((((()))(((((((((()()))((((()(())()()()(())(()((())((()()))()(((())(((((())((((((()()))(((((((((()((((((())))(((((((()((()(()(())))())(()(()))()(((((()())(()))()(()(())(((()))))())()())))(((((()))())()((()(()))))((()()()((((((()))()()((((((((())((()(()(((()(()((())((()())(()((((())(()(((()()()(()(()()))())())((((((((((())())((()))()((())(())(())))())()(()()(())))())(()))(((()(()()(((()(((())))()(((()(())()((((((())()))()))()((((((()(()(((((()())))()))))())()()(((()(((((())((()()(()((()((()(()(()(())))(()()()()((()(())(((()((()))((((()))())(())))())(()))()()()())()))(((()()())()((())))(())(()()()()(()())((()(()()((((())))((()((()(())((()(()((())()(()()(((()())()()())((()))((())(((()()(())))()()))(((()((())()(((((()())(())((())()())())((((((()(()(((((()))(()( diff --git a/advent02.ipynb b/advent02.ipynb new file mode 100644 index 0000000..032a291 --- /dev/null +++ b/advent02.ipynb @@ -0,0 +1,126 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "pi2 = open('advent02.txt').read().strip()" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['24x25x17', '14x6x11']" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pi2.splitlines()[-2:]" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "1588178" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "total = 0\n", + "for package in pi2.splitlines():\n", + " dims = [int(d) for d in package.split('x')]\n", + " areas = [dims[0]*dims[1], dims[0]*dims[2], dims[1]*dims[2]]\n", + " slack = min(areas)\n", + " paper = slack + sum(areas)*2\n", + " total += paper\n", + "total" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "3783758" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "total = 0\n", + "for package in pi2.splitlines():\n", + " dims = [int(d) for d in package.split('x')]\n", + " perims = [p*2 for p in [dims[0]+dims[1], dims[0]+dims[2], dims[1]+dims[2]]]\n", + " length = min(perims)\n", + " vol = dims[0] * dims[1] * dims[2]\n", + " ribbon = length + vol\n", + " total += ribbon\n", + "total" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.4.3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/advent02.txt b/advent02.txt new file mode 100644 index 0000000..908022e --- /dev/null +++ b/advent02.txt @@ -0,0 +1,1000 @@ +3x11x24 +13x5x19 +1x9x27 +24x8x21 +6x8x17 +19x18x22 +10x9x12 +12x2x5 +26x6x11 +9x23x15 +12x8x17 +13x29x10 +28x18x6 +22x28x26 +1x5x11 +29x26x12 +8x28x29 +27x4x21 +12x7x16 +7x4x23 +15x24x8 +15x14x2 +11x6x29 +28x19x9 +10x3x1 +5x20x13 +10x25x1 +22x17x7 +16x29x3 +18x22x8 +18x11x19 +21x24x20 +4x7x17 +22x27x12 +1x26x6 +5x27x24 +29x21x3 +25x30x2 +21x26x2 +10x24x27 +10x16x28 +18x16x23 +6x5x26 +19x12x20 +6x24x25 +11x20x7 +4x8x5 +2x13x11 +11x17x1 +13x24x6 +22x29x16 +4x24x20 +10x25x10 +12x29x23 +23x27x12 +11x21x9 +13x2x6 +15x30x2 +8x26x24 +24x7x30 +22x22x8 +29x27x8 +28x23x27 +13x16x14 +9x28x20 +21x4x30 +21x20x20 +11x17x30 +9x14x22 +20x2x6 +10x11x14 +1x8x23 +23x19x19 +26x10x13 +21x12x12 +25x7x24 +1x28x17 +20x23x9 +2x24x27 +20x24x29 +1x3x10 +5x20x14 +25x21x3 +15x5x22 +14x17x19 +27x3x18 +29x23x19 +14x21x19 +20x8x3 +22x27x12 +24x15x18 +9x10x19 +29x25x28 +14x22x6 +4x19x28 +4x24x14 +17x19x17 +7x19x29 +28x8x26 +7x20x16 +11x26x29 +2x18x3 +12x7x18 +11x15x21 +24x7x26 +2x22x23 +2x30x5 +1x19x8 +15x29x10 +15x26x22 +20x16x14 +25x29x22 +3x13x19 +1x12x30 +3x15x27 +19x9x11 +30x8x21 +26x12x20 +11x17x19 +17x25x1 +19x24x12 +30x6x20 +11x19x18 +18x15x29 +18x8x9 +25x15x5 +15x6x26 +13x27x19 +23x24x12 +3x15x28 +17x10x10 +15x4x7 +15x27x7 +21x8x11 +9x18x2 +7x20x20 +17x23x12 +2x19x1 +7x26x26 +13x23x8 +10x3x12 +11x1x9 +1x11x19 +25x14x26 +16x10x15 +7x6x11 +8x1x27 +20x28x17 +3x25x9 +30x7x5 +17x17x4 +23x25x27 +23x8x5 +13x11x1 +15x10x21 +22x16x1 +12x15x28 +27x18x26 +25x18x5 +21x3x27 +15x25x5 +29x27x19 +11x10x12 +22x16x21 +11x8x18 +6x10x23 +21x21x2 +13x27x28 +2x5x20 +23x16x20 +1x21x7 +22x2x13 +11x10x4 +7x3x4 +19x2x5 +21x11x1 +7x27x26 +12x4x23 +12x3x15 +25x7x4 +20x7x15 +16x5x11 +1x18x26 +11x27x10 +17x6x24 +19x13x16 +6x3x11 +4x19x18 +16x15x15 +1x11x17 +19x11x29 +18x19x1 +1x25x7 +8x22x14 +15x6x19 +5x30x18 +30x24x22 +11x16x2 +21x29x19 +20x29x11 +27x1x18 +20x5x30 +12x4x28 +3x9x30 +26x20x15 +18x25x18 +20x28x28 +21x5x3 +20x21x25 +19x27x22 +8x27x9 +1x5x15 +30x6x19 +16x5x15 +18x30x21 +4x15x8 +9x3x28 +18x15x27 +25x11x6 +17x22x15 +18x12x18 +14x30x30 +1x7x23 +27x21x12 +15x7x18 +16x17x24 +11x12x19 +18x15x21 +6x18x15 +2x21x4 +12x9x14 +19x7x25 +22x3x1 +29x19x7 +30x25x7 +6x27x27 +5x13x9 +21x4x18 +13x1x16 +11x21x25 +27x20x27 +14x25x9 +23x11x15 +22x10x26 +15x16x4 +14x16x21 +1x1x24 +17x27x3 +25x28x16 +12x2x29 +9x19x28 +12x7x17 +6x9x19 +15x14x24 +25x21x23 +26x27x25 +7x18x13 +15x10x6 +22x28x2 +15x2x14 +3x24x18 +30x22x7 +18x27x17 +29x18x7 +20x2x4 +4x20x26 +23x30x15 +5x7x3 +4x24x12 +24x30x20 +26x18x17 +6x28x3 +29x19x29 +14x10x4 +15x5x23 +12x25x4 +7x15x19 +26x21x19 +18x2x23 +19x20x3 +3x13x9 +29x21x24 +26x13x29 +30x27x4 +20x10x29 +21x18x8 +7x26x10 +29x16x21 +22x5x11 +17x15x2 +7x29x5 +6x18x15 +23x6x14 +10x30x14 +26x6x16 +24x13x25 +17x29x20 +4x27x19 +28x12x11 +23x20x3 +22x6x20 +29x9x19 +10x16x22 +30x26x4 +29x26x11 +2x11x15 +1x3x30 +30x30x29 +9x1x3 +30x13x16 +20x4x5 +23x28x11 +24x27x1 +4x25x10 +9x3x6 +14x4x15 +4x5x25 +27x14x13 +20x30x3 +28x15x25 +5x19x2 +10x24x29 +29x30x18 +30x1x25 +7x7x15 +1x13x16 +23x18x4 +1x28x8 +24x11x8 +22x26x19 +30x30x14 +2x4x13 +27x20x26 +16x20x17 +11x12x13 +28x2x17 +15x26x13 +29x15x25 +30x27x9 +2x6x25 +10x26x19 +16x8x23 +12x17x18 +26x14x22 +13x17x4 +27x27x29 +17x13x22 +9x8x3 +25x15x20 +14x13x16 +8x7x13 +12x4x21 +27x16x15 +6x14x5 +28x29x17 +23x17x25 +10x27x28 +1x28x21 +18x2x30 +25x30x16 +25x21x7 +2x3x4 +9x6x13 +19x6x10 +28x17x8 +13x24x28 +24x12x7 +5x19x5 +18x10x27 +16x1x6 +12x14x30 +1x2x28 +23x21x2 +13x3x23 +9x22x10 +10x17x2 +24x20x11 +30x6x14 +28x1x16 +24x20x1 +28x7x7 +1x24x21 +14x9x7 +22x8x15 +20x1x21 +6x3x7 +7x26x14 +5x7x28 +5x4x4 +15x7x28 +30x16x23 +7x26x2 +1x2x30 +24x28x20 +5x17x28 +4x15x20 +15x26x2 +1x3x23 +22x30x24 +9x20x16 +7x15x2 +6x21x18 +21x21x29 +29x10x10 +4x3x23 +23x2x18 +29x24x14 +29x29x16 +22x28x24 +21x18x24 +16x21x6 +3x9x22 +9x18x4 +22x9x9 +12x9x13 +18x21x14 +7x8x29 +28x28x14 +1x6x24 +11x11x3 +8x28x6 +11x16x10 +9x16x16 +6x6x19 +21x5x12 +15x17x12 +3x6x29 +19x1x26 +10x30x25 +24x26x21 +1x10x18 +6x1x16 +4x17x27 +17x11x27 +15x15x21 +14x23x1 +8x9x30 +22x22x25 +20x27x22 +12x7x9 +9x26x19 +26x25x12 +8x8x16 +28x15x10 +29x18x2 +25x22x6 +4x6x15 +12x18x4 +10x3x20 +17x28x17 +14x25x13 +14x10x3 +14x5x10 +7x7x22 +21x2x14 +1x21x5 +27x29x1 +6x20x4 +7x19x23 +28x19x27 +3x9x18 +13x17x17 +18x8x15 +26x23x17 +10x10x13 +11x5x21 +25x15x29 +6x23x24 +10x7x2 +19x10x30 +4x3x23 +22x12x6 +11x17x16 +6x8x12 +18x20x11 +6x2x2 +17x4x11 +20x23x22 +29x23x24 +25x11x21 +22x11x15 +29x3x9 +13x30x5 +17x10x12 +10x30x8 +21x16x17 +1x5x26 +22x15x16 +27x7x11 +16x8x18 +29x9x7 +25x4x17 +10x21x25 +2x19x21 +29x11x16 +18x26x21 +2x8x20 +17x29x27 +25x27x4 +14x3x14 +25x29x29 +26x18x11 +8x24x28 +7x30x24 +12x30x22 +29x20x6 +3x17x1 +6x15x14 +6x22x20 +13x26x26 +12x2x1 +7x14x12 +15x16x11 +3x21x4 +30x17x29 +9x18x27 +11x28x16 +22x3x25 +18x15x15 +2x30x12 +3x27x22 +10x8x8 +26x16x14 +15x2x29 +12x10x7 +21x20x15 +2x15x25 +4x14x13 +3x15x13 +29x8x3 +7x7x28 +15x10x24 +23x15x5 +5x7x14 +24x1x22 +1x11x13 +26x4x19 +19x16x26 +5x25x5 +17x25x14 +23x7x14 +24x6x17 +5x13x12 +20x20x5 +22x29x17 +11x17x29 +25x6x4 +29x8x16 +28x22x24 +24x23x17 +16x17x4 +17x8x25 +22x9x13 +24x4x8 +18x10x20 +21x23x21 +13x14x12 +23x26x4 +4x10x29 +2x18x18 +19x5x21 +2x27x23 +6x29x30 +21x9x20 +6x5x16 +25x10x27 +5x29x21 +24x14x19 +19x11x8 +2x28x6 +19x25x6 +27x1x11 +6x8x29 +18x25x30 +4x27x26 +8x12x1 +7x17x25 +7x14x27 +12x9x5 +14x29x13 +18x17x5 +23x1x3 +28x5x13 +3x2x26 +3x7x11 +1x8x7 +12x5x4 +2x30x21 +16x30x11 +3x26x4 +16x9x4 +11x9x22 +23x5x6 +13x20x3 +4x3x2 +14x10x29 +11x8x12 +26x15x16 +7x17x29 +18x19x18 +8x28x4 +22x6x13 +9x23x7 +11x23x20 +13x11x26 +15x30x13 +1x5x8 +5x10x24 +22x25x17 +27x20x25 +30x10x21 +16x28x24 +20x12x8 +17x25x1 +30x14x9 +14x18x6 +8x28x29 +12x18x29 +9x7x18 +6x12x25 +20x13x24 +22x3x12 +5x23x22 +8x10x17 +7x23x5 +10x26x27 +14x26x19 +10x18x24 +8x4x4 +16x15x11 +3x14x9 +18x5x30 +29x12x26 +16x13x12 +15x10x7 +18x5x26 +14x1x6 +10x8x29 +3x4x9 +19x4x23 +28x17x23 +30x7x17 +19x5x9 +26x29x28 +22x13x17 +28x2x1 +20x30x8 +15x13x21 +25x23x19 +27x23x1 +4x6x23 +29x29x24 +5x18x7 +4x6x30 +17x15x2 +27x4x2 +25x24x14 +28x8x30 +24x29x5 +14x30x14 +10x18x19 +15x26x22 +24x19x21 +29x23x27 +21x10x16 +7x4x29 +14x21x3 +21x4x28 +17x16x15 +24x7x13 +21x24x15 +25x11x16 +10x26x13 +23x20x14 +20x29x27 +14x24x14 +14x23x12 +18x6x5 +3x18x9 +8x18x19 +20x26x15 +16x14x13 +30x16x3 +17x13x4 +15x19x30 +20x3x8 +13x4x5 +12x10x15 +8x23x26 +16x8x15 +22x8x11 +12x11x18 +28x3x30 +15x8x4 +13x22x13 +21x26x21 +29x1x15 +28x9x5 +27x3x26 +22x19x30 +4x11x22 +21x27x20 +22x26x7 +19x28x20 +24x23x16 +26x12x9 +13x22x9 +5x6x23 +20x7x2 +18x26x30 +3x6x28 +24x18x13 +28x19x16 +25x21x25 +25x19x23 +22x29x10 +29x19x30 +4x7x27 +5x12x28 +8x26x6 +14x14x25 +17x17x2 +5x27x11 +8x2x2 +3x20x24 +26x10x9 +22x28x27 +18x15x20 +12x11x1 +5x14x30 +7x3x16 +2x16x16 +18x20x15 +13x14x29 +1x17x12 +13x5x23 +19x4x10 +25x19x11 +15x17x14 +1x28x27 +11x9x28 +9x10x18 +30x11x22 +21x21x20 +2x1x5 +2x25x1 +7x3x4 +22x15x29 +21x28x15 +12x12x4 +21x30x6 +15x10x7 +10x14x6 +21x26x18 +14x25x6 +9x7x11 +22x3x1 +1x16x27 +1x14x23 +2x13x8 +14x19x11 +21x26x1 +4x28x13 +12x16x20 +21x13x9 +3x4x13 +14x9x8 +21x21x12 +27x10x17 +6x20x6 +28x23x23 +2x28x12 +8x10x10 +3x9x2 +20x3x29 +19x4x16 +29x24x9 +26x20x8 +15x28x26 +18x17x10 +7x22x10 +20x15x9 +6x10x8 +7x26x21 +8x8x16 +15x6x29 +22x30x11 +18x25x8 +6x21x20 +7x23x25 +8x25x26 +11x25x27 +22x18x23 +3x2x14 +16x16x1 +15x13x11 +3x9x25 +29x25x24 +9x15x1 +12x4x1 +23x30x20 +3x1x23 +6x10x29 +28x13x24 +4x19x17 +6x6x25 +27x29x17 +12x13x2 +10x7x13 +14x15x8 +22x2x3 +27x17x19 +23x10x16 +5x9x25 +9x25x14 +11x18x6 +18x10x12 +9x4x15 +7x16x14 +17x24x10 +11x4x6 +12x9x17 +22x18x12 +6x24x24 +6x22x23 +5x17x30 +6x9x5 +17x20x10 +6x8x12 +14x17x13 +29x10x17 +22x4x5 +10x19x30 +22x29x11 +10x12x29 +21x22x26 +16x6x25 +1x26x24 +30x17x16 +27x28x5 +30x13x22 +7x26x12 +11x24x30 +1x17x25 +22x1x3 +29x24x6 +4x8x24 +13x9x20 +8x12x9 +21x25x4 +23x23x28 +5x2x19 +29x3x15 +22x1x14 +3x23x30 +8x25x3 +15x8x14 +30x14x6 +23x27x24 +19x1x2 +10x9x13 +13x8x7 +8x13x22 +5x15x20 +17x14x8 +5x11x20 +5x10x27 +24x17x19 +21x2x3 +15x30x26 +21x19x15 +2x7x23 +13x17x25 +30x15x19 +26x4x10 +2x25x8 +9x9x10 +2x25x8 +19x21x30 +17x26x12 +7x5x10 +2x22x14 +10x17x30 +1x8x5 +23x2x25 +22x29x8 +13x26x1 +26x3x30 +25x17x8 +25x18x26 +26x19x15 +8x28x10 +12x16x29 +30x6x29 +28x19x4 +27x26x18 +15x23x17 +5x21x30 +8x11x13 +2x26x7 +19x9x24 +3x22x23 +6x7x18 +4x26x30 +13x25x20 +17x3x15 +8x20x18 +23x18x23 +28x23x9 +16x3x4 +1x29x14 +20x26x22 +3x2x22 +23x8x17 +19x5x17 +21x18x20 +17x21x8 +30x28x1 +29x19x23 +12x12x11 +24x18x7 +21x18x14 +14x26x25 +9x11x3 +10x7x15 +27x6x28 +14x26x4 +28x4x1 +22x25x29 +6x26x6 +1x3x13 +26x22x12 +6x21x26 +23x4x27 +26x13x24 +5x24x28 +22x16x7 +3x27x24 +19x28x2 +11x13x9 +29x16x22 +30x10x24 +14x14x22 +22x23x16 +14x8x3 +20x5x14 +28x6x13 +3x15x25 +4x12x22 +15x12x25 +10x11x24 +7x7x6 +8x11x9 +21x10x29 +23x28x30 +8x29x26 +16x27x11 +1x10x2 +24x20x16 +7x12x28 +28x8x20 +14x10x30 +1x19x6 +4x12x20 +18x2x7 +24x18x17 +16x11x10 +1x12x22 +30x16x28 +18x12x11 +28x9x8 +23x6x17 +10x3x11 +5x12x8 +22x2x23 +9x19x14 +15x28x13 +27x20x23 +19x16x12 +19x30x15 +8x17x4 +10x22x18 +13x22x4 +3x12x19 +22x16x23 +11x8x19 +8x11x6 +7x14x7 +29x17x29 +21x8x12 +21x9x11 +20x1x27 +1x22x11 +5x28x4 +26x7x26 +30x12x18 +29x11x20 +3x12x15 +24x25x17 +14x6x11 diff --git a/advent03.ipynb b/advent03.ipynb new file mode 100644 index 0000000..0b919ee --- /dev/null +++ b/advent03.ipynb @@ -0,0 +1,132 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "pi3 = open('advent03.txt').read().strip()" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "2081" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import collections\n", + "\n", + "x, y = 0, 0\n", + "houses = collections.defaultdict(int)\n", + "houses[(0,0)] = 1\n", + "\n", + "for direction in pi3:\n", + " if direction == \"^\":\n", + " x += 1\n", + " if direction == 'v':\n", + " x -= 1\n", + " if direction == '>':\n", + " y += 1\n", + " if direction == '<':\n", + " y -= 1\n", + " houses[(x, y)] += 1\n", + "len(houses)" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "2341" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import collections\n", + "\n", + "x, y, rx, ry = 0, 0, 0, 0\n", + "houses = collections.defaultdict(int)\n", + "houses[(0,0)] = 2\n", + "\n", + "for i in range(0, len(pi3), 2):\n", + " direction = pi3[i]\n", + " rdirection = pi3[i+1]\n", + " if direction == \"^\":\n", + " x += 1\n", + " if direction == 'v':\n", + " x -= 1\n", + " if direction == '>':\n", + " y += 1\n", + " if direction == '<':\n", + " y -= 1\n", + " houses[(x, y)] += 1\n", + " if rdirection == \"^\":\n", + " rx += 1\n", + " if rdirection == 'v':\n", + " rx -= 1\n", + " if rdirection == '>':\n", + " ry += 1\n", + " if rdirection == '<':\n", + " ry -= 1\n", + " houses[(rx, ry)] += 1\n", + "len(houses)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.4.3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/advent03.txt b/advent03.txt new file mode 100644 index 0000000..55f286f --- /dev/null +++ b/advent03.txt @@ -0,0 +1 @@ +^><^>>>^<^v<<^<><^<^v>^vv<>v>>^^^v<<<^>^<^v<^>^v><<<^>><>v>v^<<^>^<<^^^>v>>v^^>^>vv>>^>>v^>^v>^<^^v>^>^^v^^>v^^v><^><^<<>v^<^<^vv^>>>v^v^>^<>^v<^^vv^>^<>^^<vv<>^>v<^>^v>v^>^v<>^><>>v^v<><>v^v>>>>v^^>^><^^<^>^v^v<>v<<<^<v^^^<^^^>v<^v>>>>>v<^^^^>v<^<>>>>>>v^vvvv^^^v<^v^>v><^>^v<<>>vv^>v>v^^>vv^<^vvv<>><>><><^^^^<^^^<^v>>v>^v^^^>v^^^v>>^v^^<^>>^>^<>>^^<>>^vv>v^<^>>>><><^^v<><<<<^^<>>^<>vv^<^>v^^><^v>^^>v<>^v^<>^vv^>vvv>v>^>^>>^>><>>>^^^^v^<>v^^>^<>v<^^v><^v><>^^^^^v^v>>^^v><<><^^^^><^>v>><<<^v>v^^>^v^<^^v>v<^<<>>^v<<>v<^v^>v^>^v<<v>v>>v>v^^v>^v^>>>><>^>v>^v^>>>>v^<<<>vvv>><^^>^<><^^<^v^v^<^^>^<^v^<<<^^v^v>>><>^^>vv<<^v^<<<<^^>>>v>v<<<>^^>>>v>^>v>vv<<>^<^>^^<^>^v^<>v^><^^^>vv>><^v<^<<<><<^^<><>v>^>^<>>^^v>vv^<^^v>><^vv^<<<>vv^v<^<>v^^>><>^<^v<<<^<<^>>>^^<^^v>v^vvvv>v<>><^>^<<<v^^^v<>v>^^<v>>v>>v^>^<>v><>>>v^>^v<^<><<^>^^^>^><>^><^<>vv<>>v^v>^>^>^<^><>v<><>>>^^^<^v>>^<>>>vv^>vvvv>>><^>v<>^^^>v>>v^v^>^^<<^>^>>v<<><>v^^>v^><<^v^>^^<v><<<^v^<>^<>^>>^<^^<>^v<>v^>>><>^><>>vv>v^<^^^>v>^^>^v<><>>><>><^<>>v>v^^>^^<^^>^>>v>vv^^v<^<^v>><<^>^v>^^^<<>v^<^^v<<<>^^vv<^>vv>^>^<><<>vv<^>v^vv>^^^v><<^vv>^v<>vv^^<^<>^^v^<^vvv>v^^<>^^>^^>^<><<^v>^><^^vvvv<><>^v<>^><>v>><>vv^<<><<>><>v<^>^v>>^^v><<<>>^<^v^^^<^<><><^><<<<^^<>><><>>v><<vvvv^^vv><<^v^vvv><>v><>v<<<^><^^>v^>^^^v^v>><<>^v<>v^v<<<<^^^v^v<<>>>v>>vv>^^<><^v<>>v^>>>>>^>v^v^<^v^v^vvv>vvv^<vv>>v^^vv<^v>>>>vv<>v<>^^vv^v^>>vvv<<v>v>^><<<^>v^>^v^^^><<><<<^^<^^<>^^v<^v>^v<^>^>><>^v^v<<^>^>v><^>^vv^^^v^v^>^<<>>>>>v^<>^>v^vv^><<>>^^<>v^>^vvv^>v^v><>^><<>v>v<^<^><^^vv<<><>>v>>v>>^v<<>^vv<>^vv>v>v>^>^>>><><<>v^<<^v^^<<<>>vv<^<<>v<^^^<<^v^>^v>^^^v^v>>>v>v^v>^>^vv<^^<^<<v^<><<^vvv^^><>vv^v>v>^><<^^^^vvv^><^v<^>^<>>^>>vv^<>>^v>^>v>^<^<^^^<>>>>>>v>^<>^^v^><>><^v^^><>v^v<^<<<<^>^^>vv>><^v^vvv>v^^><^^<^<>>^^v^vv<>v<^<<v>v<>^v^><>v<^v>><<^<^v^>><^<^><>v>>^vv<^v>^>v<^>>^>>v^>^v<^v^v><<><>^><<<><>^<>^^^^v>^>^vvvvv>v>>v><<<^><<^v><^v>>>>^v<^v<<>>^>^<v>><<^>^>^v><><>^><v^><<^v^<^^><^^v^<<^v^^>>^v^<^>v^^<<^^^<><>^>v^v>v^>^v^vv>^^>>>>^^<^>>>^^v<^^v><<<>^>^^>^>^v<<<<>>^<<>>>v>^^<^v<>v<>v^>v^><^<^^>^^vv><>v>^<<<^><^^<^<^^v<^>v^v^^^><^>v^v>>^^v^>>>>><<>^>v>v<>>>v>^^^^>>v^<<^>>><^v^<<>>v><>^v^^><<>>^>^>vv<^<>^vvv^vv^v>^^<<<<<>^v^>^<>v^^<>v^v^<>vv^<^vv>>><<>v^^^>^>^^>>>vvv>^>v>v>>>^>vv^><>^><>v>^^^><><<<>>v^v<^<>^^<>^^<<><>^v<><>>>^vv<^<<^<^v>v<<<<<^^v<^v<><^>v>^v>>^v^><^^^^v<><><>vv^<>vv<^v<^^><^^v^v^<^^<<>v<>v^v<^>vvv><<^v>>v><>>>v<^>>v>^<>><>^v<^^>^<^v<^<<^^v<>>^>^>^v^^v^v>v>v<>v^>v^^>^^>><<>><<^^>><^v<<><<>>>>>>^^^^^<<>^<<^><<^^vvv<<>vv><<>v>v^v>>>>>^<>><^^^><<<<>>v<^>>>^^vvv>v<>>>>v>>^v^vvv<<>vvv<<^^^<>vv^^v<<>^^^>>^<^v^<^^>v^>>^<<^v<v^>>^>v^><^><>^>>>vv>><^^^>vv<<^^vv><^<>^>^^<^<>>^vv^>>^v><>v^>>><<<^^<^>^>v<^>^<^^<>>><^^<>^v^<<>vvv>v^v<<^^^><<^vv^v>v>v<<^v^<<<>^><>v>^vv^v<>vv^>^^<^>^>v^^v><>>^v<^<><><^vv<><<>v^^>^^<><<>^<^<<<>v>><^<<>^>^v^v<^>>^v<^>v<<>^^^<^v>>>^vvvv<vvvv>v<>v^<><>vvv<>^<<>^>>>>v^<^<><^v>v^>>v><>^><^<<>^>^v^>^v>^<>v^<^^>v>^>>>v^v>>>^<>^<>>>>>v>>vv^v<><<<><><<>>vv<^^v<<>v^v<^v<>>^v>>vvv^^v>>v>^>^>v><^>^^<<>^v<^<<<<^>v<^>>v^<^v>^v<<>^>^vvv<^^vv>^vv>vv<>>v>v>v^<<<<<^^v^>v>^<<>v^<<>>^<^>^^<>>>>^<^v<>v^^>^<^^v<^><>>>^v^vv<^v<^><><>><^^>^<^v^<^<>v<<<^v>v^^^<>v^^v^>><>^^<<^^v^<>^<^vv>>><^v>vv<^v<<>v>v^v>^v<^<>v^vvv>^vv<<<<^>>^^>><^v><<^>v^^<<<<<>^v<<^^>v<<<<^>^>^>>^>>>v^<>^^v>>>^vvv<^v<>>>vv>^^><^v>vv^>>v>v^<>^^>^<<^>^^^>>^vv>^^>vvvv<>>^^^^>>>v>v^^>vv>vv^<<>^><^><<>>^>^><^v^>v^<>^>v^^v^>^^>v<<<<^<<^>>v>v^^^<<>>^^v>v<<<<^^^v>^vv^>><>^v<>>>v>vvv^v^^v^>>vv>^>><>^v><^v^><^^>vv>^<^<^>>v>><><>^>^>v>vv>vv>^^>v>v^>^>^v>^^v>^<^v<>>vvv^^>^>vvv^^v<^<^>vv^^<^^^>v>vv<v<^>^v^<^>v<^>^<>vv^><>>^>>^<^><<>^<^>v>v><>>>^<<^><<^v<>>vv<^>>v>v>>>>^^>v<^v^>><<^<>>v><^><<^>^<<>>^^<><^^v>^^>vv>^v>^^v^<^<<>>v^^^<^><^<<><><<>^v>vvv^vvv^^>>^<^><>^<<<<^^<>>>v^<<^^v>><><v>^vv>vv^><>^><<><^^>^>^<><>><^^<><>^>><^v<<<<>>^v>^^vv^v^<><<vv>>v>>^v^<>>vv^<^>^<<>v<<<^vv<^vv^vv<^v^^^v>>v<^^<^^vvv<^^v<>>>^>v^>^^><>vv>v>v<<<^^v<^vv^v>^^^>>>^^<>^^<^vvv>><><<><^><<>^>^^vv>vv^^<^^<<><><v><<>v>vvv<^^^^<^>>><<<^^^<^>vv^^v>>v<vvv^^v^^<^v<^<>^<^v>>^><><>v>>>^^>>v^>><>v<><>>><>>>>><<^vvv<<><><<>^><><<^^v><<^>v>^>^v>v>>^^<><^>vv<^<^v>v<><^<<^><>^^^^^v>><>^>^vvv>v^vv^v^>v><>v^><>v>^^^^><^v^^^>^^><<^^>v>v<^v^^vv^<<<<^>v>v^v><>^><><>^v^<>^v>^v>v^<><^>>v<<^><^vv^<><^<>><>><<^^^^>v<^<^vv<><^vv><<^<v^>>^v>^>v^^v>vvv<v<>^>>vv^>>><>^v^^<^>v<<^<^^v^^v^<vv^><^v<^>>>vv^^^^v>^><^^^<><<^^>v<><><><>vv^><<^>^><^v<^<^v^v<<<<<<><vv>v<^><<><><<>>v>><^>^v>^v^<>v^^^><^^<<<^vv^vv>^v^vvv^^>v^><^<^<^<>^vv^^^>vv^v>>><<<^<>>v>v<^^<>>><><^v^^<<><<<>^<^^v^>v><^<^>^>>^<>^v><>>^vv^>^^<<<^v<>>^v<>vvv<<^^<<>>>>^^<><>^><>^vv^v<^>^v<>v^vv<><^vvv<><<^>>^^><><>^<>^>v^^v^><>>v>><^v>^v<<<>vvv^<^^v^<>^>>v<>^^><>>^><^^vv>><<>><^><>>^vv>vv^v^^v<<^^v^^vv<<^<<><>^<><^<^<>>^vvv>>^<^vv>^vv^>v>^<><^><^<>v^v^^<^<>^^v>>><^v<>v^v<<^>v><>^^<v^>>v>^<>^>^>^<^>v><<><><><<<>^>><^>>>^v<<<^<<>^><<^>>>>>v<^>v>>v^^>v^^><>v^v^vvvvv>>><<>^<v>^>^vv^^<^>>v>vv^v<^<>^v^<^<<><<<^vvv^>^^<<>>>vv<<^<><^v<^<><<^^>vv^v>v^^^>>>>^>vv<v>>^^v^^><>v<<^><^>^>v^v>><^v^>v<<^<^<^<^<>>v^^>><<<>vv<^^>^vv<<<^^v^^>v<<><^<>^^>^v<>v>><^^^vv^>^><>v^^>^v>^<<^v>^>>>>><^^^<>v>v^^<^v^>>v^<^>v^v>>>>^>>vv<>^<^v>v>v^v>^<>^>v<<>^<>>^<>>^<>v^><<>^v>>^^^^<<^v><>^<^>^^v><^^<^^v>v<<^>^>><<^^^vvv<<^vv<^^>v^^vv^<^^<<^^>>^^<v^>>v^^>v<^>^>vv>><v><^<^vv>^^v>^>v<<^vv><^^^^^^><<^>>>^v<>^^v<<<>><<<>^<<v^>^^^<^>^^^v<<>v^><<^^<<^v<<>^v>>vv>><<^v^^>v^v>^^v<><^^^<^^>v>^<>vvv^v^^^>v^^v<^>^^>>^v<><^><^<<^vv^<><<>v^vv^<<<^^>v<<>>>v<>v<><<^v>^^v>^^>v>^>^>v<>><>^>^>^vvvv<^^^^^v>v>><>^>^><>^^>v^^<<><^><<<<>v>^^>^v<<<>vvv>>v<^v>>v>v^<<<>^>^>^<>v<^^vv><^v<<^vv<^<<^^vv^^>vv<^>v>^^<^>v<<^^<^>^^^v^^>>v^vv^<^v>^<>^<^>>^<^v<>v><^^<><>^>v<^<^vv>><^v>^<>^^>^<><<>^<>><<>vvv^<<^^>>v<^>>vv>^v^^^v<>v<>><>^vv^>vv^ diff --git a/advent04.ipynb b/advent04.ipynb new file mode 100644 index 0000000..e4cd80a --- /dev/null +++ b/advent04.ipynb @@ -0,0 +1,145 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "import hashlib" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'000001dbbfa3a5c83a2d506429c7b00e'" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "hashlib.md5(b\"abcdef609043\").hexdigest()" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "53" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "bytes(str(75), 'ascii')[1]" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "346386" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "i = 0\n", + "salt = b\"iwrupvqb\"\n", + "hd = hashlib.md5(salt + bytes(str(i), 'ascii')).hexdigest()\n", + "while not hd.startswith('00000'):\n", + " i+=1\n", + " hd = hashlib.md5(salt + bytes(str(i), 'ascii')).hexdigest()\n", + "i" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "9958218" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "i = 0\n", + "salt = b\"iwrupvqb\"\n", + "hd = hashlib.md5(salt + bytes(str(i), 'ascii')).hexdigest()\n", + "while not hd.startswith('000000'):\n", + " i+=1\n", + " hd = hashlib.md5(salt + bytes(str(i), 'ascii')).hexdigest()\n", + "i" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.4.3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/advent05.ipynb b/advent05.ipynb new file mode 100644 index 0000000..2f2dba9 --- /dev/null +++ b/advent05.ipynb @@ -0,0 +1,189 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "pi5 = open('advent05.txt').read().strip()" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def nice(str):\n", + " n1 = len(list(c for c in str if c in \"aeiou\")) >= 3\n", + " n2 = any(str[i-1] == str[i] for i in range(1, len(str)))\n", + " n3 = all(s not in str for s in ['ab', 'cd', 'pq', 'xy'])\n", + " return n1 and n2 and n3 " + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "nice('dvszwmarrgswjxmb')" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "255" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sum(1 if nice(str.strip()) else 0 for str in pi5.splitlines())" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def nice2(st):\n", + " def n1(st):\n", + " for i in range(1, len(st)):\n", + " if st.find(st[i-1:i+1], i+1) > -1:\n", + " return True\n", + " return False\n", + " def n2(st):\n", + " return any(st[i-1] == st[i+1] for i in range(1, len(st)-1))\n", + " return n1(st) and n2(st)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "nice2('ieodomkazucvgmuy')" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['ac', 'bd', 'ce', 'df']" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "['abcdef'[i-1] + 'abcdef'[i+1] for i in range(1, len('abcdef')-1)]" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "55" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sum(1 if nice2(st.strip()) else 0 for st in pi5.splitlines())" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.4.3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/advent05.txt b/advent05.txt new file mode 100644 index 0000000..a9b6e77 --- /dev/null +++ b/advent05.txt @@ -0,0 +1,1000 @@ +sszojmmrrkwuftyv +isaljhemltsdzlum +fujcyucsrxgatisb +qiqqlmcgnhzparyg +oijbmduquhfactbc +jqzuvtggpdqcekgk +zwqadogmpjmmxijf +uilzxjythsqhwndh +gtssqejjknzkkpvw +wrggegukhhatygfi +vhtcgqzerxonhsye +tedlwzdjfppbmtdx +iuvrelxiapllaxbg +feybgiimfthtplui +qxmmcnirvkzfrjwd +vfarmltinsriqxpu +oanqfyqirkraesfq +xilodxfuxphuiiii +yukhnchvjkfwcbiq +bdaibcbzeuxqplop +ivegnnpbiyxqsion +ybahkbzpditgwdgt +dmebdomwabxgtctu +ibtvimgfaeonknoh +jsqraroxudetmfyw +dqdbcwtpintfcvuz +tiyphjunlxddenpj +fgqwjgntxagidhah +nwenhxmakxqkeehg +zdoheaxqpcnlhnen +tfetfqojqcdzlpbm +qpnxkuldeiituggg +xwttlbdwxohahwar +hjkwzadmtrkegzye +koksqrqcfwcaxeof +wulwmrptktliyxeq +gyufbedqhhyqgqzj +txpunzodohikzlmj +jloqfuejfkemcrvu +amnflshcheuddqtc +pdvcsduggcogbiia +yrioavgfmeafjpcz +uyhbtmbutozzqfvq +mwhgfwsgyuwcdzik +auqylgxhmullxpaa +lgelzivplaeoivzh +uyvcepielfcmswoa +qhirixgwkkccuzlp +zoonniyosmkeejfg +iayfetpixkedyana +ictqeyzyqswdskiy +ejsgqteafvmorwxe +lhaiqrlqqwfbrqdx +ydjyboqwhfpqfydc +dwhttezyanrnbybv +edgzkqeqkyojowvr +rmjfdwsqamjqehdq +ozminkgnkwqctrxz +bztjhxpjthchhfcd +vrtioawyxkivrpiq +dpbcsznkpkaaclyy +vpoypksymdwttpvz +hhdlruwclartkyap +bqkrcbrksbzcggbo +jerbbbnxlwfvlaiw +dwkasufidwjrjfbf +kkfxtjhbnmqbmfwf +vmnfziwqxmioukmj +rqxvcultipkecdtu +fhmfdibhtjzkiqsd +hdpjbuzzbyafqrpd +emszboysjuvwwvts +msyigmwcuybfiooq +druyksfnbluvnwoh +fvgstvynnfbvxhsx +bmzalvducnqtuune +lzwkzfzttsvpllei +olmplpvjamynfyfd +padcwfkhystsvyfb +wjhbvxkwtbfqdilb +hruaqjwphonnterf +bufjobjtvxtzjpmj +oiedrjvmlbtwyyuy +sgiemafwfztwsyju +nsoqqfudrtwszyqf +vonbxquiiwxnazyl +yvnmjxtptujwqudn +rrnybqhvrcgwvrkq +taktoxzgotzxntfu +quffzywzpxyaepxa +rfvjebfiddcfgmwv +iaeozntougqwnzoh +scdqyrhoqmljhoil +bfmqticltmfhxwld +brbuktbyqlyfpsdl +oidnyhjkeqenjlhd +kujsaiqojopvrygg +vebzobmdbzvjnjtk +uunoygzqjopwgmbg +piljqxgicjzgifso +ikgptwcjzywswqnw +pujqsixoisvhdvwi +trtuxbgigogfsbbk +mplstsqclhhdyaqk +gzcwflvmstogdpvo +tfjywbkmimyyqcjd +gijutvhruqcsiznq +ibxkhjvzzxgavkha +btnxeqvznkxjsgmq +tjgofgauxaelmjoq +sokshvyhlkxerjrv +ltogbivktqmtezta +uduwytzvqvfluyuf +msuckpthtgzhdxan +fqmcglidvhvpirzr +gwztkqpcwnutvfga +bsjfgsrntdhlpqbx +xloczbqybxmiopwt +orvevzyjliomkkgu +mzjbhmfjjvaziget +tlsdxuhwdmghdyjb +atoecyjhwmznaewi +pyxpyvvipbqibiox +ajbfmpqqobfsmesj +siknbzefjblnohgd +eqfhgewbblwdfkmc +opylbscrotckkrbk +lbwxbofgjkzdxkle +ceixfjstaptdomvm +hnkrqxifjmmjktie +aqykzeuzvvetoygd +fouahjimfcisxima +prkzhutbqsyrhjzx +qqwliakathnsbzne +sayhgqtlcqqidqhj +ygduolbysehdudra +zricvxhdzznuxuce +ucvzakslykpgsixd +udirhgcttmyspgsb +yuwzppjzfsjhhdzi +gtqergjiuwookwre +xvxexbjyjkxovvwf +mlpaqhnnkqxrmwmm +ezuqbrjozwuqafhb +mcarusdthcbsonoq +weeguqeheeiigrue +pngtfugozxofaqxv +copphvbjcmfspenv +jiyahihykjjkdaya +gdqnmesvptuyrfwp +vbdscfywqmfxbohh +crtrfuxyjypzubrg +seihvevtxywxhflp +fvvpmgttnapklwou +qmqaqsajmqwhetpk +zetxvrgjmblxvakr +kpvwblrizaabmnhz +mwpvvzaaicntrkcp +clqyjiegtdsswqfm +ymrcnqgcpldgfwtm +nzyqpdenetncgnwq +cmkzevgacnmdkqro +kzfdsnamjqbeirhi +kpxrvgvvxapqlued +rzskbnfobevzrtqu +vjoahbfwtydugzap +ykbbldkoijlvicbl +mfdmroiztsgjlasb +quoigfyxwtwprmdr +ekxjqafwudgwfqjm +obtvyjkiycxfcdpb +lhoihfnbuqelthof +eydwzitgxryktddt +rxsihfybacnpoyny +bsncccxlplqgygtw +rvmlaudsifnzhcqh +huxwsyjyebckcsnn +gtuqzyihwhqvjtes +zreeyomtngvztveq +nwddzjingsarhkxb +nuqxqtctpoldrlsh +wkvnrwqgjooovhpf +kwgueyiyffudtbyg +tpkzapnjxefqnmew +ludwccvkihagvxal +lfdtzhfadvabghna +njqmlsnrkcfhtvbb +cajzbqleghhnlgap +vmitdcozzvqvzatp +eelzefwqwjiywbcz +uyztcuptfqvymjpi +aorhnrpkjqqtgnfo +lfrxfdrduoeqmwwp +vszpjvbctblplinh +zexhadgpqfifcqrz +ueirfnshekpemqua +qfremlntihbwabtb +nwznunammfexltjc +zkyieokaaogjehwt +vlrxgkpclzeslqkq +xrqrwfsuacywczhs +olghlnfjdiwgdbqc +difnlxnedpqcsrdf +dgpuhiisybjpidsj +vlwmwrikmitmoxbt +sazpcmcnviynoktm +pratafauetiknhln +ilgteekhzwlsfwcn +ywvwhrwhkaubvkbl +qlaxivzwxyhvrxcf +hbtlwjdriizqvjfb +nrmsononytuwslsa +mpxqgdthpoipyhjc +mcdiwmiqeidwcglk +vfbaeavmjjemfrmo +qzcbzmisnynzibrc +shzmpgxhehhcejhb +wirtjadsqzydtyxd +qjlrnjfokkqvnpue +dxawdvjntlbxtuqc +wttfmnrievfestog +eamjfvsjhvzzaobg +pbvfcwzjgxahlrag +omvmjkqqnobvnzkn +lcwmeibxhhlxnkzv +uiaeroqfbvlazegs +twniyldyuonfyzqw +wgjkmsbwgfotdabi +hnomamxoxvrzvtew +ycrcfavikkrxxfgw +isieyodknagzhaxy +mgzdqwikzullzyco +mumezgtxjrrejtrs +nwmwjcgrqiwgfqel +wjgxmebfmyjnxyyp +durpspyljdykvzxf +zuslbrpooyetgafh +kuzrhcjwbdouhyme +wyxuvbciodscbvfm +kbnpvuqwmxwfqtqe +zddzercqogdpxmft +sigrdchxtgavzzjh +lznjolnorbuddgcs +ycnqabxlcajagwbt +bnaudeaexahdgxsj +rlnykxvoctfwanms +jngyetkoplrstfzt +tdpxknwacksotdub +yutqgssfoptvizgr +lzmqnxeqjfnsxmsa +iqpgfsfmukovsdgu +qywreehbidowtjyz +iozamtgusdctvnkw +ielmujhtmynlwcfd +hzxnhtbnmmejlkyf +ftbslbzmiqkzebtd +bcwdqgiiizmohack +dqhfkzeddjzbdlxu +mxopokqffisxosci +vciatxhtuechbylk +khtkhcvelidjdena +blatarwzfqcapkdt +elamngegnczctcck +xeicefdbwrxhuxuf +sawvdhjoeahlgcdr +kmdcimzsfkdfpnir +axjayzqlosrduajb +mfhzreuzzumvoggr +iqlbkbhrkptquldb +xcvztvlshiefuhgb +pkvwyqmyoazocrio +ajsxkdnerbmhyxaj +tudibgsbnpnizvsi +cxuiydkgdccrqvkh +cyztpjesdzmbcpot +nnazphxpanegwitx +uphymczbmjalmsct +yyxiwnlrogyzwqmg +gmqwnahjvvdyhnfa +utolskxpuoheugyl +mseszdhyzoyavepd +ycqknvbuvcjfgmlc +sknrxhxbfpvpeorn +zqxqjetooqcodwml +sesylkpvbndrdhsy +fryuxvjnsvnjrxlw +mfxusewqurscujnu +mbitdjjtgzchvkfv +ozwlyxtaalxofovd +wdqcduaykxbunpie +rlnhykxiraileysk +wgoqfrygttlamobg +kflxzgxvcblkpsbz +tmkisflhativzhde +owsdrfgkaamogjzd +gaupjkvkzavhfnes +wknkurddcknbdleg +lltviwincmbtduap +qwzvspgbcksyzzmb +ydzzkumecryfjgnk +jzvmwgjutxoysaam +icrwpyhxllbardkr +jdopyntshmvltrve +afgkigxcuvmdbqou +mfzzudntmvuyhjzt +duxhgtwafcgrpihc +tsnhrkvponudumeb +sqtvnbeiigdzbjgv +eczmkqwvnsrracuo +mhehsgqwiczaiaxv +kaudmfvifovrimpd +lupikgivechdbwfr +mwaaysrndiutuiqx +aacuiiwgaannunmm +tjqjbftaqitukwzp +lrcqyskykbjpaekn +lirrvofbcqpjzxmr +jurorvzpplyelfml +qonbllojmloykjqe +sllkzqujfnbauuqp +auexjwsvphvikali +usuelbssqmbrkxyc +wyuokkfjexikptvv +wmfedauwjgbrgytl +sfwvtlzzebxzmuvw +rdhqxuechjsjcvaf +kpavhqkukugocsxu +ovnjtumxowbxduts +zgerpjufauptxgat +pevvnzjfwhjxdoxq +pmmfwxajgfziszcs +difmeqvaghuitjhs +icpwjbzcmlcterwm +ngqpvhajttxuegyh +mosjlqswdngwqsmi +frlvgpxrjolgodlu +eazwgrpcxjgoszeg +bbtsthgkjrpkiiyk +tjonoglufuvsvabe +xhkbcrofytmbzrtk +kqftfzdmpbxjynps +kmeqpocbnikdtfyv +qjjymgqxhnjwxxhp +dmgicrhgbngdtmjt +zdxrhdhbdutlawnc +afvoekuhdboxghvx +hiipezngkqcnihty +bbmqgheidenweeov +suprgwxgxwfsgjnx +adeagikyamgqphrj +zzifqinoeqaorjxg +adhgppljizpaxzld +lvxyieypvvuqjiyc +nljoakatwwwoovzn +fcrkfxclcacshhmx +ownnxqtdhqbgthch +lmfylrcdmdkgpwnj +hlwjfbvlswbzpbjr +mkofhdtljdetcyvp +synyxhifbetzarpo +agnggugngadrcxoc +uhttadmdmhidpyjw +ohfwjfhunalbubpr +pzkkkkwrlvxiuysn +kmidbxmyzkjrwjhu +egtitdydwjxmajnw +civoeoiuwtwgbqqs +dfptsguzfinqoslk +tdfvkreormspprer +zvnvbrmthatzztwi +ffkyddccrrfikjde +hrrmraevdnztiwff +qaeygykcpbtjwjbr +purwhitkmrtybslh +qzziznlswjaussel +dfcxkvdpqccdqqxj +tuotforulrrytgyn +gmtgfofgucjywkev +wkyoxudvdkbgpwhd +qbvktvfvipftztnn +otckgmojziezmojb +inxhvzbtgkjxflay +qvxapbiatuudseno +krpvqosbesnjntut +oqeukkgjsfuqkjbb +prcjnyymnqwqksiz +vuortvjxgckresko +orqlyobvkuwgathr +qnpyxlnazyfuijox +zwlblfkoklqmqzkw +hmwurwtpwnrcsanl +jzvxohuakopuzgpf +sfcpnxrviphhvxmx +qtwdeadudtqhbely +dbmkmloasqphnlgj +olylnjtkxgrubmtk +nxsdbqjuvwrrdbpq +wbabpirnpcsmpipw +hjnkyiuxpqrlvims +enzpntcjnxdpuqch +vvvqhlstzcizyimn +triozhqndbttglhv +fukvgteitwaagpzx +uhcvukfbmrvskpen +tizcyupztftzxdmt +vtkpnbpdzsaluczz +wodfoyhoekidxttm +otqocljrmwfqbxzu +linfbsnfvixlwykn +vxsluutrwskslnye +zbshygtwugixjvsi +zdcqwxvwytmzhvoo +wrseozkkcyctrmei +fblgtvogvkpqzxiy +opueqnuyngegbtnf +qxbovietpacqqxok +zacrdrrkohfygddn +gbnnvjqmkdupwzpq +qgrgmsxeotozvcak +hnppukzvzfmlokid +dzbheurndscrrtcl +wbgdkadtszebbrcw +fdmzppzphhpzyuiz +bukomunhrjrypohj +ohodhelegxootqbj +rsplgzarlrknqjyh +punjjwpsxnhpzgvu +djdfahypfjvpvibm +mlgrqsmhaozatsvy +xwktrgyuhqiquxgn +wvfaoolwtkbrisvf +plttjdmguxjwmeqr +zlvvbwvlhauyjykw +cigwkbyjhmepikej +masmylenrusgtyxs +hviqzufwyetyznze +nzqfuhrooswxxhus +pdbdetaqcrqzzwxf +oehmvziiqwkzhzib +icgpyrukiokmytoy +ooixfvwtiafnwkce +rvnmgqggpjopkihs +wywualssrmaqigqk +pdbvflnwfswsrirl +jeaezptokkccpbuj +mbdwjntysntsaaby +ldlgcawkzcwuxzpz +lwktbgrzswbsweht +ecspepmzarzmgpjm +qmfyvulkmkxjncai +izftypvwngiukrns +zgmnyjfeqffbooww +nyrkhggnprhedows +yykzzrjmlevgffah +mavaemfxhlfejfki +cmegmfjbkvpncqwf +zxidlodrezztcrij +fseasudpgvgnysjv +fupcimjupywzpqzp +iqhgokavirrcvyys +wjmkcareucnmfhui +nftflsqnkgjaexhq +mgklahzlcbapntgw +kfbmeavfxtppnrxn +nuhyvhknlufdynvn +nviogjxbluwrcoec +tyozixxxaqiuvoys +kgwlvmvgtsvxojpr +moeektyhyonfdhrb +kahvevmmfsmiiqex +xcywnqzcdqtvhiwd +fnievhiyltbvtvem +jlmndqufirwgtdxd +muypbfttoeelsnbs +rypxzbnujitfwkou +ubmmjbznskildeoj +ofnmizdeicrmkjxp +rekvectjbmdnfcib +yohrojuvdexbctdh +gwfnfdeibynzjmhz +jfznhfcqdwlpjull +scrinzycfhwkmmso +mskutzossrwoqqsi +rygoebkzgyzushhr +jpjqiycflqkexemx +arbufysjqmgaapnl +dbjerflevtgweeoj +snybnnjlmwjvhois +fszuzplntraprmbj +mkvaatolvuggikvg +zpuzuqygoxesnuyc +wnpxvmxvllxalulm +eivuuafkvudeouwy +rvzckdyixetfuehr +qgmnicdoqhveahyx +miawwngyymshjmpj +pvckyoncpqeqkbmx +llninfenrfjqxurv +kzbjnlgsqjfuzqtp +rveqcmxomvpjcwte +bzotkawzbopkosnx +ktqvpiribpypaymu +wvlzkivbukhnvram +uohntlcoguvjqqdo +ajlsiksjrcnzepkt +xsqatbldqcykwusd +ihbivgzrwpmowkop +vfayesfojmibkjpb +uaqbnijtrhvqxjtb +hhovshsfmvkvymba +jerwmyxrfeyvxcgg +hncafjwrlvdcupma +qyvigggxfylbbrzt +hiiixcyohmvnkpgk +mmitpwopgxuftdfu +iaxderqpceboixoa +zodfmjhuzhnsqfcb +sthtcbadrclrazsi +bkkkkcwegvypbrio +wmpcofuvzemunlhj +gqwebiifvqoeynro +juupusqdsvxcpsgv +rbhdfhthxelolyse +kjimpwnjfrqlqhhz +rcuigrjzarzpjgfq +htxcejfyzhydinks +sxucpdxhvqjxxjwf +omsznfcimbcwaxal +gufmtdlhgrsvcosb +bssshaqujtmluerz +uukotwjkstgwijtr +kbqkneobbrdogrxk +ljqopjcjmelgrakz +rwtfnvnzryujwkfb +dedjjbrndqnilbeh +nzinsxnpptzagwlb +lwqanydfirhnhkxy +hrjuzfumbvfccxno +okismsadkbseumnp +sfkmiaiwlktxqvwa +hauwpjjwowbunbjj +nowkofejwvutcnui +bqzzppwoslaeixro +urpfgufwbtzenkpj +xgeszvuqwxeykhef +yxoldvkyuikwqyeq +onbbhxrnmohzskgg +qcikuxakrqeugpoa +lnudcqbtyzhlpers +nxduvwfrgzaailgl +xniuwvxufzxjjrwz +ljwithcqmgvntjdj +awkftfagrfzywkhs +uedtpzxyubeveuek +bhcqdwidbjkqqhzl +iyneqjdmlhowwzxx +kvshzltcrrururty +zgfpiwajegwezupo +tkrvyanujjwmyyri +ercsefuihcmoaiep +ienjrxpmetinvbos +jnwfutjbgenlipzq +bgohjmrptfuamzbz +rtsyamajrhxbcncw +tfjdssnmztvbnscs +bgaychdlmchngqlp +kfjljiobynhwfkjo +owtdxzcpqleftbvn +ltjtimxwstvzwzjj +wbrvjjjajuombokf +zblpbpuaqbkvsxye +gwgdtbpnlhyqspdi +abipqjihjqfofmkx +nlqymnuvjpvvgova +avngotmhodpoufzn +qmdyivtzitnrjuae +xfwjmqtqdljuerxi +csuellnlcyqaaamq +slqyrcurcyuoxquo +dcjmxyzbzpohzprl +uqfnmjwniyqgsowb +rbmxpqoblyxdocqc +ebjclrdbqjhladem +ainnfhxnsgwqnmyo +eyytjjwhvodtzquf +iabjgmbbhilrcyyp +pqfnehkivuelyccc +xgjbyhfgmtseiimt +jwxyqhdbjiqqqeyy +gxsbrncqkmvaryln +vhjisxjkinaejytk +seexagcdmaedpcvh +lvudfgrcpjxzdpvd +fxtegyrqjzhmqean +dnoiseraqcoossmc +nwrhmwwbykvwmgep +udmzskejvizmtlce +hbzvqhvudfdlegaa +cghmlfqejbxewskv +bntcmjqfwomtbwsb +qezhowyopjdyhzng +todzsocdkgfxanbz +zgjkssrjlwxuhwbk +eibzljqsieriyrzr +wamxvzqyycrxotjp +epzvfkispwqynadu +dwlpfhtrafrxlyie +qhgzujhgdruowoug +girstvkahaemmxvh +baitcrqmxhazyhbl +xyanqcchbhkajdmc +gfvjmmcgfhvgnfdq +tdfdbslwncbnkzyz +jojuselkpmnnbcbb +hatdslkgxtqpmavj +dvelfeddvgjcyxkj +gnsofhkfepgwltse +mdngnobasfpewlno +qssnbcyjgmkyuoga +glvcmmjytmprqwvn +gwrixumjbcdffsdl +lozravlzvfqtsuiq +sicaflbqdxbmdlch +inwfjkyyqbwpmqlq +cuvszfotxywuzhzi +igfxyoaacoarlvay +ucjfhgdmnjvgvuni +rvvkzjsytqgiposh +jduinhjjntrmqroz +yparkxbgsfnueyll +lyeqqeisxzfsqzuj +woncskbibjnumydm +lltucklragtjmxtl +ubiyvmyhlesfxotj +uecjseeicldqrqww +xxlxkbcthufnjbnm +lhqijovvhlffpxga +fzdgqpzijitlogjz +efzzjqvwphomxdpd +jvgzvuyzobeazssc +hejfycgxywfjgbfw +yhjjmvkqfbnbliks +sffvfyywtlntsdsz +dwmxqudvxqdenrur +asnukgppdemxrzaz +nwqfnumblwvdpphx +kqsmkkspqvxzuket +cpnraovljzqiquaz +qrzgrdlyyzbyykhg +opoahcbiydyhsmqe +hjknnfdauidjeydr +hczdjjlygoezadow +rtflowzqycimllfv +sfsrgrerzlnychhq +bpahuvlblcolpjmj +albgnjkgmcrlaicl +pijyqdhfxpaxzdex +eeymiddvcwkpbpux +rqwkqoabywgggnln +vckbollyhgbgmgwh +ylzlgvnuvpynybkm +hpmbxtpfosbsjixt +ocebeihnhvkhjfqz +tvctyxoujdgwayze +efvhwxtuhapqxjen +rusksgefyidldmpo +nkmtjvddfmhirmzz +whvtsuadwofzmvrt +iiwjqvsdxudhdzzk +gucirgxaxgcassyo +rmhfasfzexeykwmr +hynlxcvsbgosjbis +huregszrcaocueen +pifezpoolrnbdqtv +unatnixzvdbqeyox +xtawlpduxgacchfe +bdvdbflqfphndduf +xtdsnjnmzccfptyt +nkhsdkhqtzqbphhg +aqcubmfkczlaxiyb +moziflxpsfubucmv +srdgnnjtfehiimqx +pwfalehdfyykrohf +sysxssmvewyfjrve +brsemdzosgqvvlxe +bimbjoshuvflkiat +hkgjasmljkpkwwku +sbnmwjvodygobpqc +bbbqycejueruihhd +corawswvlvneipyc +gcyhknmwsczcxedh +kppakbffdhntmcqp +ynulzwkfaemkcefp +pyroowjekeurlbii +iwksighrswdcnmxf +glokrdmugreygnsg +xkmvvumnfzckryop +aesviofpufygschi +csloawlirnegsssq +fkqdqqmlzuxbkzbc +uzlhzcfenxdfjdzp +poaaidrktteusvyf +zrlyfzmjzfvivcfr +qwjulskbniitgqtx +gjeszjksbfsuejki +vczdejdbfixbduaq +knjdrjthitjxluth +jweydeginrnicirl +bottrfgccqhyycsl +eiquffofoadmbuhk +lbqfutmzoksscswf +xfmdvnvfcnzjprba +uvugkjbkhlaoxmyx +wadlgtpczgvcaqqv +inzrszbtossflsxk +dbzbtashaartczrj +qbjiqpccefcfkvod +hluujmokjywotvzy +thwlliksfztcmwzh +arahybspdaqdexrq +nuojrmsgyipdvwyx +hnajdwjwmzattvst +sulcgaxezkprjbgu +rjowuugwdpkjtypw +oeugzwuhnrgiaqga +wvxnyymwftfoswij +pqxklzkjpcqscvde +tuymjzknntekglqj +odteewktugcwlhln +exsptotlfecmgehc +eeswfcijtvzgrqel +vjhrkiwmunuiwqau +zhlixepkeijoemne +pavfsmwesuvebzdd +jzovbklnngfdmyws +nbajyohtzfeoiixz +ciozmhrsjzrwxvhz +gwucrxieqbaqfjuv +uayrxrltnohexawc +flmrbhwsfbcquffm +gjyabmngkitawlxc +rwwtggvaygfbovhg +xquiegaisynictjq +oudzwuhexrwwdbyy +lengxmguyrwhrebb +uklxpglldbgqsjls +dbmvlfeyguydfsxq +zspdwdqcrmtmdtsc +mqfnzwbfqlauvrgc +amcrkzptgacywvhv +ndxmskrwrqysrndf +mwjyhsufeqhwisju +srlrukoaenyevykt +tnpjtpwawrxbikct +geczalxmgxejulcv +tvkcbqdhmuwcxqci +tiovluvwezwwgaox +zrjhtbgajkjqzmfo +vcrywduwsklepirs +lofequdigsszuioy +wxsdzomkjqymlzat +iabaczqtrfbmypuy +ibdlmudbajikcncr +rqcvkzsbwmavdwnv +ypxoyjelhllhbeog +fdnszbkezyjbttbg +uxnhrldastpdjkdz +xfrjbehtxnlyzcka +omjyfhbibqwgcpbv +eguucnoxaoprszmp +xfpypldgcmcllyzz +aypnmgqjxjqceelv +mgzharymejlafvgf +tzowgwsubbaigdok +ilsehjqpcjwmylxc +pfmouwntfhfnmrwk +csgokybgdqwnduwp +eaxwvxvvwbrovypz +nmluqvobbbmdiwwb +lnkminvfjjzqbmio +mjiiqzycqdhfietz +towlrzriicyraevq +obiloewdvbrsfwjo +lmeooaajlthsfltw +ichygipzpykkesrw +gfysloxmqdsfskvt +saqzntehjldvwtsx +pqddoemaufpfcaew +mjrxvbvwcreaybwe +ngfbrwfqnxqosoai +nesyewxreiqvhald +kqhqdlquywotcyfy +liliptyoqujensfi +nsahsaxvaepzneqq +zaickulfjajhctye +gxjzahtgbgbabtht +koxbuopaqhlsyhrp +jhzejdjidqqtjnwe +dekrkdvprfqpcqki +linwlombdqtdeyop +dvckqqbnigdcmwmx +yaxygbjpzkvnnebv +rlzkdkgaagmcpxah +cfzuyxivtknirqvt +obivkajhsjnrxxhn +lmjhayymgpseuynn +bbjyewkwadaipyju +lmzyhwomfypoftuu +gtzhqlgltvatxack +jfflcfaqqkrrltgq +txoummmnzfrlrmcg +ohemsbfuqqpucups +imsfvowcbieotlok +tcnsnccdszxfcyde +qkcdtkwuaquajazz +arcfnhmdjezdbqku +srnocgyqrlcvlhkb +mppbzvfmcdirbyfw +xiuarktilpldwgwd +ypufwmhrvzqmexpc +itpdnsfkwgrdujmj +cmpxnodtsswkyxkr +wayyxtjklfrmvbfp +mfaxphcnjczhbbwy +sjxhgwdnqcofbdra +pnxmujuylqccjvjm +ivamtjbvairwjqwl +deijtmzgpfxrclss +bzkqcaqagsynlaer +tycefobvxcvwaulz +ctbhnywezxkdsswf +urrxxebxrthtjvib +fpfelcigwqwdjucv +ngfcyyqpqulwcphb +rltkzsiipkpzlgpw +qfdsymzwhqqdkykc +balrhhxipoqzmihj +rnwalxgigswxomga +ghqnxeogckshphgr +lyyaentdizaumnla +exriodwfzosbeoib +speswfggibijfejk +yxmxgfhvmshqszrq +hcqhngvahzgawjga +qmhlsrfpesmeksur +eviafjejygakodla +kvcfeiqhynqadbzv +fusvyhowslfzqttg +girqmvwmcvntrwau +yuavizroykfkdekz +jmcwohvmzvowrhxf +kzimlcpavapynfue +wjudcdtrewfabppq +yqpteuxqgbmqfgxh +xdgiszbuhdognniu +jsguxfwhpftlcjoh +whakkvspssgjzxre +ggvnvjurlyhhijgm +krvbhjybnpemeptr +pqedgfojyjybfbzr +jzhcrsgmnkwwtpdo +yyscxoxwofslncmp +gzjhnxytmyntzths +iteigbnqbtpvqumi +zjevfzusnjukqpfw +xippcyhkfuounxqk +mcnhrcfonfdgpkyh +pinkcyuhjkexbmzj +lotxrswlxbxlxufs +fmqajrtoabpckbnu +wfkwsgmcffdgaqxg +qfrsiwnohoyfbidr +czfqbsbmiuyusaqs +ieknnjeecucghpoo +cevdgqnugupvmsge +gjkajcyjnxdrtuvr +udzhrargnujxiclq +zqqrhhmjwermjssg +ggdivtmgoqajydzz +wnpfsgtxowkjiivl +afbhqawjbotxnqpd +xjpkifkhfjeqifdn +oyfggzsstfhvticp +kercaetahymeawxy +khphblhcgmbupmzt +iggoqtqpvaebtiol +ofknifysuasshoya +qxuewroccsbogrbv +apsbnbkiopopytgu +zyahfroovfjlythh +bxhjwfgeuxlviydq +uvbhdtvaypasaswa +qamcjzrmesqgqdiz +hjnjyzrxntiycyel +wkcrwqwniczwdxgq +hibxlvkqakusswkx +mzjyuenepwdgrkty +tvywsoqslfsulses +jqwcwuuisrclircv +xanwaoebfrzhurct +ykriratovsvxxasf +qyebvtqqxbjuuwuo +telrvlwvriylnder +acksrrptgnhkeiaa +yemwfjhiqlzsvdxf +banrornfkcymmkcc +ytbhxvaeiigjpcgm +crepyazgxquposkn +xlqwdrytzwnxzwzv +xtrbfbwopxscftps +kwbytzukgseeyjla +qtfdvavvjogybxjg +ytbmvmrcxwfkgvzw +nbscbdskdeocnfzr +sqquwjbdxsxhcseg +ewqxhigqcgszfsuw +cvkyfcyfmubzwsee +dcoawetekigxgygd +ohgqnqhfimyuqhvi +otisopzzpvnhctte +bauieohjejamzien +ewnnopzkujbvhwce +aeyqlskpaehagdiv +pncudvivwnnqspxy +ytugesilgveokxcg +zoidxeelqdjesxpr +ducjccsuaygfchzj +smhgllqqqcjfubfc +nlbyyywergronmir +prdawpbjhrzsbsvj +nmgzhnjhlpcplmui +eflaogtjghdjmxxz +qolvpngucbkprrdc +ixywxcienveltgho +mwnpqtocagenkxut +iskrfbwxonkguywx +ouhtbvcaczqzmpua +srewprgddfgmdbao +dyufrltacelchlvu +czmzcbrkecixuwzz +dtbeojcztzauofuk +prrgoehpqhngfgmw +baolzvfrrevxsyke +zqadgxshwiarkzwh +vsackherluvurqqj +surbpxdulvcvgjbd +wqxytarcxzgxhvtx +vbcubqvejcfsgrac +zqnjfeapshjowzja +hekvbhtainkvbynx +knnugxoktxpvoxnh +knoaalcefpgtvlwm +qoakaunowmsuvkus +ypkvlzcduzlezqcb +ujhcagawtyepyogh +wsilcrxncnffaxjf +gbbycjuscquaycrk +aduojapeaqwivnly +ceafyxrakviagcjy +nntajnghicgnrlst +vdodpeherjmmvbje +wyyhrnegblwvdobn +xlfurpghkpbzhhif +xyppnjiljvirmqjo +kglzqahipnddanpi +omjateouxikwxowr +ocifnoopfglmndcx +emudcukfbadyijev +ooktviixetfddfmh +wtvrhloyjewdeycg +cgjncqykgutfjhvb +nkwvpswppeffmwad +hqbcmfhzkxmnrivg +mdskbvzguxvieilr +anjcvqpavhdloaqh +erksespdevjylenq +fadxwbmisazyegup +iyuiffjmcaahowhj +ygkdezmynmltodbv +fytneukxqkjattvh +woerxfadbfrvdcnz +iwsljvkyfastccoa +movylhjranlorofe +drdmicdaiwukemep +knfgtsmuhfcvvshg +ibstpbevqmdlhajn +tstwsswswrxlzrqs +estyydmzothggudf +jezogwvymvikszwa +izmqcwdyggibliet +nzpxbegurwnwrnca +kzkojelnvkwfublh +xqcssgozuxfqtiwi +tcdoigumjrgvczfv +ikcjyubjmylkwlwq +kqfivwystpqzvhan +bzukgvyoqewniivj +iduapzclhhyfladn +fbpyzxdfmkrtfaeg +yzsmlbnftftgwadz diff --git a/advent06.ipynb b/advent06.ipynb new file mode 100644 index 0000000..da4d1de --- /dev/null +++ b/advent06.ipynb @@ -0,0 +1,505 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "pi6 = open('advent06.txt').read().strip()" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[[False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False]]" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "grid = [list([False]*10) for _ in range(10)]\n", + "grid" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[[False, False, False, False, False, False, False, False, False, False],\n", + " [False, True, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False],\n", + " [False, False, False, False, False, False, False, False, False, False]]" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "grid[1][1] = True\n", + "grid" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def print_grid(grid):\n", + " print('\\n'.join(''.join('*' if l else '.' for l in line) for line in grid))" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "..........\n", + ".*........\n", + "..........\n", + "..........\n", + "..........\n", + "..........\n", + "..........\n", + "..........\n", + "..........\n", + "..........\n" + ] + } + ], + "source": [ + "print_grid(grid)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def turn_on(r1, c1, r2, c2, grid):\n", + " for r in range(r1, r2+1):\n", + " for c in range(c1, c2+1):\n", + " grid[r][c] = True " + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def turn_off(r1, c1, r2, c2, grid):\n", + " for r in range(r1, r2+1):\n", + " for c in range(c1, c2+1):\n", + " grid[r][c] = False " + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def toggle(r1, c1, r2, c2, grid):\n", + " for r in range(r1, r2+1):\n", + " for c in range(c1, c2+1):\n", + " grid[r][c] = not grid[r][c] " + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "****......\n", + "****......\n", + "****......\n", + "**..***...\n", + "**........\n", + "**.....**.\n", + "****...**.\n", + ".........*\n", + ".......***\n", + ".......***\n" + ] + } + ], + "source": [ + "grid = [list([False]*10) for _ in range(10)]\n", + "turn_on(3, 2, 5, 6, grid)\n", + "turn_off(4, 4, 7, 7, grid)\n", + "toggle(0, 0, 6, 3, grid)\n", + "turn_on(7, 7, 9, 9, grid)\n", + "toggle(5, 7, 7, 8, grid)\n", + "print_grid(grid)" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "36" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sum(sum(line) for line in grid)" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def parse(line):\n", + " words = line.split(' ')\n", + " if line.startswith('turn'):\n", + " command = words[1]\n", + " s = words[2].split(',')\n", + " f = words[4].split(',')\n", + " else:\n", + " command = words[0]\n", + " s = words[1].split(',')\n", + " f = words[3].split(',')\n", + " # print(command, s, f)\n", + " r1 = min(int(s[0]), int(f[0]))\n", + " r2 = max(int(s[0]), int(f[0]))\n", + " c1 = min(int(s[1]), int(f[1]))\n", + " c2 = max(int(s[1]), int(f[1]))\n", + " return command, r1, c1, r2, c2" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "('toggle', 489, 959, 759, 964)" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "parse('toggle 489,959 through 759,964')" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def do_line(line, grid):\n", + " command, r1, c1, r2, c2 = parse(line)\n", + " if command == 'on':\n", + " turn_on(r1, c1, r2, c2, grid)\n", + " elif command == 'off':\n", + " turn_off(r1, c1, r2, c2, grid)\n", + " else:\n", + " toggle(r1, c1, r2, c2, grid)" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "grid = [list([False]*1000) for _ in range(1000)]" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "569999" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "grid = [list([False]*1000) for _ in range(1000)]\n", + "for line in pi6.splitlines():\n", + " do_line(line.strip(), grid)\n", + "sum(sum(line) for line in grid)" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "turn on 489,959 through 759,964\n" + ] + }, + { + "data": { + "text/plain": [ + "1626" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "grid = [list([False]*1000) for _ in range(1000)]\n", + "do_line(pi6.splitlines()[0].strip(), grid)\n", + "print(pi6.splitlines()[0].strip())\n", + "sum(sum(line) for line in grid)" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "1626" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "((759-489)+1)*((964-959)+1)" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def do_line2(line, grid):\n", + " command, r1, c1, r2, c2 = parse(line)\n", + " if command == 'on':\n", + " turn_on2(r1, c1, r2, c2, grid)\n", + " elif command == 'off':\n", + " turn_off2(r1, c1, r2, c2, grid)\n", + " else:\n", + " toggle2(r1, c1, r2, c2, grid)" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def turn_on2(r1, c1, r2, c2, grid):\n", + " for r in range(r1, r2+1):\n", + " for c in range(c1, c2+1):\n", + " grid[r][c] +=1 \n", + "\n", + "def turn_off2(r1, c1, r2, c2, grid):\n", + " for r in range(r1, r2+1):\n", + " for c in range(c1, c2+1):\n", + " grid[r][c] -= 1\n", + " if grid[r][c] < 0:\n", + " grid[r][c] = 0\n", + "\n", + "def toggle2(r1, c1, r2, c2, grid):\n", + " for r in range(r1, r2+1):\n", + " for c in range(c1, c2+1):\n", + " grid[r][c] += 2" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "17836115" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "grid2 = [list([0]*1000) for _ in range(1000)]\n", + "for line in pi6.splitlines():\n", + " do_line2(line.strip(), grid2)\n", + "sum(sum(line) for line in grid2)" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", + " [0, 2, 0, 0, 0, 0, 0, 0, 0, 0],\n", + " [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", + " [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", + " [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", + " [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", + " [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", + " [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", + " [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", + " [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "grid = [list([0]*10) for _ in range(10)]\n", + "grid[1][1] += 2\n", + "grid" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.4.3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/advent06.txt b/advent06.txt new file mode 100644 index 0000000..5fcc942 --- /dev/null +++ b/advent06.txt @@ -0,0 +1,300 @@ +turn on 489,959 through 759,964 +turn off 820,516 through 871,914 +turn off 427,423 through 929,502 +turn on 774,14 through 977,877 +turn on 410,146 through 864,337 +turn on 931,331 through 939,812 +turn off 756,53 through 923,339 +turn off 313,787 through 545,979 +turn off 12,823 through 102,934 +toggle 756,965 through 812,992 +turn off 743,684 through 789,958 +toggle 120,314 through 745,489 +toggle 692,845 through 866,994 +turn off 587,176 through 850,273 +turn off 674,321 through 793,388 +toggle 749,672 through 973,965 +turn on 943,30 through 990,907 +turn on 296,50 through 729,664 +turn on 212,957 through 490,987 +toggle 171,31 through 688,88 +turn off 991,989 through 994,998 +turn off 913,943 through 958,953 +turn off 278,258 through 367,386 +toggle 275,796 through 493,971 +turn off 70,873 through 798,923 +toggle 258,985 through 663,998 +turn on 601,259 through 831,486 +turn off 914,94 through 941,102 +turn off 558,161 through 994,647 +turn on 119,662 through 760,838 +toggle 378,775 through 526,852 +turn off 384,670 through 674,972 +turn off 249,41 through 270,936 +turn on 614,742 through 769,780 +turn on 427,70 through 575,441 +turn on 410,478 through 985,753 +turn off 619,46 through 931,342 +turn on 284,55 through 768,922 +turn off 40,592 through 728,685 +turn on 825,291 through 956,950 +turn on 147,843 through 592,909 +turn off 218,675 through 972,911 +toggle 249,291 through 350,960 +turn off 556,80 through 967,675 +toggle 609,148 through 968,279 +toggle 217,605 through 961,862 +toggle 407,177 through 548,910 +toggle 400,936 through 599,938 +turn off 721,101 through 925,455 +turn on 268,631 through 735,814 +toggle 549,969 through 612,991 +toggle 553,268 through 689,432 +turn off 817,668 through 889,897 +toggle 801,544 through 858,556 +toggle 615,729 through 832,951 +turn off 427,477 through 958,948 +turn on 164,49 through 852,946 +turn on 542,449 through 774,776 +turn off 923,196 through 980,446 +toggle 90,310 through 718,846 +turn off 657,215 through 744,252 +turn off 800,239 through 811,712 +turn on 502,90 through 619,760 +toggle 649,512 through 862,844 +turn off 334,903 through 823,935 +turn off 630,233 through 839,445 +turn on 713,67 through 839,865 +turn on 932,50 through 982,411 +turn off 480,729 through 984,910 +turn on 100,219 through 796,395 +turn on 758,108 through 850,950 +turn off 427,276 through 439,938 +turn on 178,284 through 670,536 +toggle 540,27 through 625,102 +turn off 906,722 through 936,948 +toggle 345,418 through 859,627 +toggle 175,775 through 580,781 +toggle 863,28 through 929,735 +turn off 824,858 through 905,973 +toggle 752,312 through 863,425 +turn on 985,716 through 988,852 +turn off 68,504 through 763,745 +toggle 76,209 through 810,720 +turn off 657,607 through 676,664 +toggle 596,869 through 896,921 +turn off 915,411 through 968,945 +turn off 368,39 through 902,986 +turn on 11,549 through 393,597 +turn off 842,893 through 976,911 +toggle 274,106 through 581,329 +toggle 406,403 through 780,950 +toggle 408,988 through 500,994 +toggle 217,73 through 826,951 +turn on 917,872 through 961,911 +toggle 394,34 through 510,572 +toggle 424,603 through 583,626 +toggle 106,159 through 755,738 +turn off 244,610 through 472,709 +turn on 350,265 through 884,690 +turn on 688,184 through 928,280 +toggle 279,443 through 720,797 +turn off 615,493 through 888,610 +toggle 118,413 through 736,632 +turn on 798,782 through 829,813 +turn off 250,934 through 442,972 +turn on 68,503 through 400,949 +toggle 297,482 through 313,871 +toggle 710,3 through 839,859 +turn on 125,300 through 546,888 +toggle 482,39 through 584,159 +turn off 536,89 through 765,962 +turn on 530,518 through 843,676 +turn on 994,467 through 994,676 +turn on 623,628 through 744,927 +toggle 704,912 through 837,983 +turn on 154,364 through 517,412 +toggle 344,409 through 780,524 +turn off 578,740 through 725,879 +turn on 251,933 through 632,957 +turn on 827,705 through 971,789 +toggle 191,282 through 470,929 +toggle 324,525 through 446,867 +toggle 534,343 through 874,971 +toggle 550,650 through 633,980 +toggle 837,404 through 881,915 +toggle 338,881 through 845,905 +turn on 469,462 through 750,696 +turn on 741,703 through 892,870 +turn off 570,215 through 733,562 +turn on 445,576 through 870,775 +turn on 466,747 through 554,878 +turn off 820,453 through 868,712 +turn off 892,706 through 938,792 +turn off 300,238 through 894,746 +turn off 306,44 through 457,444 +turn off 912,569 through 967,963 +toggle 109,756 through 297,867 +turn on 37,546 through 41,951 +turn on 321,637 through 790,910 +toggle 66,50 through 579,301 +toggle 933,221 through 933,791 +turn on 486,676 through 878,797 +turn on 417,231 through 556,317 +toggle 904,468 through 981,873 +turn on 417,675 through 749,712 +turn on 692,371 through 821,842 +toggle 324,73 through 830,543 +turn on 912,490 through 977,757 +turn off 634,872 through 902,949 +toggle 266,779 through 870,798 +turn on 772,982 through 990,996 +turn off 607,46 through 798,559 +turn on 295,602 through 963,987 +turn on 657,86 through 944,742 +turn off 334,639 through 456,821 +turn off 997,667 through 997,670 +turn off 725,832 through 951,945 +turn off 30,120 through 952,984 +turn on 860,965 through 917,976 +toggle 471,997 through 840,998 +turn off 319,307 through 928,504 +toggle 823,631 through 940,908 +toggle 969,984 through 981,993 +turn off 691,319 through 865,954 +toggle 911,926 through 938,929 +turn on 953,937 through 968,991 +toggle 914,643 through 975,840 +turn on 266,982 through 436,996 +turn off 101,896 through 321,932 +turn off 193,852 through 751,885 +turn off 576,532 through 863,684 +turn on 761,456 through 940,783 +turn on 20,290 through 398,933 +turn off 435,335 through 644,652 +turn on 830,569 through 905,770 +turn off 630,517 through 905,654 +turn on 664,53 through 886,976 +toggle 275,416 through 408,719 +turn on 370,621 through 515,793 +turn on 483,373 through 654,749 +turn on 656,786 through 847,928 +turn off 532,752 through 945,974 +toggle 301,150 through 880,792 +turn off 951,488 through 958,952 +turn on 207,729 through 882,828 +toggle 694,532 through 973,961 +toggle 676,639 through 891,802 +turn off 653,6 through 905,519 +toggle 391,109 through 418,312 +turn on 877,423 through 957,932 +turn on 340,145 through 563,522 +turn off 978,467 through 988,895 +turn off 396,418 through 420,885 +turn off 31,308 through 816,316 +turn on 107,675 through 758,824 +turn on 61,82 through 789,876 +turn on 750,743 through 754,760 +toggle 88,733 through 736,968 +turn off 754,349 through 849,897 +toggle 157,50 through 975,781 +turn off 230,231 through 865,842 +turn off 516,317 through 630,329 +turn off 697,820 through 829,903 +turn on 218,250 through 271,732 +toggle 56,167 through 404,431 +toggle 626,891 through 680,927 +toggle 370,207 through 791,514 +toggle 860,74 through 949,888 +turn on 416,527 through 616,541 +turn off 745,449 through 786,908 +turn on 485,554 through 689,689 +turn on 586,62 through 693,141 +toggle 506,759 through 768,829 +turn on 473,109 through 929,166 +turn on 760,617 through 773,789 +toggle 595,683 through 618,789 +turn off 210,775 through 825,972 +toggle 12,426 through 179,982 +turn on 774,539 through 778,786 +turn on 102,498 through 121,807 +turn off 706,897 through 834,965 +turn off 678,529 through 824,627 +turn on 7,765 through 615,870 +turn off 730,872 through 974,943 +turn off 595,626 through 836,711 +turn off 215,424 through 841,959 +toggle 341,780 through 861,813 +toggle 507,503 through 568,822 +turn on 252,603 through 349,655 +toggle 93,521 through 154,834 +turn on 565,682 through 951,954 +turn on 544,318 through 703,418 +toggle 756,953 through 891,964 +turn on 531,123 through 856,991 +turn on 148,315 through 776,559 +turn off 925,835 through 963,971 +turn on 895,944 through 967,964 +turn off 102,527 through 650,747 +toggle 626,105 through 738,720 +turn off 160,75 through 384,922 +toggle 813,724 through 903,941 +turn on 207,107 through 982,849 +toggle 750,505 through 961,697 +toggle 105,410 through 885,819 +turn on 226,104 through 298,283 +turn off 224,604 through 508,762 +turn on 477,368 through 523,506 +turn off 477,901 through 627,936 +turn off 887,131 through 889,670 +turn on 896,994 through 938,999 +toggle 401,580 through 493,728 +toggle 987,184 through 991,205 +turn on 821,643 through 882,674 +toggle 784,940 through 968,959 +turn off 251,293 through 274,632 +turn off 339,840 through 341,844 +turn off 675,351 through 675,836 +toggle 918,857 through 944,886 +toggle 70,253 through 918,736 +turn off 612,604 through 772,680 +turn off 277,40 through 828,348 +toggle 692,139 through 698,880 +toggle 124,446 through 883,453 +toggle 969,932 through 990,945 +toggle 855,692 through 993,693 +toggle 722,472 through 887,899 +toggle 978,149 through 985,442 +toggle 837,540 through 916,889 +turn off 612,2 through 835,82 +toggle 560,767 through 878,856 +turn on 461,734 through 524,991 +toggle 206,824 through 976,912 +turn on 826,610 through 879,892 +turn on 577,699 through 956,933 +turn off 9,250 through 50,529 +turn off 77,657 through 817,677 +turn on 68,419 through 86,426 +turn on 991,720 through 992,784 +turn on 668,20 through 935,470 +turn off 133,418 through 613,458 +turn off 487,286 through 540,328 +toggle 247,874 through 840,955 +toggle 301,808 through 754,970 +turn off 34,194 through 578,203 +turn off 451,49 through 492,921 +turn on 907,256 through 912,737 +turn off 479,305 through 702,587 +turn on 545,583 through 732,749 +toggle 11,16 through 725,868 +turn on 965,343 through 986,908 +turn on 674,953 through 820,965 +toggle 398,147 through 504,583 +turn off 778,194 through 898,298 +turn on 179,140 through 350,852 +turn off 241,118 through 530,832 +turn off 41,447 through 932,737 +turn off 820,663 through 832,982 +turn on 550,460 through 964,782 +turn on 31,760 through 655,892 +toggle 628,958 through 811,992 \ No newline at end of file diff --git a/advent07.ipynb b/advent07.ipynb new file mode 100644 index 0000000..e743a8d --- /dev/null +++ b/advent07.ipynb @@ -0,0 +1,989 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "pi7 = \"\"\"lf AND lq -> ls\n", + "iu RSHIFT 1 -> jn\n", + "bo OR bu -> bv\n", + "gj RSHIFT 1 -> hc\n", + "et RSHIFT 2 -> eu\n", + "bv AND bx -> by\n", + "is OR it -> iu\n", + "b OR n -> o\n", + "gf OR ge -> gg\n", + "NOT kt -> ku\n", + "ea AND eb -> ed\n", + "kl OR kr -> ks\n", + "hi AND hk -> hl\n", + "au AND av -> ax\n", + "lf RSHIFT 2 -> lg\n", + "dd RSHIFT 3 -> df\n", + "eu AND fa -> fc\n", + "df AND dg -> di\n", + "ip LSHIFT 15 -> it\n", + "NOT el -> em\n", + "et OR fe -> ff\n", + "fj LSHIFT 15 -> fn\n", + "t OR s -> u\n", + "ly OR lz -> ma\n", + "ko AND kq -> kr\n", + "NOT fx -> fy\n", + "et RSHIFT 1 -> fm\n", + "eu OR fa -> fb\n", + "dd RSHIFT 2 -> de\n", + "NOT go -> gp\n", + "kb AND kd -> ke\n", + "hg OR hh -> hi\n", + "jm LSHIFT 1 -> kg\n", + "NOT cn -> co\n", + "jp RSHIFT 2 -> jq\n", + "jp RSHIFT 5 -> js\n", + "1 AND io -> ip\n", + "eo LSHIFT 15 -> es\n", + "1 AND jj -> jk\n", + "g AND i -> j\n", + "ci RSHIFT 3 -> ck\n", + "gn AND gp -> gq\n", + "fs AND fu -> fv\n", + "lj AND ll -> lm\n", + "jk LSHIFT 15 -> jo\n", + "iu RSHIFT 3 -> iw\n", + "NOT ii -> ij\n", + "1 AND cc -> cd\n", + "bn RSHIFT 3 -> bp\n", + "NOT gw -> gx\n", + "NOT ft -> fu\n", + "jn OR jo -> jp\n", + "iv OR jb -> jc\n", + "hv OR hu -> hw\n", + "19138 -> b\n", + "gj RSHIFT 5 -> gm\n", + "hq AND hs -> ht\n", + "dy RSHIFT 1 -> er\n", + "ao OR an -> ap\n", + "ld OR le -> lf\n", + "bk LSHIFT 1 -> ce\n", + "bz AND cb -> cc\n", + "bi LSHIFT 15 -> bm\n", + "il AND in -> io\n", + "af AND ah -> ai\n", + "as RSHIFT 1 -> bl\n", + "lf RSHIFT 3 -> lh\n", + "er OR es -> et\n", + "NOT ax -> ay\n", + "ci RSHIFT 1 -> db\n", + "et AND fe -> fg\n", + "lg OR lm -> ln\n", + "k AND m -> n\n", + "hz RSHIFT 2 -> ia\n", + "kh LSHIFT 1 -> lb\n", + "NOT ey -> ez\n", + "NOT di -> dj\n", + "dz OR ef -> eg\n", + "lx -> a\n", + "NOT iz -> ja\n", + "gz LSHIFT 15 -> hd\n", + "ce OR cd -> cf\n", + "fq AND fr -> ft\n", + "at AND az -> bb\n", + "ha OR gz -> hb\n", + "fp AND fv -> fx\n", + "NOT gb -> gc\n", + "ia AND ig -> ii\n", + "gl OR gm -> gn\n", + "0 -> c\n", + "NOT ca -> cb\n", + "bn RSHIFT 1 -> cg\n", + "c LSHIFT 1 -> t\n", + "iw OR ix -> iy\n", + "kg OR kf -> kh\n", + "dy OR ej -> ek\n", + "km AND kn -> kp\n", + "NOT fc -> fd\n", + "hz RSHIFT 3 -> ib\n", + "NOT dq -> dr\n", + "NOT fg -> fh\n", + "dy RSHIFT 2 -> dz\n", + "kk RSHIFT 2 -> kl\n", + "1 AND fi -> fj\n", + "NOT hr -> hs\n", + "jp RSHIFT 1 -> ki\n", + "bl OR bm -> bn\n", + "1 AND gy -> gz\n", + "gr AND gt -> gu\n", + "db OR dc -> dd\n", + "de OR dk -> dl\n", + "as RSHIFT 5 -> av\n", + "lf RSHIFT 5 -> li\n", + "hm AND ho -> hp\n", + "cg OR ch -> ci\n", + "gj AND gu -> gw\n", + "ge LSHIFT 15 -> gi\n", + "e OR f -> g\n", + "fp OR fv -> fw\n", + "fb AND fd -> fe\n", + "cd LSHIFT 15 -> ch\n", + "b RSHIFT 1 -> v\n", + "at OR az -> ba\n", + "bn RSHIFT 2 -> bo\n", + "lh AND li -> lk\n", + "dl AND dn -> do\n", + "eg AND ei -> ej\n", + "ex AND ez -> fa\n", + "NOT kp -> kq\n", + "NOT lk -> ll\n", + "x AND ai -> ak\n", + "jp OR ka -> kb\n", + "NOT jd -> je\n", + "iy AND ja -> jb\n", + "jp RSHIFT 3 -> jr\n", + "fo OR fz -> ga\n", + "df OR dg -> dh\n", + "gj RSHIFT 2 -> gk\n", + "gj OR gu -> gv\n", + "NOT jh -> ji\n", + "ap LSHIFT 1 -> bj\n", + "NOT ls -> lt\n", + "ir LSHIFT 1 -> jl\n", + "bn AND by -> ca\n", + "lv LSHIFT 15 -> lz\n", + "ba AND bc -> bd\n", + "cy LSHIFT 15 -> dc\n", + "ln AND lp -> lq\n", + "x RSHIFT 1 -> aq\n", + "gk OR gq -> gr\n", + "NOT kx -> ky\n", + "jg AND ji -> jj\n", + "bn OR by -> bz\n", + "fl LSHIFT 1 -> gf\n", + "bp OR bq -> br\n", + "he OR hp -> hq\n", + "et RSHIFT 5 -> ew\n", + "iu RSHIFT 2 -> iv\n", + "gl AND gm -> go\n", + "x OR ai -> aj\n", + "hc OR hd -> he\n", + "lg AND lm -> lo\n", + "lh OR li -> lj\n", + "da LSHIFT 1 -> du\n", + "fo RSHIFT 2 -> fp\n", + "gk AND gq -> gs\n", + "bj OR bi -> bk\n", + "lf OR lq -> lr\n", + "cj AND cp -> cr\n", + "hu LSHIFT 15 -> hy\n", + "1 AND bh -> bi\n", + "fo RSHIFT 3 -> fq\n", + "NOT lo -> lp\n", + "hw LSHIFT 1 -> iq\n", + "dd RSHIFT 1 -> dw\n", + "dt LSHIFT 15 -> dx\n", + "dy AND ej -> el\n", + "an LSHIFT 15 -> ar\n", + "aq OR ar -> as\n", + "1 AND r -> s\n", + "fw AND fy -> fz\n", + "NOT im -> in\n", + "et RSHIFT 3 -> ev\n", + "1 AND ds -> dt\n", + "ec AND ee -> ef\n", + "NOT ak -> al\n", + "jl OR jk -> jm\n", + "1 AND en -> eo\n", + "lb OR la -> lc\n", + "iu AND jf -> jh\n", + "iu RSHIFT 5 -> ix\n", + "bo AND bu -> bw\n", + "cz OR cy -> da\n", + "iv AND jb -> jd\n", + "iw AND ix -> iz\n", + "lf RSHIFT 1 -> ly\n", + "iu OR jf -> jg\n", + "NOT dm -> dn\n", + "lw OR lv -> lx\n", + "gg LSHIFT 1 -> ha\n", + "lr AND lt -> lu\n", + "fm OR fn -> fo\n", + "he RSHIFT 3 -> hg\n", + "aj AND al -> am\n", + "1 AND kz -> la\n", + "dy RSHIFT 5 -> eb\n", + "jc AND je -> jf\n", + "cm AND co -> cp\n", + "gv AND gx -> gy\n", + "ev OR ew -> ex\n", + "jp AND ka -> kc\n", + "fk OR fj -> fl\n", + "dy RSHIFT 3 -> ea\n", + "NOT bs -> bt\n", + "NOT ag -> ah\n", + "dz AND ef -> eh\n", + "cf LSHIFT 1 -> cz\n", + "NOT cv -> cw\n", + "1 AND cx -> cy\n", + "de AND dk -> dm\n", + "ck AND cl -> cn\n", + "x RSHIFT 5 -> aa\n", + "dv LSHIFT 1 -> ep\n", + "he RSHIFT 2 -> hf\n", + "NOT bw -> bx\n", + "ck OR cl -> cm\n", + "bp AND bq -> bs\n", + "as OR bd -> be\n", + "he AND hp -> hr\n", + "ev AND ew -> ey\n", + "1 AND lu -> lv\n", + "kk RSHIFT 3 -> km\n", + "b AND n -> p\n", + "NOT kc -> kd\n", + "lc LSHIFT 1 -> lw\n", + "km OR kn -> ko\n", + "id AND if -> ig\n", + "ih AND ij -> ik\n", + "jr AND js -> ju\n", + "ci RSHIFT 5 -> cl\n", + "hz RSHIFT 1 -> is\n", + "1 AND ke -> kf\n", + "NOT gs -> gt\n", + "aw AND ay -> az\n", + "x RSHIFT 2 -> y\n", + "ab AND ad -> ae\n", + "ff AND fh -> fi\n", + "ci AND ct -> cv\n", + "eq LSHIFT 1 -> fk\n", + "gj RSHIFT 3 -> gl\n", + "u LSHIFT 1 -> ao\n", + "NOT bb -> bc\n", + "NOT hj -> hk\n", + "kw AND ky -> kz\n", + "as AND bd -> bf\n", + "dw OR dx -> dy\n", + "br AND bt -> bu\n", + "kk AND kv -> kx\n", + "ep OR eo -> eq\n", + "he RSHIFT 1 -> hx\n", + "ki OR kj -> kk\n", + "NOT ju -> jv\n", + "ek AND em -> en\n", + "kk RSHIFT 5 -> kn\n", + "NOT eh -> ei\n", + "hx OR hy -> hz\n", + "ea OR eb -> ec\n", + "s LSHIFT 15 -> w\n", + "fo RSHIFT 1 -> gh\n", + "kk OR kv -> kw\n", + "bn RSHIFT 5 -> bq\n", + "NOT ed -> ee\n", + "1 AND ht -> hu\n", + "cu AND cw -> cx\n", + "b RSHIFT 5 -> f\n", + "kl AND kr -> kt\n", + "iq OR ip -> ir\n", + "ci RSHIFT 2 -> cj\n", + "cj OR cp -> cq\n", + "o AND q -> r\n", + "dd RSHIFT 5 -> dg\n", + "b RSHIFT 2 -> d\n", + "ks AND ku -> kv\n", + "b RSHIFT 3 -> e\n", + "d OR j -> k\n", + "NOT p -> q\n", + "NOT cr -> cs\n", + "du OR dt -> dv\n", + "kf LSHIFT 15 -> kj\n", + "NOT ac -> ad\n", + "fo RSHIFT 5 -> fr\n", + "hz OR ik -> il\n", + "jx AND jz -> ka\n", + "gh OR gi -> gj\n", + "kk RSHIFT 1 -> ld\n", + "hz RSHIFT 5 -> ic\n", + "as RSHIFT 2 -> at\n", + "NOT jy -> jz\n", + "1 AND am -> an\n", + "ci OR ct -> cu\n", + "hg AND hh -> hj\n", + "jq OR jw -> jx\n", + "v OR w -> x\n", + "la LSHIFT 15 -> le\n", + "dh AND dj -> dk\n", + "dp AND dr -> ds\n", + "jq AND jw -> jy\n", + "au OR av -> aw\n", + "NOT bf -> bg\n", + "z OR aa -> ab\n", + "ga AND gc -> gd\n", + "hz AND ik -> im\n", + "jt AND jv -> jw\n", + "z AND aa -> ac\n", + "jr OR js -> jt\n", + "hb LSHIFT 1 -> hv\n", + "hf OR hl -> hm\n", + "ib OR ic -> id\n", + "fq OR fr -> fs\n", + "cq AND cs -> ct\n", + "ia OR ig -> ih\n", + "dd OR do -> dp\n", + "d AND j -> l\n", + "ib AND ic -> ie\n", + "as RSHIFT 3 -> au\n", + "be AND bg -> bh\n", + "dd AND do -> dq\n", + "NOT l -> m\n", + "1 AND gd -> ge\n", + "y AND ae -> ag\n", + "fo AND fz -> gb\n", + "NOT ie -> if\n", + "e AND f -> h\n", + "x RSHIFT 3 -> z\n", + "y OR ae -> af\n", + "hf AND hl -> hn\n", + "NOT h -> i\n", + "NOT hn -> ho\n", + "he RSHIFT 5 -> hh\"\"\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "pi7 = open('advent07.txt').read().strip()" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "from collections import namedtuple\n", + "\n", + "Rule = namedtuple('Rule', ['command', 'antecedents', 'consequence'])" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def parse_arg(arg):\n", + " #try:\n", + " # return int(arg)\n", + " #except ValueError:\n", + " # return arg\n", + " if arg.isnumeric():\n", + " return int(arg)\n", + " else:\n", + " return arg\n", + " \n", + "def parse_rule(text):\n", + " tokens = text.strip().split(' ')\n", + " if tokens[0] == 'NOT':\n", + " rule = Rule(command=tokens[0], antecedents=[parse_arg(tokens[1])], consequence=tokens[3])\n", + " elif len(tokens) == 3:\n", + " rule = Rule(command='ASSIGN', antecedents=[parse_arg(tokens[0])], consequence=tokens[2])\n", + " else:\n", + " rule = Rule(command=tokens[1], antecedents=[parse_arg(tokens[0]), parse_arg(tokens[2])], consequence=tokens[4])\n", + " return rule" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "123 -> x: Rule(command='ASSIGN', antecedents=[123], consequence='x')\n", + "456 -> y: Rule(command='ASSIGN', antecedents=[456], consequence='y')\n", + "x AND y -> d: Rule(command='AND', antecedents=['x', 'y'], consequence='d')\n", + "x OR y -> e: Rule(command='OR', antecedents=['x', 'y'], consequence='e')\n", + "x LSHIFT 2 -> f: Rule(command='LSHIFT', antecedents=['x', 2], consequence='f')\n", + "y RSHIFT 2 -> g: Rule(command='RSHIFT', antecedents=['y', 2], consequence='g')\n", + "NOT x -> h: Rule(command='NOT', antecedents=['x'], consequence='h')\n", + "NOT y -> i: Rule(command='NOT', antecedents=['y'], consequence='i')\n", + "lx -> zz: Rule(command='ASSIGN', antecedents=['lx'], consequence='zz')\n" + ] + } + ], + "source": [ + "for r in ['123 -> x', '456 -> y', 'x AND y -> d', 'x OR y -> e', 'x LSHIFT 2 -> f', \n", + " 'y RSHIFT 2 -> g', 'NOT x -> h', 'NOT y -> i', 'lx -> zz']:\n", + " print(r, end=': ')\n", + " print(parse_rule(r))" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "def rule_can_fire(rule, known_values):\n", + " return all(isinstance(a, int) or a in known_values for a in rule.antecedents)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "rule_can_fire(parse_rule('NOT y -> f'), {'y': 12})" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def get_value(arg, known_values):\n", + " if arg in known_values:\n", + " return known_values[arg]\n", + " else:\n", + " return arg\n", + "\n", + "def fire_rule(rule, known_values):\n", + " evaluated_args = [get_value(arg, known_values) for arg in rule.antecedents]\n", + " if rule.command == 'ASSIGN':\n", + " known_values[rule.consequence] = evaluated_args[0]\n", + " elif rule.command == 'NOT':\n", + " known_values[rule.consequence] = ~evaluated_args[0] % 65536\n", + " elif rule.command == 'LSHIFT':\n", + " known_values[rule.consequence] = (evaluated_args[0] << evaluated_args[1]) % 65536\n", + " elif rule.command == 'RSHIFT':\n", + " known_values[rule.consequence] = (evaluated_args[0] >> evaluated_args[1]) % 65536\n", + " elif rule.command == 'AND':\n", + " known_values[rule.consequence] = (evaluated_args[0] & evaluated_args[1]) % 65536\n", + " elif rule.command == 'OR':\n", + " known_values[rule.consequence] = (evaluated_args[0] | evaluated_args[1]) % 65536" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "65518" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "~17 % 65536" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "339" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "rules = [parse_rule(r) for r in pi7.splitlines()]\n", + "len(rules)" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "16076" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "known = {}\n", + "while 'a' not in known:\n", + " for r in rules:\n", + " if rule_can_fire(r, known) and r.consequence not in known:\n", + " fire_rule(r, known)\n", + "known['a']" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "2797" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "known = {'b': 16076}\n", + "while 'a' not in known:\n", + " for r in rules:\n", + " if rule_can_fire(r, known) and r.consequence not in known:\n", + " fire_rule(r, known)\n", + "known['a']" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "{'a': 2797,\n", + " 'aa': 251,\n", + " 'ab': 1023,\n", + " 'ac': 232,\n", + " 'ad': 65303,\n", + " 'ae': 791,\n", + " 'af': 2015,\n", + " 'ag': 785,\n", + " 'ah': 64750,\n", + " 'ai': 1230,\n", + " 'aj': 8174,\n", + " 'ak': 1094,\n", + " 'al': 64441,\n", + " 'am': 7080,\n", + " 'an': 0,\n", + " 'ao': 0,\n", + " 'ap': 0,\n", + " 'aq': 4019,\n", + " 'ar': 0,\n", + " 'as': 4019,\n", + " 'at': 1004,\n", + " 'au': 502,\n", + " 'av': 125,\n", + " 'aw': 511,\n", + " 'ax': 116,\n", + " 'ay': 65419,\n", + " 'az': 395,\n", + " 'b': 16076,\n", + " 'ba': 1007,\n", + " 'bb': 392,\n", + " 'bc': 65143,\n", + " 'bd': 615,\n", + " 'be': 4087,\n", + " 'bf': 547,\n", + " 'bg': 64988,\n", + " 'bh': 3540,\n", + " 'bi': 0,\n", + " 'bj': 0,\n", + " 'bk': 0,\n", + " 'bl': 2009,\n", + " 'bm': 0,\n", + " 'bn': 2009,\n", + " 'bo': 502,\n", + " 'bp': 251,\n", + " 'bq': 62,\n", + " 'br': 255,\n", + " 'bs': 58,\n", + " 'bt': 65477,\n", + " 'bu': 197,\n", + " 'bv': 503,\n", + " 'bw': 196,\n", + " 'bx': 65339,\n", + " 'by': 307,\n", + " 'bz': 2043,\n", + " 'c': 0,\n", + " 'ca': 273,\n", + " 'cb': 65262,\n", + " 'cc': 1770,\n", + " 'cd': 0,\n", + " 'ce': 0,\n", + " 'cf': 0,\n", + " 'cg': 1004,\n", + " 'ch': 0,\n", + " 'ci': 1004,\n", + " 'cj': 251,\n", + " 'ck': 125,\n", + " 'cl': 31,\n", + " 'cm': 127,\n", + " 'cn': 29,\n", + " 'co': 65506,\n", + " 'cp': 98,\n", + " 'cq': 251,\n", + " 'cr': 98,\n", + " 'cs': 65437,\n", + " 'ct': 153,\n", + " 'cu': 1021,\n", + " 'cv': 136,\n", + " 'cw': 65399,\n", + " 'cx': 885,\n", + " 'cy': 1,\n", + " 'cz': 0,\n", + " 'd': 4019,\n", + " 'da': 1,\n", + " 'db': 502,\n", + " 'dc': 32768,\n", + " 'dd': 33270,\n", + " 'de': 8317,\n", + " 'df': 4158,\n", + " 'dg': 1039,\n", + " 'dh': 5183,\n", + " 'di': 14,\n", + " 'dj': 65521,\n", + " 'dk': 5169,\n", + " 'dl': 13437,\n", + " 'dm': 49,\n", + " 'dn': 65486,\n", + " 'do': 13388,\n", + " 'dp': 46590,\n", + " 'dq': 68,\n", + " 'dr': 65467,\n", + " 'ds': 46522,\n", + " 'dt': 0,\n", + " 'du': 2,\n", + " 'dv': 2,\n", + " 'dw': 16635,\n", + " 'dx': 0,\n", + " 'dy': 16635,\n", + " 'dz': 4158,\n", + " 'e': 2009,\n", + " 'ea': 2079,\n", + " 'eb': 519,\n", + " 'ec': 2591,\n", + " 'ed': 7,\n", + " 'ee': 65528,\n", + " 'ef': 2584,\n", + " 'eg': 6718,\n", + " 'eh': 24,\n", + " 'ei': 65511,\n", + " 'ej': 6694,\n", + " 'ek': 23295,\n", + " 'el': 34,\n", + " 'em': 65501,\n", + " 'en': 23261,\n", + " 'eo': 1,\n", + " 'ep': 4,\n", + " 'eq': 5,\n", + " 'er': 8317,\n", + " 'es': 32768,\n", + " 'et': 41085,\n", + " 'eu': 10271,\n", + " 'ev': 5135,\n", + " 'ew': 1283,\n", + " 'ex': 5391,\n", + " 'ey': 1027,\n", + " 'ez': 64508,\n", + " 'f': 502,\n", + " 'fa': 4364,\n", + " 'fb': 14623,\n", + " 'fc': 12,\n", + " 'fd': 65523,\n", + " 'fe': 14611,\n", + " 'ff': 47487,\n", + " 'fg': 8209,\n", + " 'fh': 57326,\n", + " 'fi': 39278,\n", + " 'fj': 0,\n", + " 'fk': 10,\n", + " 'fl': 10,\n", + " 'fm': 20542,\n", + " 'fn': 0,\n", + " 'fo': 20542,\n", + " 'fp': 5135,\n", + " 'fq': 2567,\n", + " 'fr': 641,\n", + " 'fs': 2695,\n", + " 'ft': 513,\n", + " 'fu': 65022,\n", + " 'fv': 2182,\n", + " 'fw': 7311,\n", + " 'fx': 6,\n", + " 'fy': 65529,\n", + " 'fz': 7305,\n", + " 'g': 2047,\n", + " 'ga': 23743,\n", + " 'gb': 4104,\n", + " 'gc': 61431,\n", + " 'gd': 19639,\n", + " 'ge': 1,\n", + " 'gf': 20,\n", + " 'gg': 21,\n", + " 'gh': 10271,\n", + " 'gi': 32768,\n", + " 'gj': 43039,\n", + " 'gk': 10759,\n", + " 'gl': 5379,\n", + " 'gm': 1344,\n", + " 'gn': 5443,\n", + " 'go': 1280,\n", + " 'gp': 64255,\n", + " 'gq': 4163,\n", + " 'gr': 14919,\n", + " 'gs': 3,\n", + " 'gt': 65532,\n", + " 'gu': 14916,\n", + " 'gv': 47711,\n", + " 'gw': 10244,\n", + " 'gx': 55291,\n", + " 'gy': 37467,\n", + " 'gz': 1,\n", + " 'h': 464,\n", + " 'ha': 42,\n", + " 'hb': 43,\n", + " 'hc': 21519,\n", + " 'hd': 32768,\n", + " 'he': 54287,\n", + " 'hf': 13571,\n", + " 'hg': 6785,\n", + " 'hh': 1696,\n", + " 'hi': 7841,\n", + " 'hj': 640,\n", + " 'hk': 64895,\n", + " 'hl': 7201,\n", + " 'hm': 15651,\n", + " 'hn': 5121,\n", + " 'ho': 60414,\n", + " 'hp': 10530,\n", + " 'hq': 64815,\n", + " 'hr': 2,\n", + " 'hs': 65533,\n", + " 'ht': 64813,\n", + " 'hu': 1,\n", + " 'hv': 86,\n", + " 'hw': 87,\n", + " 'hx': 27143,\n", + " 'hy': 32768,\n", + " 'hz': 59911,\n", + " 'i': 65071,\n", + " 'ia': 14977,\n", + " 'ib': 7488,\n", + " 'ic': 1872,\n", + " 'id': 8016,\n", + " 'ie': 1344,\n", + " 'if': 64191,\n", + " 'ig': 6672,\n", + " 'ih': 14993,\n", + " 'ii': 6656,\n", + " 'ij': 58879,\n", + " 'ik': 8337,\n", + " 'il': 60055,\n", + " 'im': 8193,\n", + " 'in': 57342,\n", + " 'io': 51862,\n", + " 'ip': 0,\n", + " 'iq': 174,\n", + " 'ir': 174,\n", + " 'is': 29955,\n", + " 'it': 0,\n", + " 'iu': 29955,\n", + " 'iv': 7488,\n", + " 'iw': 3744,\n", + " 'ix': 936,\n", + " 'iy': 4008,\n", + " 'iz': 672,\n", + " 'j': 1583,\n", + " 'ja': 64863,\n", + " 'jb': 3336,\n", + " 'jc': 7496,\n", + " 'jd': 3328,\n", + " 'je': 62207,\n", + " 'jf': 4168,\n", + " 'jg': 30027,\n", + " 'jh': 4096,\n", + " 'ji': 61439,\n", + " 'jj': 25931,\n", + " 'jk': 1,\n", + " 'jl': 348,\n", + " 'jm': 349,\n", + " 'jn': 14977,\n", + " 'jo': 32768,\n", + " 'jp': 47745,\n", + " 'jq': 11936,\n", + " 'jr': 5968,\n", + " 'js': 1492,\n", + " 'jt': 6100,\n", + " 'ju': 1360,\n", + " 'jv': 64175,\n", + " 'jw': 4740,\n", + " 'jx': 16036,\n", + " 'jy': 640,\n", + " 'jz': 64895,\n", + " 'k': 4031,\n", + " 'ka': 15396,\n", + " 'kb': 48805,\n", + " 'kc': 14336,\n", + " 'kd': 51199,\n", + " 'ke': 34469,\n", + " 'kf': 1,\n", + " 'kg': 698,\n", + " 'kh': 699,\n", + " 'ki': 23872,\n", + " 'kj': 32768,\n", + " 'kk': 56640,\n", + " 'kl': 14160,\n", + " 'km': 7080,\n", + " 'kn': 1770,\n", + " 'ko': 8170,\n", + " 'kp': 680,\n", + " 'kq': 64855,\n", + " 'kr': 7490,\n", + " 'ks': 16210,\n", + " 'kt': 5440,\n", + " 'ku': 60095,\n", + " 'kv': 10770,\n", + " 'kw': 65362,\n", + " 'kx': 2048,\n", + " 'ky': 63487,\n", + " 'kz': 63314,\n", + " 'l': 1571,\n", + " 'la': 0,\n", + " 'lb': 1398,\n", + " 'lc': 1398,\n", + " 'ld': 28320,\n", + " 'le': 0,\n", + " 'lf': 28320,\n", + " 'lg': 7080,\n", + " 'lh': 3540,\n", + " 'li': 885,\n", + " 'lj': 4085,\n", + " 'lk': 340,\n", + " 'll': 65195,\n", + " 'lm': 3745,\n", + " 'ln': 8105,\n", + " 'lo': 2720,\n", + " 'lp': 62815,\n", + " 'lq': 5385,\n", + " 'lr': 32681,\n", + " 'ls': 1024,\n", + " 'lt': 64511,\n", + " 'lu': 31657,\n", + " 'lv': 1,\n", + " 'lw': 2796,\n", + " 'lx': 2797,\n", + " 'ly': 14160,\n", + " 'lz': 32768,\n", + " 'm': 63964,\n", + " 'ma': 46928,\n", + " 'n': 2460,\n", + " 'o': 16348,\n", + " 'p': 2188,\n", + " 'q': 63347,\n", + " 'r': 14160,\n", + " 's': 0,\n", + " 't': 0,\n", + " 'u': 0,\n", + " 'v': 8038,\n", + " 'w': 0,\n", + " 'x': 8038,\n", + " 'y': 2009,\n", + " 'z': 1004}" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "known" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.4.3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/advent07.txt b/advent07.txt new file mode 100644 index 0000000..1034292 --- /dev/null +++ b/advent07.txt @@ -0,0 +1,339 @@ +lf AND lq -> ls +iu RSHIFT 1 -> jn +bo OR bu -> bv +gj RSHIFT 1 -> hc +et RSHIFT 2 -> eu +bv AND bx -> by +is OR it -> iu +b OR n -> o +gf OR ge -> gg +NOT kt -> ku +ea AND eb -> ed +kl OR kr -> ks +hi AND hk -> hl +au AND av -> ax +lf RSHIFT 2 -> lg +dd RSHIFT 3 -> df +eu AND fa -> fc +df AND dg -> di +ip LSHIFT 15 -> it +NOT el -> em +et OR fe -> ff +fj LSHIFT 15 -> fn +t OR s -> u +ly OR lz -> ma +ko AND kq -> kr +NOT fx -> fy +et RSHIFT 1 -> fm +eu OR fa -> fb +dd RSHIFT 2 -> de +NOT go -> gp +kb AND kd -> ke +hg OR hh -> hi +jm LSHIFT 1 -> kg +NOT cn -> co +jp RSHIFT 2 -> jq +jp RSHIFT 5 -> js +1 AND io -> ip +eo LSHIFT 15 -> es +1 AND jj -> jk +g AND i -> j +ci RSHIFT 3 -> ck +gn AND gp -> gq +fs AND fu -> fv +lj AND ll -> lm +jk LSHIFT 15 -> jo +iu RSHIFT 3 -> iw +NOT ii -> ij +1 AND cc -> cd +bn RSHIFT 3 -> bp +NOT gw -> gx +NOT ft -> fu +jn OR jo -> jp +iv OR jb -> jc +hv OR hu -> hw +19138 -> b +gj RSHIFT 5 -> gm +hq AND hs -> ht +dy RSHIFT 1 -> er +ao OR an -> ap +ld OR le -> lf +bk LSHIFT 1 -> ce +bz AND cb -> cc +bi LSHIFT 15 -> bm +il AND in -> io +af AND ah -> ai +as RSHIFT 1 -> bl +lf RSHIFT 3 -> lh +er OR es -> et +NOT ax -> ay +ci RSHIFT 1 -> db +et AND fe -> fg +lg OR lm -> ln +k AND m -> n +hz RSHIFT 2 -> ia +kh LSHIFT 1 -> lb +NOT ey -> ez +NOT di -> dj +dz OR ef -> eg +lx -> a +NOT iz -> ja +gz LSHIFT 15 -> hd +ce OR cd -> cf +fq AND fr -> ft +at AND az -> bb +ha OR gz -> hb +fp AND fv -> fx +NOT gb -> gc +ia AND ig -> ii +gl OR gm -> gn +0 -> c +NOT ca -> cb +bn RSHIFT 1 -> cg +c LSHIFT 1 -> t +iw OR ix -> iy +kg OR kf -> kh +dy OR ej -> ek +km AND kn -> kp +NOT fc -> fd +hz RSHIFT 3 -> ib +NOT dq -> dr +NOT fg -> fh +dy RSHIFT 2 -> dz +kk RSHIFT 2 -> kl +1 AND fi -> fj +NOT hr -> hs +jp RSHIFT 1 -> ki +bl OR bm -> bn +1 AND gy -> gz +gr AND gt -> gu +db OR dc -> dd +de OR dk -> dl +as RSHIFT 5 -> av +lf RSHIFT 5 -> li +hm AND ho -> hp +cg OR ch -> ci +gj AND gu -> gw +ge LSHIFT 15 -> gi +e OR f -> g +fp OR fv -> fw +fb AND fd -> fe +cd LSHIFT 15 -> ch +b RSHIFT 1 -> v +at OR az -> ba +bn RSHIFT 2 -> bo +lh AND li -> lk +dl AND dn -> do +eg AND ei -> ej +ex AND ez -> fa +NOT kp -> kq +NOT lk -> ll +x AND ai -> ak +jp OR ka -> kb +NOT jd -> je +iy AND ja -> jb +jp RSHIFT 3 -> jr +fo OR fz -> ga +df OR dg -> dh +gj RSHIFT 2 -> gk +gj OR gu -> gv +NOT jh -> ji +ap LSHIFT 1 -> bj +NOT ls -> lt +ir LSHIFT 1 -> jl +bn AND by -> ca +lv LSHIFT 15 -> lz +ba AND bc -> bd +cy LSHIFT 15 -> dc +ln AND lp -> lq +x RSHIFT 1 -> aq +gk OR gq -> gr +NOT kx -> ky +jg AND ji -> jj +bn OR by -> bz +fl LSHIFT 1 -> gf +bp OR bq -> br +he OR hp -> hq +et RSHIFT 5 -> ew +iu RSHIFT 2 -> iv +gl AND gm -> go +x OR ai -> aj +hc OR hd -> he +lg AND lm -> lo +lh OR li -> lj +da LSHIFT 1 -> du +fo RSHIFT 2 -> fp +gk AND gq -> gs +bj OR bi -> bk +lf OR lq -> lr +cj AND cp -> cr +hu LSHIFT 15 -> hy +1 AND bh -> bi +fo RSHIFT 3 -> fq +NOT lo -> lp +hw LSHIFT 1 -> iq +dd RSHIFT 1 -> dw +dt LSHIFT 15 -> dx +dy AND ej -> el +an LSHIFT 15 -> ar +aq OR ar -> as +1 AND r -> s +fw AND fy -> fz +NOT im -> in +et RSHIFT 3 -> ev +1 AND ds -> dt +ec AND ee -> ef +NOT ak -> al +jl OR jk -> jm +1 AND en -> eo +lb OR la -> lc +iu AND jf -> jh +iu RSHIFT 5 -> ix +bo AND bu -> bw +cz OR cy -> da +iv AND jb -> jd +iw AND ix -> iz +lf RSHIFT 1 -> ly +iu OR jf -> jg +NOT dm -> dn +lw OR lv -> lx +gg LSHIFT 1 -> ha +lr AND lt -> lu +fm OR fn -> fo +he RSHIFT 3 -> hg +aj AND al -> am +1 AND kz -> la +dy RSHIFT 5 -> eb +jc AND je -> jf +cm AND co -> cp +gv AND gx -> gy +ev OR ew -> ex +jp AND ka -> kc +fk OR fj -> fl +dy RSHIFT 3 -> ea +NOT bs -> bt +NOT ag -> ah +dz AND ef -> eh +cf LSHIFT 1 -> cz +NOT cv -> cw +1 AND cx -> cy +de AND dk -> dm +ck AND cl -> cn +x RSHIFT 5 -> aa +dv LSHIFT 1 -> ep +he RSHIFT 2 -> hf +NOT bw -> bx +ck OR cl -> cm +bp AND bq -> bs +as OR bd -> be +he AND hp -> hr +ev AND ew -> ey +1 AND lu -> lv +kk RSHIFT 3 -> km +b AND n -> p +NOT kc -> kd +lc LSHIFT 1 -> lw +km OR kn -> ko +id AND if -> ig +ih AND ij -> ik +jr AND js -> ju +ci RSHIFT 5 -> cl +hz RSHIFT 1 -> is +1 AND ke -> kf +NOT gs -> gt +aw AND ay -> az +x RSHIFT 2 -> y +ab AND ad -> ae +ff AND fh -> fi +ci AND ct -> cv +eq LSHIFT 1 -> fk +gj RSHIFT 3 -> gl +u LSHIFT 1 -> ao +NOT bb -> bc +NOT hj -> hk +kw AND ky -> kz +as AND bd -> bf +dw OR dx -> dy +br AND bt -> bu +kk AND kv -> kx +ep OR eo -> eq +he RSHIFT 1 -> hx +ki OR kj -> kk +NOT ju -> jv +ek AND em -> en +kk RSHIFT 5 -> kn +NOT eh -> ei +hx OR hy -> hz +ea OR eb -> ec +s LSHIFT 15 -> w +fo RSHIFT 1 -> gh +kk OR kv -> kw +bn RSHIFT 5 -> bq +NOT ed -> ee +1 AND ht -> hu +cu AND cw -> cx +b RSHIFT 5 -> f +kl AND kr -> kt +iq OR ip -> ir +ci RSHIFT 2 -> cj +cj OR cp -> cq +o AND q -> r +dd RSHIFT 5 -> dg +b RSHIFT 2 -> d +ks AND ku -> kv +b RSHIFT 3 -> e +d OR j -> k +NOT p -> q +NOT cr -> cs +du OR dt -> dv +kf LSHIFT 15 -> kj +NOT ac -> ad +fo RSHIFT 5 -> fr +hz OR ik -> il +jx AND jz -> ka +gh OR gi -> gj +kk RSHIFT 1 -> ld +hz RSHIFT 5 -> ic +as RSHIFT 2 -> at +NOT jy -> jz +1 AND am -> an +ci OR ct -> cu +hg AND hh -> hj +jq OR jw -> jx +v OR w -> x +la LSHIFT 15 -> le +dh AND dj -> dk +dp AND dr -> ds +jq AND jw -> jy +au OR av -> aw +NOT bf -> bg +z OR aa -> ab +ga AND gc -> gd +hz AND ik -> im +jt AND jv -> jw +z AND aa -> ac +jr OR js -> jt +hb LSHIFT 1 -> hv +hf OR hl -> hm +ib OR ic -> id +fq OR fr -> fs +cq AND cs -> ct +ia OR ig -> ih +dd OR do -> dp +d AND j -> l +ib AND ic -> ie +as RSHIFT 3 -> au +be AND bg -> bh +dd AND do -> dq +NOT l -> m +1 AND gd -> ge +y AND ae -> ag +fo AND fz -> gb +NOT ie -> if +e AND f -> h +x RSHIFT 3 -> z +y OR ae -> af +hf AND hl -> hn +NOT h -> i +NOT hn -> ho +he RSHIFT 5 -> hh \ No newline at end of file diff --git a/advent08.ipynb b/advent08.ipynb new file mode 100644 index 0000000..5099475 --- /dev/null +++ b/advent08.ipynb @@ -0,0 +1,252 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "pi8 = [l.strip() for l in open('advent08.txt').readlines()]" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[('\"qxfcsmh\"', 9),\n", + " ('\"ffsfyxbyuhqkpwatkjgudo\"', 24),\n", + " ('\"byc\\\\x9dyxuafof\\\\\\\\\\\\xa6uf\\\\\\\\axfozomj\\\\\\\\olh\\\\x6a\"', 43),\n", + " ('\"jtqvz\"', 7),\n", + " ('\"uzezxa\\\\\"jgbmojtwyfbfguz\"', 25)]" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "[(l, len(l)) for l in pi8][:5]" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "def interpret_len(s):\n", + " # s = s0[1:-2]\n", + " #print(len(s0), len(s))\n", + " l = 0\n", + " i = 0\n", + " while i < len(s):\n", + " # print(i, l, s[i])\n", + " if s[i] == '\\\\':\n", + " if s[i+1] == '\\\\' or s[i+1] == '\"':\n", + " l += 1\n", + " i += 2\n", + " else:\n", + " l += 1\n", + " i += 4\n", + " else:\n", + " l += 1\n", + " i += 1\n", + " return l - 2" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "7" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "interpret_len(pi8[0])" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[]" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "[l for l in pi8 if len(eval(l)) != interpret_len(l)]" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "1350" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sum(len(s) - len(eval(s)) for s in pi8)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def uninterpret_len(s):\n", + " return len(s) + s.count('\\\\') + s.count('\"') + 2" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[(9, 13, '\"qxfcsmh\"'),\n", + " (24, 28, '\"ffsfyxbyuhqkpwatkjgudo\"'),\n", + " (43, 56, '\"byc\\\\x9dyxuafof\\\\\\\\\\\\xa6uf\\\\\\\\axfozomj\\\\\\\\olh\\\\x6a\"'),\n", + " (7, 11, '\"jtqvz\"'),\n", + " (25, 31, '\"uzezxa\\\\\"jgbmojtwyfbfguz\"'),\n", + " (24, 29, '\"vqsremfk\\\\x8fxiknektafj\"'),\n", + " (34, 45, '\"wzntebpxnnt\\\\\"vqndz\\\\\"i\\\\x47vvjqo\\\\\"\"'),\n", + " (19, 27, '\"higvez\\\\\"k\\\\\"riewqk\"'),\n", + " (29, 35, '\"dlkrbhbrlfrp\\\\\\\\damiauyucwhty\"'),\n", + " (5, 11, '\"d\\\\\"\"')]" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "[(len(s), uninterpret_len(s), s) for s in pi8[:10]]" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "11" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "uninterpret_len(r'\"\\x27\"')" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "2085" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sum(uninterpret_len(s) - len(s) for s in pi8)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.4.3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/advent08.txt b/advent08.txt new file mode 100644 index 0000000..94538e7 --- /dev/null +++ b/advent08.txt @@ -0,0 +1,300 @@ +"qxfcsmh" +"ffsfyxbyuhqkpwatkjgudo" +"byc\x9dyxuafof\\\xa6uf\\axfozomj\\olh\x6a" +"jtqvz" +"uzezxa\"jgbmojtwyfbfguz" +"vqsremfk\x8fxiknektafj" +"wzntebpxnnt\"vqndz\"i\x47vvjqo\"" +"higvez\"k\"riewqk" +"dlkrbhbrlfrp\\damiauyucwhty" +"d\"" +"qlz" +"ku" +"yy\"\"uoao\"uripabop" +"saduyrntuswlnlkuppdro\\sicxosted" +"tj" +"zzphopswlwdhebwkxeurvizdv" +"xfoheirjoakrpofles\"nfu" +"q\xb7oh\"p\xce\"n" +"qeendp\"ercwgywdjeylxcv" +"dcmem" +"\"i\x13r\"l" +"ikso\xdcbvqnbrjduh\"uqudzki\xderwk" +"wfdsn" +"pwynglklryhtsqbno" +"hcoj\x63iccz\"v\"ttr" +"zf\x23\\hlj\\kkce\\d\\asy\"yyfestwcdxyfj" +"xs" +"m\"tvltapxdvtrxiy" +"bmud" +"k\"a" +"b\"oas" +"\"yexnjjupoqsxyqnquy\"uzfdvetqrc" +"vdw\xe3olxfgujaj" +"qomcxdnd\"\\cfoe\"" +"fpul" +"m\"avamefphkpv" +"vvdnb\\x\\uhnxfw\"dpubfkxfmeuhnxisd" +"hey\\" +"ldaeigghlfey" +"eure\"hoy\xa5iezjp\\tm" +"yygb\"twbj\\r\"\x10gmxuhmp\"" +"weirebp\x39mqonbtmfmd" +"ltuz\\hs\"e" +"ysvmpc" +"g\x8amjtt\"megl\"omsaihifwa" +"yimmm" +"iiyqfalh" +"cwknlaaf" +"q\x37feg\xc6s\"xx" +"uayrgeurgyp\\oi" +"xhug\"pt\"axugllbdiggzhvy" +"kdaarqmsjfx\xc3d" +"\"vkwla" +"d\"" +"tmroz\"bvfinxoe\\mum\"wmm" +"\"n\"bbswxne\\p\\yr\"qhwpdd" +"skzlkietklkqovjhvj\xfe" +"pbg\\pab\"bubqaf\"obzcwxwywbs\\dhtq" +"xxjidvqh\"lx\\wu\"ij" +"daef\x5fe\x5b\\kbeeb\x13qnydtboof" +"ogvazaqy\"j\x73" +"y" +"n\"tibetedldy\\gsamm\"nwu" +"wldkvgdtqulwkad" +"dpmxnj" +"twybw\"cdvf\"mjdajurokbce" +"ru\"\\lasij\"i" +"roc\\vra\\lhrm" +"pbkt\x60booz\"fjlkc" +"j\x4dytvjwrzt" +"\\uiwjkniumxcs" +"cbhm\"nexccior\"v\"j\"nazxilmfp\x47" +"qdxngevzrlgoq" +"\"lrzxftytpobsdfyrtdqpjbpuwmm\x9e" +"mdag\x0asnck\xc2ggj\"slb\"fjy" +"wyqkhjuazdtcgkcxvjkpnjdae" +"aixfk\xc0iom\x21vueob" +"dkiiakyjpkffqlluhaetires" +"ysspv\"lysgkvnmwbbsy" +"gy\"ryexcjjxdm\"xswssgtr" +"s" +"ddxv" +"qwt\"\x27puilb\"pslmbrsxhrz" +"qdg\xc9e\\qwtknlvkol\x54oqvmchn\\" +"lvo" +"b" +"fk\"aa\"\"yenwch\\\\on" +"srig\x63hpwaavs\\\x80qzk\"xa\"\xe6u\\wr" +"yxjxuj\"ghyhhxfj\"\xa6qvatre" +"yoktqxjxkzrklkoeroil" +"\"jfmik\"" +"smgseztzdwldikbqrh\"" +"jftahgctf\"hoqy" +"tcnhicr\"znpgckt\"ble" +"vqktnkodh\"lo\"a\\bkmdjqqnsqr" +"ztnirfzqq" +"s" +"xx" +"iqj\"y\\hqgzflwrdsusasekyrxbp\\ad" +"\\xzjhlaiynkioz\"\"bxepzimvgwt" +"s\x36rbw" +"mniieztwrisvdx" +"atyfxioy\x2b\\" +"irde\x85\x5cvbah\\jekw\"ia" +"bdmftlhkwrprmpat\"prfaocvp" +"w\\k" +"umbpausy" +"zfauhpsangy" +"p\"zqyw" +"wtztypyqvnnxzvlvipnq\"zu" +"deicgwq\\oqvajpbov\\or\"kgplwu" +"mbzlfgpi\\\\zqcidjpzqdzxityxa" +"lfkxvhma" +"\xf2yduqzqr\"\\fak\"p\"n" +"mpajacfuxotonpadvng" +"anb\\telzvcdu\\a\xf2flfq" +"lrs\"ebethwpmuuc\"\x86ygr" +"qmvdbhtumzc\"ci" +"meet" +"yopg\x0fdxdq\"h\\ugsu\xffmolxjv" +"uhy" +"fzgidrtzycsireghazscvmwcfmw\\t" +"cqohkhpgvpru" +"bihyigtnvmevx\"xx" +"xz" +"zofomwotzuxsjk\"q\"mc\"js\"dnmalhxd" +"\\ktnddux\\fqvt\"ibnjntjcbn" +"ia" +"htjadnefwetyp\xd5kbrwfycbyy" +"\"\\hkuxqddnao" +"meqqsz\x83luecpgaem" +"cvks\x87frvxo\"svqivqsdpgwhukmju" +"sgmxiai\\o\"riufxwjfigr\xdf" +"fgywdfecqufccpcdn" +"faghjoq\x28abxnpxj" +"zuppgzcfb\"dctvp\"elup\"zxkopx" +"xqs\x45xxdqcihbwghmzoa" +"anbnlp\\cgcvm\"hc" +"xf\"fgrngwzys" +"nrxsjduedcy\x24" +"\x71sxl\"gj\"sds\"ulcruguz\\t\\ssvjcwhi" +"jhj\"msch" +"qpovolktfwyiuyicbfeeju\x01" +"nkyxmb\"qyqultgt\"nmvzvvnxnb" +"ycsrkbstgzqb\"uv\\cisn" +"s" +"ueptjnn\"\"sh" +"lp\"z\"d\"mxtxiy" +"yzjtvockdnvbubqabjourf\"k\"uoxwle" +"\x82\"wqm\"" +"\xb5cwtuks\x5fpgh" +"wd" +"tbvf" +"ttbmzdgn" +"vfpiyfdejyrlbgcdtwzbnm" +"uc" +"otdcmhpjagqix" +"\\\xb1qso\"s" +"scowax" +"behpstjdh\xccqlgnqjyz\"eesn" +"r\xe1cbnjwzveoomkzlo\\kxlfouhm" +"jgrl" +"kzqs\\r" +"ctscb\x7fthwkdyko\"\x62pkf\"d\xe6knmhurg" +"tc\"kw\x3ftt" +"bxb\x5ccl" +"jyrmfbphsldwpq" +"jylpvysl\"\"juducjg" +"en\\m\"kxpq\"wpb\\\"" +"madouht\"bmdwvnyqvpnawiphgac\"" +"vuxpk\"ltucrw" +"aae\x60arr" +"ttitnne\"kilkrgssnr\xfdurzh" +"oalw" +"pc\"\"gktkdykzbdpkwigucqni\"nxiqx" +"dbrsaj" +"bgzsowyxcbrvhtvekhsh\"qgd" +"kudfemvk\"\"\"hkbrbil\"chkqoa" +"zjzgj\\ekbhyfzufy" +"\\acos\"fqekuxqzxbmkbnn\x1ejzwrm" +"elxahvudn\"txtmomotgw" +"\x2eoxmwdhelpr\"cgi\xf7pzvb" +"eapheklx" +"hfvma\"mietvc\"tszbbm\"czex" +"h\"iiockj\\\xc1et" +"d\"rmjjftm" +"qlvhdcbqtyrhlc\\" +"yy\"rsucjtulm\"coryri\"eqjlbmk" +"tv" +"r\"bfuht\\jjgujp\"" +"kukxvuauamtdosngdjlkauylttaokaj" +"srgost\"\"rbkcqtlccu\x65ohjptstrjkzy" +"yxwxl\\yjilwwxffrjjuazmzjs" +"dxlw\\fkstu\"hjrtiafhyuoh\"sewabne" +"\x88sj\"v" +"rfzprz\xec\"oxqclu\"krzefp\\q" +"cfmhdbjuhrcymgxpylllyvpni" +"ucrmjvmimmcq\x88\xd9\"lz" +"lujtt\"" +"gvbqoixn\"pmledpjmo\"flydnwkfxllf" +"dvxqlbshhmelsk\x8big\"l" +"mx\x54lma\x8bbguxejg" +"\x66jdati\xeceieo" +"\"iyyupixei\x54ff" +"xohzf\"rbxsoksxamiu" +"vlhthspeshzbppa\x4drhqnohjop\"\"mfjd" +"f\"tvxxla\"vurian\"\"idjq\x3aptm\xc3olep" +"gzqz" +"kbq\\wogye\\altvi\\hbvmodny" +"j\xd8" +"ofjozdhkblvndl" +"hbitoupimbawimxlxqze" +"ypeleimnme" +"xfwdrzsc\\oxqamawyizvi\\y" +"enoikppx\xa1ixe\"yo\"gumye" +"fb" +"vzf" +"zxidr" +"cu\x31beirsywtskq" +"lxpjbvqzztafwezd" +"\\jyxeuo\x18bv" +"b\"vawc\"p\\\\giern\"b" +"odizunx\"\"t\\yicdn\"x\"sdiz" +"\"\"tebrtsi" +"ctyzsxv\xa6pegfkwsi\"tgyltaakytccb" +"htxwbofchvmzbppycccliyik\xe5a" +"ggsslefamsklezqkrd" +"rcep\"fnimwvvdx\"l" +"zyrzlqmd\x12egvqs\\llqyie" +"\x07gsqyrr\\rcyhyspsvn" +"butg\"" +"gb" +"gywkoxf\"jsg\\wtopxvumirqxlwz" +"rj\"ir\"wldwveair\x2es\"dhjrdehbqnzl" +"ru\"elktnsbxufk\\ejufjfjlevt\\lrzd" +"\"widsvok" +"oy\"\x81nuesvw" +"ay" +"syticfac\x1cfjsivwlmy\"pumsqlqqzx" +"m" +"rjjkfh\x78cf\x2brgceg\"jmdyas\"\\xlv\xb6p" +"tmuvo\"\x3ffdqdovjmdmkgpstotojkv\"as" +"jd\\ojvynhxllfzzxvbn\"wrpphcvx" +"pz" +"\"twr" +"n\\hdzmxe\"mzjjeadlz" +"fb\"rprxuagvahjnri" +"rfmexmjjgh\\xrnmyvnatrvfruflaqjnd" +"obbbde\"co\"qr\"qpiwjgqahqm\\jjp\"" +"vpbq\"\"y\"czk\\b\x52ed\"lnzepobp" +"syzeajzfarplydipny\"y\"\xe8ad" +"mpyodwb" +"\x47rakphlqqptd" +"wa\"oj\"aiy" +"a" +"ropozx" +"q\x51nbtlwa" +"etukvgx\\jqxlkq" +"\"tp\"rah\"pg\"s\"bpdtes\\tkasdhqd" +"dn\"qqpkikadowssb\xcah\"dzpsf\\ect\"jdh" +"pxunovbbrrn\\vullyn\"bno\"\"\"myfxlp\"" +"qaixyazuryvkmoulhcqaotegfj\\mpzm" +"bvfrbicutzbjwn\\oml\"cf\"d\"ezcpv\"j" +"rmbrdtneudemigdhelmb" +"aq\\aurmbhy" +"wujqvzw" +"gf\"tssmvm\"gm\"hu\x9a\xb7yjawsa" +"hrhqqxow\xe2gsydtdspcfqy\"zw\\ou" +"ianwwf\\yko\\tdujhhqdi" +"xylz\"zpvpab" +"lwuopbeeegp" +"aoop\x49jhhcexdmdtun" +"\\\\mouqqcsgmz" +"tltuvwhveau\x43b\"ymxjlcgiymcynwt" +"gsugerumpyuhtjljbhrdyoj" +"lnjm\xb8wg\"ajh" +"zmspue\"nfttdon\\b\"eww" +"\"w\x67jwaq\x7ernmyvs\\rmdsuwydsd\"th" +"ogtgvtlmcvgllyv" +"z\"fqi\"rvddoehrciyl" +"yustxxtot\"muec\"xvfdbzunzvveq" +"mqslw" +"txqnyvzmibqgjs\xb6xy\x86nfalfyx" +"kzhehlmkholov" +"plpmywcnirrjutjguosh\\" +"pydbnqofv\"dn\\m" +"aegqof" +"eambmxt\\dxagoogl\\zapfwwlmk" +"afbmqitxxqhddlozuxcpjxgh" +"vgts" +"bfdpqtoxzzhmzcilehnflna" +"s\"idpz" +"\xcfhgly\"nlmztwybx\"ecezmsxaqw" +"aackfgndqcqiy" +"\x22unqdlsrvgzfaohoffgxzfpir\"s" +"abh\"ydv\"kbpdhrerl" +"bdzpg" +"ekwgkywtmzp" +"wtoodejqmrrgslhvnk\"pi\"ldnogpth" +"njro\x68qgbx\xe4af\"\\suan" diff --git a/advent09.ipynb b/advent09.ipynb new file mode 100644 index 0000000..d314005 --- /dev/null +++ b/advent09.ipynb @@ -0,0 +1,439 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "pi9 = open('advent09.txt').read().strip()" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "{('AlphaCentauri',\n", + " 'Arbre'): Connection(origin='AlphaCentauri', destination='Arbre', distance=116),\n", + " ('AlphaCentauri',\n", + " 'Faerun'): Connection(origin='AlphaCentauri', destination='Faerun', distance=13),\n", + " ('AlphaCentauri',\n", + " 'Norrath'): Connection(origin='AlphaCentauri', destination='Norrath', distance=15),\n", + " ('AlphaCentauri',\n", + " 'Snowdin'): Connection(origin='AlphaCentauri', destination='Snowdin', distance=12),\n", + " ('AlphaCentauri',\n", + " 'Straylight'): Connection(origin='AlphaCentauri', destination='Straylight', distance=91),\n", + " ('AlphaCentauri',\n", + " 'Tambi'): Connection(origin='AlphaCentauri', destination='Tambi', distance=18),\n", + " ('AlphaCentauri',\n", + " 'Tristram'): Connection(origin='AlphaCentauri', destination='Tristram', distance=118),\n", + " ('Arbre',\n", + " 'AlphaCentauri'): Connection(origin='Arbre', destination='AlphaCentauri', distance=116),\n", + " ('Arbre',\n", + " 'Faerun'): Connection(origin='Arbre', destination='Faerun', distance=24),\n", + " ('Arbre',\n", + " 'Norrath'): Connection(origin='Arbre', destination='Norrath', distance=135),\n", + " ('Arbre',\n", + " 'Snowdin'): Connection(origin='Arbre', destination='Snowdin', distance=129),\n", + " ('Arbre',\n", + " 'Straylight'): Connection(origin='Arbre', destination='Straylight', distance=40),\n", + " ('Arbre',\n", + " 'Tambi'): Connection(origin='Arbre', destination='Tambi', distance=53),\n", + " ('Arbre',\n", + " 'Tristram'): Connection(origin='Arbre', destination='Tristram', distance=122),\n", + " ('Faerun',\n", + " 'AlphaCentauri'): Connection(origin='Faerun', destination='AlphaCentauri', distance=13),\n", + " ('Faerun',\n", + " 'Arbre'): Connection(origin='Faerun', destination='Arbre', distance=24),\n", + " ('Faerun',\n", + " 'Norrath'): Connection(origin='Faerun', destination='Norrath', distance=129),\n", + " ('Faerun',\n", + " 'Snowdin'): Connection(origin='Faerun', destination='Snowdin', distance=60),\n", + " ('Faerun',\n", + " 'Straylight'): Connection(origin='Faerun', destination='Straylight', distance=67),\n", + " ('Faerun',\n", + " 'Tambi'): Connection(origin='Faerun', destination='Tambi', distance=71),\n", + " ('Faerun',\n", + " 'Tristram'): Connection(origin='Faerun', destination='Tristram', distance=58),\n", + " ('Norrath',\n", + " 'AlphaCentauri'): Connection(origin='Norrath', destination='AlphaCentauri', distance=15),\n", + " ('Norrath',\n", + " 'Arbre'): Connection(origin='Norrath', destination='Arbre', distance=135),\n", + " ('Norrath',\n", + " 'Faerun'): Connection(origin='Norrath', destination='Faerun', distance=129),\n", + " ('Norrath',\n", + " 'Snowdin'): Connection(origin='Norrath', destination='Snowdin', distance=75),\n", + " ('Norrath',\n", + " 'Straylight'): Connection(origin='Norrath', destination='Straylight', distance=54),\n", + " ('Norrath',\n", + " 'Tambi'): Connection(origin='Norrath', destination='Tambi', distance=82),\n", + " ('Norrath',\n", + " 'Tristram'): Connection(origin='Norrath', destination='Tristram', distance=142),\n", + " ('Snowdin',\n", + " 'AlphaCentauri'): Connection(origin='Snowdin', destination='AlphaCentauri', distance=12),\n", + " ('Snowdin',\n", + " 'Arbre'): Connection(origin='Snowdin', destination='Arbre', distance=129),\n", + " ('Snowdin',\n", + " 'Faerun'): Connection(origin='Snowdin', destination='Faerun', distance=60),\n", + " ('Snowdin',\n", + " 'Norrath'): Connection(origin='Snowdin', destination='Norrath', distance=75),\n", + " ('Snowdin',\n", + " 'Straylight'): Connection(origin='Snowdin', destination='Straylight', distance=99),\n", + " ('Snowdin',\n", + " 'Tambi'): Connection(origin='Snowdin', destination='Tambi', distance=15),\n", + " ('Snowdin',\n", + " 'Tristram'): Connection(origin='Snowdin', destination='Tristram', distance=103),\n", + " ('Straylight',\n", + " 'AlphaCentauri'): Connection(origin='Straylight', destination='AlphaCentauri', distance=91),\n", + " ('Straylight',\n", + " 'Arbre'): Connection(origin='Straylight', destination='Arbre', distance=40),\n", + " ('Straylight',\n", + " 'Faerun'): Connection(origin='Straylight', destination='Faerun', distance=67),\n", + " ('Straylight',\n", + " 'Norrath'): Connection(origin='Straylight', destination='Norrath', distance=54),\n", + " ('Straylight',\n", + " 'Snowdin'): Connection(origin='Straylight', destination='Snowdin', distance=99),\n", + " ('Straylight',\n", + " 'Tambi'): Connection(origin='Straylight', destination='Tambi', distance=70),\n", + " ('Straylight',\n", + " 'Tristram'): Connection(origin='Straylight', destination='Tristram', distance=97),\n", + " ('Tambi',\n", + " 'AlphaCentauri'): Connection(origin='Tambi', destination='AlphaCentauri', distance=18),\n", + " ('Tambi',\n", + " 'Arbre'): Connection(origin='Tambi', destination='Arbre', distance=53),\n", + " ('Tambi',\n", + " 'Faerun'): Connection(origin='Tambi', destination='Faerun', distance=71),\n", + " ('Tambi',\n", + " 'Norrath'): Connection(origin='Tambi', destination='Norrath', distance=82),\n", + " ('Tambi',\n", + " 'Snowdin'): Connection(origin='Tambi', destination='Snowdin', distance=15),\n", + " ('Tambi',\n", + " 'Straylight'): Connection(origin='Tambi', destination='Straylight', distance=70),\n", + " ('Tambi',\n", + " 'Tristram'): Connection(origin='Tambi', destination='Tristram', distance=49),\n", + " ('Tristram',\n", + " 'AlphaCentauri'): Connection(origin='Tristram', destination='AlphaCentauri', distance=118),\n", + " ('Tristram',\n", + " 'Arbre'): Connection(origin='Tristram', destination='Arbre', distance=122),\n", + " ('Tristram',\n", + " 'Faerun'): Connection(origin='Tristram', destination='Faerun', distance=58),\n", + " ('Tristram',\n", + " 'Norrath'): Connection(origin='Tristram', destination='Norrath', distance=142),\n", + " ('Tristram',\n", + " 'Snowdin'): Connection(origin='Tristram', destination='Snowdin', distance=103),\n", + " ('Tristram',\n", + " 'Straylight'): Connection(origin='Tristram', destination='Straylight', distance=97),\n", + " ('Tristram',\n", + " 'Tambi'): Connection(origin='Tristram', destination='Tambi', distance=49)}" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from collections import namedtuple\n", + "\n", + "Connection = namedtuple('Connection', ['origin', 'destination', 'distance'])\n", + "\n", + "connections = {}\n", + "\n", + "for l in pi9.splitlines():\n", + " s = l.split(' ')\n", + " connections[(s[0], s[2])] = Connection(origin=s[0], destination=s[2], distance=int(s[4]))\n", + " connections[(s[2], s[0])] = Connection(origin=s[2], destination=s[0], distance=int(s[4]))\n", + "connections" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "{'AlphaCentauri',\n", + " 'Arbre',\n", + " 'Faerun',\n", + " 'Norrath',\n", + " 'Snowdin',\n", + " 'Straylight',\n", + " 'Tambi',\n", + " 'Tristram'}" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "towns = set([c[0] for c in connections] + [c[1] for c in connections])\n", + "towns" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def viable(route):\n", + " return all((c in connections) for c in zip(route, route[1:])) " + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "viable(['Faerun', 'Norrath', 'Tambi', 'Arbre'])" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def length(route):\n", + " return sum(connections[c].distance for c in zip(route, route[1:]))" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "211" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "length(['Faerun', 'Norrath', 'Tambi'])" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def best(route1, route2):\n", + " if length(route1) < length(route2):\n", + " return route1\n", + " else:\n", + " return route2" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def worst(route1, route2):\n", + " if length(route1) > length(route2):\n", + " return route1\n", + " else:\n", + " return route2" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "(('Norrath',\n", + " 'Straylight',\n", + " 'Arbre',\n", + " 'Faerun',\n", + " 'AlphaCentauri',\n", + " 'Snowdin',\n", + " 'Tambi',\n", + " 'Tristram'),\n", + " 207)" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import itertools\n", + "import functools\n", + "\n", + "possible_routes = filter(viable, [r for r in itertools.permutations(towns)])\n", + "best_route = functools.reduce(best, possible_routes)\n", + "best_route, length(best_route)" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "40320" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(list(filter(viable, [r for r in itertools.permutations(towns)])))" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "ps = list(itertools.permutations(towns))" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "40320" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(list(filter(viable, ps)))" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "(('Straylight',\n", + " 'Snowdin',\n", + " 'Arbre',\n", + " 'AlphaCentauri',\n", + " 'Tristram',\n", + " 'Norrath',\n", + " 'Faerun',\n", + " 'Tambi'),\n", + " 804)" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "possible_routes = filter(viable, [r for r in itertools.permutations(towns)])\n", + "worst_route = functools.reduce(worst, possible_routes)\n", + "worst_route, length(worst_route)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.4.3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/advent09.txt b/advent09.txt new file mode 100644 index 0000000..9850564 --- /dev/null +++ b/advent09.txt @@ -0,0 +1,28 @@ +Faerun to Norrath = 129 +Faerun to Tristram = 58 +Faerun to AlphaCentauri = 13 +Faerun to Arbre = 24 +Faerun to Snowdin = 60 +Faerun to Tambi = 71 +Faerun to Straylight = 67 +Norrath to Tristram = 142 +Norrath to AlphaCentauri = 15 +Norrath to Arbre = 135 +Norrath to Snowdin = 75 +Norrath to Tambi = 82 +Norrath to Straylight = 54 +Tristram to AlphaCentauri = 118 +Tristram to Arbre = 122 +Tristram to Snowdin = 103 +Tristram to Tambi = 49 +Tristram to Straylight = 97 +AlphaCentauri to Arbre = 116 +AlphaCentauri to Snowdin = 12 +AlphaCentauri to Tambi = 18 +AlphaCentauri to Straylight = 91 +Arbre to Snowdin = 129 +Arbre to Tambi = 53 +Arbre to Straylight = 40 +Snowdin to Tambi = 15 +Snowdin to Straylight = 99 +Tambi to Straylight = 70 diff --git a/advent10.ipynb b/advent10.ipynb new file mode 100644 index 0000000..46d130c --- /dev/null +++ b/advent10.ipynb @@ -0,0 +1,210 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "import itertools" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[(1, [1, 1]), (2, [2, 2, 2]), (1, [1, 1]), (3, [3])]" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "[(i, list(ii)) for i, ii in itertools.groupby([1,1,2,2,2,1,1,3])]" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def chunks(sequence):\n", + " return [(len(list(ii)), i) for i, ii in itertools.groupby(int(d) for d in sequence)]" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[(3, 1), (2, 2), (1, 1)]" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "chunks('111221')" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def looksay(chunks):\n", + " return ''.join(str(item) for chunk in chunks for item in chunk)" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'312211'" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "looksay(chunks('111221'))" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "11\n", + "21\n", + "1211\n", + "111221\n", + "312211\n", + "13112221\n", + "1113213211\n", + "31131211131221\n", + "13211311123113112211\n", + "11131221133112132113212221\n" + ] + } + ], + "source": [ + "lss = '1'\n", + "for i in range(10):\n", + " lss = looksay(chunks(lss))\n", + " print(lss)" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "329356\n" + ] + } + ], + "source": [ + "lss = '3113322113'\n", + "for _ in range(40):\n", + " lss = looksay(chunks(lss))\n", + "print(len(lss))" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "4666278\n" + ] + } + ], + "source": [ + "lss = '3113322113'\n", + "for _ in range(50):\n", + " lss = looksay(chunks(lss))\n", + "print(len(lss))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.4.3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/advent11.ipynb b/advent11.ipynb new file mode 100644 index 0000000..f2838bc --- /dev/null +++ b/advent11.ipynb @@ -0,0 +1,330 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "import itertools\n", + "import string" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def increment(password):\n", + " if password:\n", + " if password[-1] < 'z':\n", + " return password[:-1] + chr(ord(password[-1]) + 1)\n", + " else:\n", + " return increment(password[:-1]) + 'a'\n", + " else:\n", + " raise StopIterations\n" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'aca'" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "increment('abz')" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'aabaaaaa'" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "increment('aaazzzzz')" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def valid(password):\n", + " if 'i' in password:\n", + " return False\n", + " if 'o' in password:\n", + " return False\n", + " if 'l' in password:\n", + " return False\n", + " if not has_run(password):\n", + " return False\n", + " if len(doubles(password)) < 2:\n", + " return False\n", + " return True" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "def has_run(password):\n", + " for i in range(len(password) - 3):\n", + " if ord(password[i]) + 1 == ord(password[i+1]) and ord(password[i+1]) + 1 == ord(password[i+2]):\n", + " return True\n", + " return False" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "has_run('hiajkblammnpo')" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "def doubles(password):\n", + " ds = []\n", + " for i in range(len(password)-1):\n", + " if password[i] == password[i+1]:\n", + " ds += [password[i]]\n", + " return set(ds)" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "{'k', 'm'}" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "doubles('hiajkkblammmnpo')" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "valid('abbcegjk')" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def next_valid(password):\n", + " p = increment(password)\n", + " while not valid(p):\n", + " p = increment(p)\n", + " return p" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'abcdffaa'" + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "next_valid('abcdefgh')" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'ghjaabcc'" + ] + }, + "execution_count": 33, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "next_valid('ghijklmn')" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'hxbxxyzz'" + ] + }, + "execution_count": 34, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "next_valid('hxbxwxba')" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'hxcaabcc'" + ] + }, + "execution_count": 35, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "next_valid('hxbxxyzz')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.4.3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/advent12.ipynb b/advent12.ipynb new file mode 100644 index 0000000..b4b4be6 --- /dev/null +++ b/advent12.ipynb @@ -0,0 +1,170 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "8" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import json\n", + "\n", + "pi12 = json.load(open('advent12.json'))\n", + "len(pi12)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "def jsum(term):\n", + " if isinstance(term, dict):\n", + " return sum(jsum(k) + jsum(v) for k, v in term.items())\n", + " elif isinstance(term, list):\n", + " return sum(jsum(e) for e in term)\n", + " elif isinstance(term, int):\n", + " return term\n", + " elif isinstance(term, str):\n", + " return 0\n", + " else:\n", + " raise ArgumentError" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "jsum({})" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "191164" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "jsum(pi12)" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "def jsum2(term):\n", + " if isinstance(term, dict):\n", + " if 'red' in term or 'red' in term.values():\n", + " return 0\n", + " else:\n", + " return sum(jsum2(k) + jsum2(v) for k, v in term.items())\n", + " elif isinstance(term, list):\n", + " return sum(jsum2(e) for e in term)\n", + " elif isinstance(term, int):\n", + " return term\n", + " elif isinstance(term, str):\n", + " return 0\n", + " else:\n", + " raise ArgumentError" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "87842" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "jsum2(pi12)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.4.3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/advent12.json b/advent12.json new file mode 100644 index 0000000..bd91fda --- /dev/null +++ b/advent12.json @@ -0,0 +1 @@ +[["green",[{"e":"green","a":77,"d":{"c":"violet","a":"yellow","b":"violet"},"c":"yellow","h":"red","b":144,"g":{"a":["yellow",-48,72,87,{"e":"violet","c":123,"a":101,"b":87,"d":"red","f":88},{"e":"red","c":2,"a":1,"g":"blue","b":"green","d":"violet","f":170},"orange",171,162]},"f":"orange","i":"orange"},49,[{"c":{"e":"violet","a":-44,"d":115,"c":117,"h":194,"b":{"e":-17,"a":172,"d":"green","c":197,"h":53,"b":106,"g":"violet","f":-10},"g":"red","f":"orange"},"a":-49,"b":["violet","orange","blue"]}],"green"]],["orange"],{"e":"blue","a":["red","yellow"],"d":{"a":[{"c":{"a":181,"b":["orange",-40,"red","orange","yellow",31,60,71,"yellow"]},"a":[114,-40],"b":"orange"},["green",93,10,{"c":11,"a":170,"b":[161,-3],"d":-16},58,{"e":{"c":-2,"a":117,"b":"violet"},"c":["blue","yellow","red","violet","yellow",123,113],"a":"orange","g":19,"b":108,"d":"red","f":"yellow"},{"e":"green","c":"yellow","a":{"e":28,"c":"red","a":"violet","b":"red","d":"green"},"g":"yellow","b":116,"d":148,"f":"red"},[15],["green","green",43],"blue"],[133],"green",134,"violet",{"c":"red","a":[71,41,"blue"],"b":"yellow","d":"violet"},132,[10,"violet",[182,"green","green","orange"],78,{"c":"blue","a":[100,-36,"blue","violet",-10,"orange"],"b":{"e":"orange","c":"blue","a":160,"g":"green","b":190,"d":"red","f":186}},16],[{"c":"green","a":"violet","b":20,"d":"red"},"green","blue",{"c":[0,84,184,"orange",-34,"blue","orange",0,"violet","violet"],"a":10,"b":89},"green",182,127,-2,196]]},"c":-20,"h":[[165,[180,"yellow",-5,16,"red",[{"e":"orange","a":"orange","d":"orange","c":"yellow","h":"red","b":182,"g":21,"f":"violet"},"red",69,"violet",10,"red","orange"]],[160,"blue",{"e":"yellow","c":"violet","a":"green","g":43,"b":[-40,"yellow","yellow",118,57,"green","violet","yellow","violet"],"d":"yellow","f":"blue"}],130,{"e":["yellow",58,"green",139,"violet","red"],"c":"green","a":"green","g":{"e":163,"c":33,"a":15,"b":78,"d":"green"},"b":86,"d":"orange","f":58},"red","red",{"a":37}],"yellow",{"e":44,"a":{"a":136,"b":"yellow"},"d":"yellow","j":39,"c":[-28,["violet",{"e":"red","a":150,"d":189,"c":76,"h":"orange","b":"yellow","g":164,"f":"orange"}],{"e":12,"a":"red","d":"yellow","c":"yellow","h":102,"b":"yellow","g":"red","f":147},"violet",[40,"red",24,193,105,179,"violet","green",{"a":"yellow","b":"violet"}],39,-25,{"a":127},126,{"e":"red","c":151,"a":-46,"b":"green","d":"violet"}],"h":"red","b":122,"g":93,"f":["violet",{"c":102,"a":-16,"b":39,"d":176},"red",187,{"e":"blue","a":172,"d":{"a":-5},"c":25,"h":{"a":"red"},"b":"blue","g":["yellow","red"],"f":{"e":158,"c":85,"a":"blue","g":"green","b":"violet","d":125,"f":93},"i":11},"violet"],"i":[195,{"a":"blue"},48,[44,25,"green","red","violet",172,"orange",49]]},["yellow",[{"e":-4,"a":"red","d":"green","c":"blue","h":"green","b":"green","g":190,"f":30,"i":-2},"green","violet",{"e":92,"c":-11,"a":{"e":"orange","c":0,"a":47,"g":"blue","b":"orange","d":"yellow","f":-47},"b":40,"d":193},97,"violet",[51,168,"violet",{"c":-45,"a":167,"b":"orange"},"blue","orange",64],[188,"green",91,-10,66,"green"],"green","blue"],"green",-42,{"e":"red","c":"red","a":199,"g":84,"b":"blue","d":["blue",194,["green",88,110,-23,"yellow","green",15,"violet"]],"f":"red"}],{"e":"blue","c":-33,"a":-34,"b":"blue","d":81}],"b":{"e":"violet","c":165,"a":"violet","b":{"a":"red","b":"yellow"},"d":[6,71,"orange","orange",{"a":96},74,"yellow"]},"g":["yellow",["orange",[-27],[[[8,"red","blue",-46,62,"yellow",94],[60,"violet",141,"green"],16,"green","yellow","blue",81,[93,"red",183,"blue","red",30,-16,"red","red","yellow"],-21,139],{"c":"blue","a":"orange","b":"violet","d":51}],"blue","yellow",["violet",19,"orange","yellow","red","violet","blue","violet",{"e":"yellow","a":"violet","d":137,"c":"blue","h":197,"b":"orange","g":{"e":"yellow","c":"orange","a":18,"b":42,"d":183,"f":142},"f":68}],"green",["blue",85,"violet"]]],"f":"green"},[92,{"c":-26,"a":{"c":["orange","orange",{"e":131,"c":192,"a":-38,"g":16,"b":27,"d":"yellow","f":-46},120,"orange",-28,-18,3],"a":["red",-15,{"e":56,"c":-15,"a":150,"g":"blue","b":"orange","d":"violet","f":70},-44,{"e":"green","c":53,"a":"blue","b":"blue","d":-34,"f":"violet"},"orange",[161,"orange",-19,{"e":27,"c":98,"a":"violet","g":"yellow","b":-45,"d":191,"f":"green"}]],"b":-41,"d":[["orange","red","yellow",120,140],[{"e":-1,"c":"orange","a":"yellow","b":"yellow","d":86},42,[78,140,"orange","green","orange",-49,159],"yellow","red",90,{"c":"green","a":62,"b":"violet"}],"violet",178,30,"green",186]},"b":"red","d":"violet"},{"e":-21,"a":{"e":{"e":{"e":"orange","c":115,"a":199,"b":-43,"d":"yellow"},"a":"blue","d":"green","c":"blue","h":"violet","b":"red","g":"violet","f":{"a":5}},"a":[{"e":"green","a":[20,"yellow",23,100,"orange",142,"red",-3],"d":19,"c":18,"h":"blue","b":"yellow","g":"yellow","f":{"a":-33}}],"d":"yellow","j":"yellow","c":["red",-2,95,-1,"green","violet",12],"h":"orange","b":{"e":[94,-14,"orange",68],"c":["blue","yellow",[-12,"yellow",126,"orange",199,"red",133],{"e":-14,"a":40,"d":-48,"c":5,"h":"orange","b":"red","g":"yellow","f":"red","i":"orange"},"blue",[-35,87,84,"yellow"],"red","red",86,"yellow"],"a":11,"g":{"e":-34,"a":"orange","d":"blue","j":"blue","c":"yellow","h":"yellow","b":"violet","g":42,"f":188,"i":53},"b":"yellow","d":{"e":"red","c":84,"a":"violet","b":"orange","d":87},"f":["blue","yellow","red",{"c":"orange","a":"blue","b":61},"violet",20,-22,129]},"g":{"e":28,"c":170,"a":["green",98,"orange",150,"orange"],"b":"blue","d":"blue"},"f":"blue","i":[{"e":"green","a":"blue","d":19,"c":177,"h":-18,"b":{"e":-19,"a":"green","d":"yellow","c":172,"h":"red","b":"red","g":"yellow","f":"yellow"},"g":{"c":-36,"a":"red","b":"violet"},"f":121},141,"violet",113,81]},"d":{"e":133,"a":19,"d":-27,"c":{"c":["yellow"],"a":105,"b":{"a":"orange"},"d":{"e":"yellow","c":"orange","a":"orange","b":163,"d":"violet","f":"red"}},"h":"yellow","b":161,"g":110,"f":[[137,6,[195,"violet",179,93,"green",130,"blue","yellow"],70,"orange",-8,-28,"orange",{"e":59,"a":"red","d":128,"j":88,"c":"violet","h":188,"b":0,"g":0,"f":"green","i":2}],86,"green","orange",68,"yellow"]},"c":{"e":"violet","a":-49,"d":["blue",140],"c":-29,"h":["red",4,-45,165,["yellow","blue","blue"]],"b":"blue","g":{"e":{"e":{"e":"blue","c":168,"a":51,"b":-28,"d":"orange","f":"violet"},"c":"violet","a":"green","g":"blue","b":-29,"d":121,"f":69},"a":"violet","d":["orange",[12,192,"green",-17,160,"blue"],131,"blue",41,{"e":"violet","a":"green","d":"blue","c":182,"h":"red","b":10,"g":"blue","f":-37,"i":151},"blue"],"c":{"e":"orange","a":182,"d":155,"j":18,"c":-41,"h":119,"b":148,"g":"green","f":104,"i":141},"h":16,"b":"blue","g":[137],"f":"green","i":-35},"f":[["green","red",19,"yellow","blue","red"],["red",37,[36,"red",-38,183,"violet",-17,119,93],130,-20,77,[64,115,66,"green"]],-13,-23,"green",100,"orange",{"a":"orange","b":"red"}]},"h":["red",{"e":28,"c":{"c":"green","a":149,"b":["orange",137,"violet",184,"orange","green","red",20,72]},"a":114,"g":["blue",{"e":"yellow","a":104,"d":"red","c":-17,"h":"blue","b":"violet","g":"orange","f":"red","i":"red"},181,21,"blue","orange",111,{"e":39,"a":"orange","d":196,"j":119,"c":143,"h":-42,"b":"green","g":190,"f":-43,"i":37}],"b":"orange","d":{"e":["green",44,"green",177,"violet",-44,160,"violet",85,95],"a":{"e":138,"c":"yellow","a":"yellow","b":"blue","d":"green"},"d":"violet","j":"blue","c":100,"h":"blue","b":104,"g":-28,"f":189,"i":"orange"},"f":[121,{"c":110,"a":68,"b":5,"d":57},[108],15,"red",[83,"blue","green",-16,"yellow"],"green"]},[[80],160,68,187,"green","green",94,113,2,163],34,"orange",["yellow",{"e":72,"c":["green",11,"green","green","orange"],"a":{"c":"violet","a":13,"b":66,"d":36},"g":"blue","b":"yellow","d":140,"f":145},"red",53,-11,"yellow","blue",148,{"e":"violet","a":"violet","d":83,"c":"yellow","h":103,"b":-23,"g":36,"f":[154,"red",62,112,35],"i":"violet"}],{"e":174,"a":-49,"d":58,"j":114,"c":"violet","h":[162,"red",54,-8,[142,178,"red",26,"violet",71,-20,38,"orange"],"orange","yellow",[49,25,"violet","green","blue",189,"green","yellow",-25,55],"red"],"b":-13,"g":156,"f":[48,107,-15,167],"i":"blue"},["red",{"a":"red","b":"red"},"violet",[73,"blue","violet","red"],["red","red"],63,-12,108]],"b":{"c":"violet","a":{"a":-39,"b":166},"b":183},"g":36,"f":[45,"yellow","blue","violet",26,7,[[156,-18,"yellow"],-4,-37,[129,-11,["yellow",179,"violet","red","yellow","violet"],"red","red",133],17,"green",137,"red",-9,"yellow"],"yellow",[{"e":"green","a":"yellow","d":52,"c":127,"h":132,"b":38,"g":"yellow","f":"violet","i":"red"},"yellow","red",{"e":{"c":60,"a":126,"b":88},"a":159,"d":"red","j":70,"c":23,"h":195,"b":178,"g":"red","f":"yellow","i":"blue"},13,-37,[196,146,145,"orange",60,"violet",["red",144,51,"red",-26,172,"yellow","red",52,"yellow"],157,"green"],[{"a":-7,"b":"red"},123,{"e":"yellow","c":"orange","a":"orange","b":40,"d":"blue"},139,"green","red",48,{"e":165,"a":60,"d":83,"c":"yellow","h":186,"b":34,"g":"blue","f":178,"i":33},[116,"yellow",179,18,32]],"red"]]},{"c":[6,{"e":{"c":79,"a":82,"b":"orange"},"a":"blue","d":[38,"red",37,[12,134,139,"violet",102,60,"green",82,91],"orange",84],"j":"orange","c":["yellow","green","blue","violet",{"e":"orange","c":157,"a":"green","b":"blue","d":"violet","f":"blue"},64,["violet",176,-7,137,"red",57,"yellow"],"yellow",["blue",170,159],"orange"],"h":170,"b":[3],"g":"violet","f":"violet","i":186},{"e":{"e":"yellow","c":"red","a":"blue","g":["violet",104],"b":124,"d":42,"f":"violet"},"c":-43,"a":-28,"b":[6],"d":[0,97,{"e":-9,"a":"violet","d":31,"c":23,"h":40,"b":76,"g":"red","f":94},["violet"],124,68,"green",37]},[84,{"e":"yellow","c":18,"a":"orange","b":"blue","d":"red"},["yellow",66],81,"orange",-22,-10,"green",139],"red","yellow"],"a":25,"b":"yellow"},[{"e":25,"a":{"e":["violet",22,103,{"e":193,"c":"red","a":"yellow","g":"violet","b":"yellow","d":-33,"f":29},{"e":-10,"a":77,"d":"blue","c":-15,"h":74,"b":-4,"g":"orange","f":153},"yellow",176,94,"green",141],"c":"blue","a":146,"b":-26,"d":-7,"f":149},"d":"green","c":["violet"],"h":"orange","b":[[23,"violet","blue","violet","violet",-40],"orange","yellow"],"g":57,"f":[{"e":141,"a":"yellow","d":"red","c":138,"h":118,"b":{"a":"yellow","b":"red"},"g":133,"f":{"e":169,"c":"violet","a":"green","g":193,"b":"orange","d":"violet","f":-17},"i":"yellow"},72,"green","violet",[106,"red","red","red","yellow",180,"orange",{"a":"green","b":"green"},111,"blue"],147],"i":-7},[[62,65,158,"blue",86,"yellow"],[71,[168,179,"yellow","red","green"],-7],"violet"],"violet",["yellow","red","blue","orange",78,47,{"c":"orange","a":"violet","b":152},[-37,"yellow"],-11,6]],"red",{"e":"red","a":"orange","d":{"e":"red","a":10,"d":"blue","c":{"c":"green","a":91,"b":"yellow","d":-28},"h":158,"b":[["orange"]],"g":"blue","f":[[137,157,50,10,"blue",-12,"violet",76,76,80],[164,46,"orange",-23,{"a":"green"},"yellow","green","green","yellow",48],47]},"j":{"e":["orange",{"e":191,"c":"orange","a":25,"g":"red","b":"yellow","d":148,"f":"orange"},-34,"orange","orange",-36],"a":[{"e":198,"a":["blue",80,121,36,102],"d":{"e":"green","a":"blue","d":76,"j":"red","c":127,"h":"yellow","b":"yellow","g":"yellow","f":163,"i":"red"},"c":"yellow","h":73,"b":"red","g":"green","f":"red"},"violet",{"e":133,"a":"blue","d":"green","j":3,"c":"violet","h":144,"b":25,"g":"green","f":102,"i":"green"},{"e":{"a":"violet","b":"green"},"a":"green","d":[86],"c":"green","h":3,"b":{"c":"orange","a":"orange","b":"yellow","d":193},"g":-34,"f":-35,"i":"green"}],"d":[{"e":"violet","a":"blue","d":{"c":79,"a":"red","b":0,"d":"violet"},"c":77,"h":"violet","b":"green","g":-47,"f":"green"},-49,90],"j":"blue","c":"yellow","h":["violet","green",28,"green",97,"orange"],"b":53,"g":{"e":21,"a":{"c":42,"a":"blue","b":"red"},"d":"violet","c":142,"h":158,"b":"blue","g":["orange",197,"blue","green","yellow",-3,15,-38],"f":62},"f":{"a":32},"i":79},"c":{"e":[{"e":[125,"yellow",-43,"orange","red"],"c":3,"a":"orange","b":"orange","d":{"e":195,"c":16,"a":"yellow","b":94,"d":-20,"f":-13},"f":"yellow"},89,["orange"],"violet"],"c":{"e":"red","a":"orange","d":5,"j":{"a":92,"b":142},"c":22,"h":"blue","b":"orange","g":{"a":[-13,199,"green",133,-41,-22,"orange",169],"b":[134,"blue"]},"f":183,"i":["green",-24,"violet"]},"a":116,"g":[{"e":57,"a":["blue",144,44,43,"orange",34,"yellow",126,"red"],"d":"green","c":"violet","h":"orange","b":"violet","g":"violet","f":[196,60],"i":-21},[168],["red","violet","yellow","green","yellow","green","blue",113,{"e":"orange","a":"red","d":-7,"c":-29,"h":"orange","b":-44,"g":"red","f":-32}],{"a":116},"blue"],"b":{"c":{"e":-41,"a":"orange","d":154,"c":"yellow","h":-12,"b":"yellow","g":"blue","f":"violet","i":105},"a":-23,"b":2},"d":161,"f":"orange"},"h":[187,{"c":"yellow","a":"orange","b":"orange","d":"red"},[[58,"blue"],[111,["yellow","green","green","violet","green"],"orange","blue",112,-45],31,"violet"]],"b":{"e":[[13,"blue",-19,"blue","yellow",144,23,17,110],"violet",{"c":"orange","a":"yellow","b":73,"d":"red"},9,115,"blue","violet","yellow","blue","green"],"a":[-9,"yellow","violet",183,"red",14,"blue",192,"yellow",165],"d":"blue","j":{"e":[86],"a":-14,"d":"yellow","j":"violet","c":"violet","h":{"e":85,"a":["red","yellow",114,111,129,37,71,"blue"],"d":"yellow","c":43,"h":11,"b":72,"g":128,"f":"red"},"b":11,"g":183,"f":34,"i":187},"c":122,"h":{"c":[93,132,"yellow","yellow",91],"a":"green","b":"orange"},"b":[{"e":"blue","a":"green","d":"blue","j":{"e":"orange","a":"violet","d":"orange","j":"yellow","c":"yellow","h":"orange","b":"green","g":"orange","f":"green","i":"green"},"c":186,"h":"yellow","b":145,"g":112,"f":"orange","i":"orange"},100,139,-11,{"e":103,"c":["green","red",-40,90,"violet","violet","yellow"],"a":140,"g":"red","b":"violet","d":"red","f":"blue"},{"c":-43,"a":"orange","b":66},"red",["red","orange",["blue",187],76,192,50,"yellow","violet"]],"g":38,"f":"blue","i":[129,[30,"green",157,92,181,176],{"e":"violet","a":127,"d":172,"j":"yellow","c":148,"h":171,"b":"yellow","g":{"e":115,"a":"red","d":48,"c":-12,"h":"blue","b":"orange","g":"red","f":78},"f":135,"i":79}]},"g":[[173,131,"yellow",193,162,"yellow"],[-5,{"e":[116,102,"orange","yellow"],"a":189,"d":136,"c":{"e":72,"a":"blue","d":-13,"j":"yellow","c":90,"h":"violet","b":169,"g":"orange","f":"blue","i":"blue"},"h":186,"b":"orange","g":"red","f":"orange"},{"e":-8,"a":-37,"d":104,"c":"violet","h":"orange","b":-31,"g":25,"f":168,"i":119},"green",32,[[197,"orange","violet"]],"yellow",{"e":["red",-16,"yellow"],"a":"blue","d":31,"c":"yellow","h":"red","b":"red","g":"violet","f":20,"i":"violet"},31,80],22,{"e":{"e":"red","a":125,"d":"yellow","j":111,"c":34,"h":193,"b":100,"g":"orange","f":31,"i":15},"c":{"e":75,"a":13,"d":-29,"c":["green"],"h":-46,"b":{"a":58},"g":100,"f":{"c":"violet","a":"red","b":-35},"i":["violet","green","orange","violet",183,0,-27,96]},"a":"red","b":[95,"orange","blue","green",170,{"e":3,"a":"blue","d":125,"j":-25,"c":10,"h":25,"b":"blue","g":182,"f":141,"i":27},["violet",7,76,-37,"red",59,"yellow",29]],"d":78,"f":88}],"f":["violet",72],"i":[96,["green","orange",63,"red",83,"yellow"],[{"e":"red","a":{"e":"orange","a":"green","d":183,"c":"orange","h":"yellow","b":146,"g":-1,"f":"red","i":"orange"},"d":"green","j":"red","c":"red","h":"yellow","b":"violet","g":-9,"f":182,"i":"red"},-49,17,"orange",187,-2,[178,"red","red",131,195,[94,-26,"blue","green",0,1,101]]],-25,14,"violet",{"c":"blue","a":"green","b":"orange"},198,-2]},9],[{"e":["green",177,[-38],{"e":"green","a":[147,"green",[56,93,"violet","red"],82,{"e":"blue","a":"orange","d":"red","c":30,"h":"blue","b":10,"g":"orange","f":"orange","i":82},193],"d":"violet","j":69,"c":"green","h":161,"b":-12,"g":{"e":125,"c":-33,"a":-42,"g":70,"b":{"c":81,"a":52,"b":"red","d":"violet"},"d":["violet"],"f":39},"f":["red","green",74,158,14],"i":"yellow"},[144,88,["yellow","violet",-1,"blue",109,[53,86,-36,91,"violet","green",59,15],171,"blue"]],185],"c":{"e":{"a":92},"a":67,"d":"violet","c":"blue","h":[71,"violet",25,154,{"e":16,"a":"red","d":"red","j":"violet","c":54,"h":"violet","b":160,"g":"orange","f":{"e":-47,"a":"green","d":"blue","c":56,"h":175,"b":118,"g":97,"f":"red"},"i":"yellow"},{"e":[107,"violet","violet","blue",-4,"blue","green",82,"red"],"c":{"e":"yellow","c":"violet","a":"orange","b":"blue","d":"green"},"a":172,"b":131,"d":"green","f":43},"red","green",["red","green","violet","violet",132,"green",153,195,-41,[128]]],"b":"yellow","g":"green","f":{"c":72,"a":{"c":"green","a":"violet","b":"green","d":180},"b":48,"d":["blue",70,60,"orange",139,183,"red","red",{"a":"red","b":123},"yellow"]},"i":[66,77,"green","violet",25,[193,"orange",78,"red",["violet","red",163,37,"yellow"]]]},"a":"red","b":175,"d":0,"f":[{"e":38,"a":"yellow","d":"violet","c":68,"h":{"e":"orange","c":129,"a":"blue","b":"green","d":106,"f":"orange"},"b":"red","g":"green","f":{"e":91,"c":46,"a":"blue","g":"red","b":"yellow","d":92,"f":"yellow"}},["green",65,150,86,"orange"],"green",{"c":"green","a":30,"b":"yellow"}]},["blue",70,143,{"a":"green","b":[{"e":83,"c":63,"a":-2,"g":{"e":"green","c":"orange","a":-46,"b":"yellow","d":"red"},"b":39,"d":"red","f":123},"orange",57,34,{"c":"yellow","a":{"c":"blue","a":"green","b":"blue"},"b":"orange","d":{"e":"blue","a":158,"d":"red","c":69,"h":122,"b":6,"g":93,"f":"yellow","i":163}},{"e":183,"c":99,"a":"orange","g":76,"b":42,"d":31,"f":118}]},{"e":31,"c":["orange",186,58,{"e":"violet","c":9,"a":115,"b":[115,"yellow",19,"violet","blue","yellow"],"d":106}],"a":{"e":"red","c":{"a":82,"b":180},"a":71,"b":"yellow","d":100},"g":{"c":68,"a":"red","b":{"a":"blue","b":70}},"b":"yellow","d":"violet","f":-4},"yellow",[{"a":"yellow"},[{"e":"violet","a":159,"d":"violet","c":"blue","h":{"a":195,"b":-16},"b":97,"g":74,"f":126,"i":83},-49,"orange","orange",20,{"e":-37,"c":82,"a":"blue","b":"yellow","d":"orange"},"violet","green",5],"blue",{"a":-2},{"e":-39,"c":"yellow","a":-3,"b":127,"d":[196]},{"c":"red","a":-1,"b":"orange","d":166},{"e":{"e":"red","a":97,"d":"orange","j":47,"c":84,"h":-36,"b":-5,"g":"red","f":"yellow","i":113},"c":55,"a":{"e":[13,108,137,"green","green",-9,71,-36,"orange","blue"],"a":"violet","d":95,"c":6,"h":125,"b":"orange","g":"orange","f":130},"b":-28,"d":[97,46,[-7,"violet",146,155,166,"orange","orange","yellow",148,"red"],"orange",40,"red"]}],[{"c":"violet","a":"yellow","b":64,"d":"orange"},{"e":{"e":"violet","c":"blue","a":{"e":"yellow","a":-41,"d":181,"c":101,"h":"orange","b":"orange","g":"blue","f":51},"g":-25,"b":"red","d":41,"f":1},"a":25,"d":{"e":"orange","a":"green","d":-9,"c":"orange","h":71,"b":"red","g":137,"f":133},"j":[["yellow",116],93,"orange","violet","blue",150,34],"c":66,"h":"violet","b":-49,"g":[60,194,[136,-37,160,"red","orange","red",179,"red"]],"f":[-24,"violet",35],"i":"blue"},{"e":92,"c":"blue","a":"red","b":"blue","d":"green"},"red",[126],96,"red",198],87],{"e":{"e":["orange","violet",{"e":"green","a":-42,"d":103,"c":["violet",-48,37,122,107,"orange","blue",97],"h":"blue","b":92,"g":"orange","f":0},"blue",197,-9,"yellow",{"a":["orange","blue",186,"blue","green","red","red",48,"red","green"],"b":195},121,"blue"],"a":96,"d":"orange","j":94,"c":66,"h":{"a":["violet"],"b":"orange"},"b":"violet","g":191,"f":{"e":"red","c":-32,"a":[149,[69,"green",84,25,"red"],"yellow","violet",4,"violet","green",69],"b":"blue","d":148,"f":111},"i":93},"a":[181],"d":{"e":{"e":{"e":"red","c":36,"a":143,"b":82,"d":11},"a":168,"d":"orange","j":-45,"c":159,"h":"red","b":{"e":120,"a":-37,"d":"green","c":"green","h":"red","b":59,"g":"violet","f":173},"g":166,"f":"orange","i":"yellow"},"a":158,"d":"green","c":126,"h":[[159,"violet","violet","green",101,"orange",141],"violet",122,"yellow","red",79],"b":13,"g":"red","f":{"a":"orange"},"i":{"a":89,"b":{"e":[-20,"green",6,58,18],"a":-17,"d":137,"c":[-25,"orange",95,"yellow","green"],"h":3,"b":"violet","g":26,"f":"green","i":168}}},"c":["orange",{"e":163,"a":{"a":6},"d":-25,"c":164,"h":[-47,"yellow","orange",[139,93,93,"yellow","violet","red",-12],"blue",-32,136,10],"b":"orange","g":"blue","f":174}],"h":["blue",-34,-29,{"e":"violet","a":3,"d":"green","j":"red","c":"orange","h":"green","b":"red","g":"green","f":124,"i":{"e":186,"c":"violet","a":168,"g":110,"b":[127,136,31,109,"blue","red","blue","violet",79,91],"d":"red","f":["violet",191,-15,-22]}}],"b":[124,{"e":-38,"a":{"a":"yellow"},"d":[130,{"c":158,"a":"blue","b":103,"d":197},-36,[153,-6,173,121,"yellow",94,168,"violet",77,-35],168,"red",{"e":-32,"a":"red","d":46,"c":82,"h":91,"b":"blue","g":"yellow","f":"orange","i":174},"green"],"j":[189,-43,41],"c":[185],"h":[182],"b":[139,"violet",-44],"g":"yellow","f":"red","i":["red",-18,"violet","red",31,"red",115,-49,["yellow","yellow","violet","blue","violet","violet"]]},143,"yellow",["violet","red",["blue","violet",{"a":-49},41,"orange","blue"],{"a":"orange"},[93,-8,"yellow",-39]],166,155,"red","violet","orange"],"g":"violet","f":"red","i":[85,126,{"e":{"e":"red","c":-42,"a":51,"b":"yellow","d":"red","f":{"e":130,"c":"violet","a":115,"g":"violet","b":-28,"d":-3,"f":"blue"}},"a":92,"d":114,"c":"violet","h":{"e":-41,"a":"red","d":57,"j":82,"c":"violet","h":"green","b":"red","g":2,"f":-20,"i":78},"b":"yellow","g":"violet","f":86,"i":67},147,146,-33,"blue","violet"]},{"e":[[{"a":174},21,"orange","green","blue",{"e":127,"c":{"c":0,"a":197,"b":"yellow"},"a":"blue","b":["yellow",153,9,"blue"],"d":136}],"blue"],"c":[{"c":"red","a":[-5,"green",["violet"],-47,19,173],"b":106,"d":"yellow"},182,[21,106,"violet",10,"green",20,"orange"],["green"],{"e":-25,"c":"blue","a":"violet","b":["red",27,"blue",21,193,"green",["green","green"]],"d":["orange"],"f":18},"yellow","yellow",{"e":{"e":"violet","a":"green","d":"violet","c":"red","h":171,"b":["red",149,"violet"],"g":"yellow","f":"blue","i":"green"},"c":[86,-30,"orange",56,123,"green"],"a":65,"b":[86,129,"yellow","blue",87,127,182],"d":4,"f":[-36,179,"red",-9,27,{"c":111,"a":178,"b":"yellow","d":25},"red","blue"]},[-3,5,["orange","blue"],70],"yellow"],"a":[{"e":{"c":-15,"a":"red","b":-18,"d":"green"},"a":-42,"d":{"c":-47,"a":"red","b":"green","d":"yellow"},"c":{"e":56,"a":"green","d":"yellow","c":"orange","h":"yellow","b":"blue","g":-35,"f":179,"i":"green"},"h":"blue","b":[35,153],"g":193,"f":{"e":{"e":37,"c":86,"a":"green","g":170,"b":"violet","d":"red","f":-33},"c":187,"a":16,"b":147,"d":19,"f":"red"},"i":88},"green","blue",{"e":{"e":"orange","a":"blue","d":"orange","c":150,"h":-12,"b":"green","g":"red","f":145,"i":"red"},"c":"red","a":"yellow","b":"yellow","d":"blue"},196,{"e":"green","c":186,"a":"green","g":-18,"b":"red","d":[102,"green","orange",[-6,160,128,"green","violet",48,"violet","yellow",50],"blue","green","orange",[199,59,20,15,126]],"f":[[120,"red",69],49,18,84,"red","green",["orange","blue",-31,"green","red",198,115]]},{"e":"yellow","a":196,"d":["orange",{"e":"violet","a":21,"d":"green","c":"red","h":"green","b":18,"g":48,"f":174,"i":"orange"},{"a":-1,"b":"green"},"green"],"c":106,"h":"blue","b":"blue","g":"yellow","f":{"e":-4,"a":61,"d":18,"c":122,"h":"green","b":84,"g":165,"f":"orange"}}],"b":[43,{"e":137,"c":"green","a":"green","b":75,"d":125}],"d":{"e":178,"c":[-21,[116,20,"yellow","blue",161,"orange","blue",30,{"c":181,"a":-30,"b":3}],"orange",-9,"orange",["violet","green",54],"orange",[-20,97,{"c":59,"a":115,"b":-48,"d":-22},28,{"e":59,"c":"green","a":"green","b":"yellow","d":"green","f":-27}],{"a":"violet"},{"e":"blue","c":50,"a":"orange","b":"yellow","d":"orange","f":{"a":"red","b":"green"}}],"a":"orange","b":134,"d":-3,"f":{"e":"violet","a":"orange","d":"green","c":80,"h":"red","b":[140],"g":"red","f":"red"}}},-47,[-28,{"a":[46,["blue",-45,172,193,"blue","green",-2],122,{"a":"green","b":92},-35,[136,[-8,127,20,91,45,"orange"],"green","orange",["orange","yellow",92,162,48,"orange","violet",197],"blue","orange",57,172],"green",135],"b":{"e":[173,{"e":89,"a":96,"d":"orange","c":"orange","h":"green","b":74,"g":"yellow","f":60,"i":135},-11,3,"blue","violet","blue"],"c":160,"a":"blue","b":60,"d":"green","f":"red"}},{"e":[12,"orange"],"c":{"e":45,"c":{"e":-26,"a":86,"d":"yellow","c":["yellow",128,180,135,102,186,"red",194,"green"],"h":"violet","b":{"c":90,"a":-47,"b":56},"g":"blue","f":"red","i":28},"a":71,"b":"violet","d":25},"a":182,"b":"green","d":111,"f":"violet"},{"c":[-21,{"e":[157,13,"red",180,"yellow","green","red",59],"c":-49,"a":82,"b":69,"d":{"e":"orange","a":"yellow","d":98,"j":60,"c":"red","h":199,"b":172,"g":120,"f":"yellow","i":98}},[53,[-23,"orange",135,102,165,170,172,"violet"],"yellow","blue","green",105,97],[74,"violet","orange",["yellow",56,"orange",81,"violet"],"orange",177,75,11],"blue","yellow","blue","red",["blue"]],"a":{"a":-36,"b":"orange"},"b":5,"d":"green"},179,-26,{"a":"green","b":[163,{"a":"orange","b":-35},{"e":180,"a":"blue","d":40,"j":"orange","c":"green","h":"orange","b":"orange","g":131,"f":53,"i":169}]}]],[[{"e":153,"c":"orange","a":"yellow","g":{"e":-4,"c":{"e":115,"c":"red","a":121,"b":151,"d":"red"},"a":"orange","b":194,"d":"orange"},"b":{"a":30},"d":["green",[31,["violet"],["orange",152,"yellow","red"],"yellow"],"violet",{"a":"violet"},171,"violet",{"c":"violet","a":"orange","b":"orange"},"green"],"f":{"e":"yellow","c":["green","red"],"a":"red","g":-17,"b":-3,"d":-42,"f":150}},"orange",{"c":["orange"],"a":"red","b":{"c":-32,"a":{"a":"blue","b":"orange"},"b":{"c":75,"a":{"e":"green","a":101,"d":-3,"j":"violet","c":56,"h":166,"b":192,"g":-5,"f":-22,"i":100},"b":"yellow"},"d":159},"d":{"e":"violet","a":"yellow","d":["green","orange","blue","green"],"j":"yellow","c":[23,"green","blue","yellow","violet","red"],"h":[149,-24,"red",152],"b":-12,"g":"red","f":89,"i":169}},[{"e":{"e":"violet","a":[124,"blue","orange","green",160],"d":113,"c":"red","h":"blue","b":["violet","red","violet",104],"g":85,"f":179,"i":{"e":"orange","a":"violet","d":"violet","j":"yellow","c":191,"h":"red","b":53,"g":-25,"f":"green","i":169}},"a":[147,120],"d":"green","j":["yellow",["yellow",108,"violet",114,"green",195,25,"green"],"green","orange"],"c":["orange",148,141,"yellow",32,-24],"h":124,"b":"orange","g":[121,"blue","red","violet",-18],"f":"violet","i":"red"},["violet","green",94,91,"blue"],{"c":[9,"violet",-18,69,"orange","orange",-24,"yellow","yellow"],"a":"yellow","b":150,"d":73}],110,["blue",-9,"blue","yellow",{"e":[163,45,67],"c":135,"a":50,"b":[43,26,18,120,"green","blue",10,"green",68,-2],"d":{"e":136,"a":15,"d":89,"c":[65,"green",108,122,"yellow","violet","yellow"],"h":"green","b":{"e":125,"a":21,"d":51,"c":153,"h":33,"b":158,"g":"blue","f":26,"i":"green"},"g":-33,"f":[-16,14,"red","red",126,"violet",-16]}},"red",{"e":120,"c":"red","a":{"e":"green","a":"yellow","d":18,"c":150,"h":185,"b":["yellow","red","violet",48,"violet","blue"],"g":"green","f":{"a":"yellow"}},"g":[12,"blue",168,"orange",{"a":"red"},168,"red"],"b":-2,"d":{"e":"violet","c":"yellow","a":86,"g":155,"b":3,"d":-24,"f":149},"f":"yellow"}],[{"c":"green","a":91,"b":"green"},[{"e":"red","c":98,"a":{"c":"red","a":-49,"b":176,"d":105},"b":"red","d":169,"f":"blue"},-46,"green","blue",-30,{"c":154,"a":72,"b":"yellow"},[161,85]],111,"blue",172,57,{"a":-23,"b":"green"},81,[160,["blue","green","green",157],137,["blue",["violet",162],[153,"yellow","orange","violet",127,"green",148,182,29,150],-33,168,"blue"],95]]],["yellow",132,{"c":16,"a":[113],"b":"red","d":{"e":"green","c":24,"a":{"a":"red"},"g":125,"b":["violet",2,101],"d":"green","f":132}},89],[{"e":"yellow","c":[68,"green",[160,146],175,"orange",185,"blue",[198,[179,"yellow","green",72,33,112,179,"violet",194,1]]],"a":["blue","violet",153,"blue",{"a":77,"b":"yellow"},-19,"yellow","green"],"b":"yellow","d":29,"f":{"c":"violet","a":"violet","b":-18}},"yellow",{"e":["violet","green",["red","red","blue",126,137,47,["blue","blue","green",102,"orange","yellow","green"],"red"],[["blue","orange",16,-2],"green","orange","yellow",27,150,0],{"e":62,"c":"yellow","a":"blue","b":94,"d":10,"f":31},[-47,{"e":"green","a":"yellow","d":197,"j":99,"c":"yellow","h":152,"b":"orange","g":85,"f":"green","i":"green"},174,"blue","green"],106],"c":["blue",118,[120,161,-41,["violet"],"violet","yellow"],"red"],"a":["orange","green","red",58,"green",5,178,191,-43],"b":62,"d":"violet"},{"e":97,"a":[["yellow",122,"orange","red",{"e":165,"c":"blue","a":63,"g":"violet","b":"blue","d":"yellow","f":77},[104,118,"green","red","orange",61]],{"c":124,"a":86,"b":"violet"},"yellow",{"e":[98,110,40,104,126,90,140,"blue",46],"a":-42,"d":[77,"green","red",-28,"blue",88,29,-9,-28],"j":-3,"c":"green","h":{"e":153,"c":45,"a":"green","g":127,"b":"red","d":183,"f":"orange"},"b":3,"g":0,"f":["blue","green",62,"red","yellow","green"],"i":"orange"},127,171,[118,[119,"blue"],15,87,"orange",{"e":-34,"c":"violet","a":18,"b":153,"d":37,"f":"red"}],"red"],"d":"red","c":["yellow","red","blue","red","violet","red",-13,179],"h":100,"b":{"e":"orange","a":48,"d":"red","c":{"e":"violet","a":"violet","d":"orange","c":["violet","yellow","blue","yellow"],"h":"red","b":"violet","g":149,"f":"green"},"h":"yellow","b":46,"g":"blue","f":184},"g":16,"f":36,"i":{"e":"green","a":-4,"d":{"c":{"e":"yellow","a":"blue","d":177,"j":"violet","c":"red","h":140,"b":131,"g":137,"f":53,"i":28},"a":16,"b":161},"c":48,"h":[53,7,[137,80,113,160,"blue",105]],"b":"blue","g":"orange","f":"green"}},"yellow",{"c":["orange",{"e":-11,"c":-36,"a":"green","b":"yellow","d":"yellow","f":{"a":186}},-4,170,"green","green",16,123],"a":-29,"b":{"c":"orange","a":"blue","b":"orange"}},{"c":[[161,"violet","blue"],"yellow","yellow",["red",22,["red",92,103,126,-13,67,"blue"],-21,136,"violet",[193]],"blue",-15],"a":{"e":179,"a":1,"d":"yellow","c":[92,15],"h":"orange","b":{"e":-6,"a":"violet","d":"yellow","j":155,"c":198,"h":-18,"b":14,"g":"blue","f":-39,"i":"orange"},"g":{"a":"yellow"},"f":"blue"},"b":87},"yellow",{"c":"blue","a":[{"e":"red","a":"blue","d":"orange","c":"orange","h":-27,"b":"yellow","g":47,"f":{"e":"violet","a":"green","d":185,"j":"orange","c":"violet","h":138,"b":-3,"g":"blue","f":"red","i":150}},{"e":75,"c":168,"a":[12,"blue","green"],"g":{"c":"blue","a":"green","b":107},"b":-36,"d":"orange","f":72},2,[120,"green",182,"yellow",-23,"red"],"green",{"e":"blue","a":"orange","d":"blue","c":157,"h":"green","b":58,"g":"blue","f":-39},"red","orange",32],"b":"violet"},{"e":178,"a":{"c":{"e":59,"a":186,"d":"orange","c":{"a":"violet"},"h":"green","b":198,"g":{"a":"blue","b":"blue"},"f":"orange","i":2},"a":"red","b":[95,130,"blue","violet",98]},"d":176,"c":-38,"h":["yellow",128,"green",39,74,"yellow",5],"b":"blue","g":"violet","f":"orange"}],{"a":{"e":135,"c":{"e":{"e":["orange",-44,81,-11,-1,47,"orange",-36],"c":10,"a":12,"b":"red","d":{"e":"violet","c":"violet","a":161,"b":192,"d":133},"f":77},"c":92,"a":"yellow","g":["blue"],"b":{"e":"violet","a":-48,"d":"orange","c":"blue","h":"orange","b":-40,"g":81,"f":77},"d":102,"f":"yellow"},"a":127,"b":"violet","d":{"e":130,"a":36,"d":148,"c":"yellow","h":117,"b":"orange","g":"orange","f":-19,"i":["green",{"e":"red","a":191,"d":159,"j":"violet","c":"red","h":147,"b":"blue","g":"red","f":"red","i":"green"},"blue",62]},"f":-5},"b":[["green",-36,62,"green","blue",{"c":"violet","a":{"a":-4},"b":"violet","d":88},{"e":"yellow","c":166,"a":["blue"],"g":50,"b":146,"d":"blue","f":142},"yellow"]]},["red","blue",{"e":{"a":-16},"a":[["violet",{"e":"blue","a":171,"d":"blue","c":"blue","h":"green","b":"green","g":"orange","f":"yellow"},186,"orange",195,87,"green",[67,158,"blue",23]],25],"d":[159,74],"c":-28,"h":{"e":-16,"a":"red","d":55,"c":158,"h":167,"b":"red","g":27,"f":{"e":"yellow","c":[34,"blue",-22,"orange"],"a":94,"b":-30,"d":["blue",133,39,102,"orange"]}},"b":119,"g":{"e":104,"c":90,"a":["orange","blue",158,-34,"violet"],"g":"green","b":33,"d":["violet",125,"yellow","yellow",117,["blue",25,"orange"],["red",193,-23,"red","green",146,173],"red","yellow",10],"f":50},"f":47,"i":{"e":[121,144,172,171,{"e":"green","a":9,"d":"violet","c":-33,"h":64,"b":-4,"g":45,"f":75}],"a":8,"d":{"c":68,"a":["yellow","red","green"],"b":"violet","d":9},"c":"blue","h":17,"b":199,"g":115,"f":[["green",108,113,"red",6,"violet","violet","green",57,"green"],"orange",177,"red",34,"blue","red"],"i":-25}},{"e":"blue","a":["orange","yellow",["violet",27,"violet",128,120,{"e":"green","a":"orange","d":"orange","j":"blue","c":"yellow","h":"yellow","b":"yellow","g":139,"f":132,"i":81},"blue","red",53],7,"orange","violet",{"c":"yellow","a":{"a":-11},"b":"orange","d":87},"violet"],"d":[{"a":175},[163,"orange",185],[-30,109,194,119,170,"green","violet","yellow",125,"red"],"blue",{"e":"green","c":152,"a":37,"b":"red","d":["orange"],"f":"orange"},69,"yellow",{"e":{"e":"yellow","c":"violet","a":144,"b":"yellow","d":141,"f":"blue"},"c":"blue","a":"green","g":"yellow","b":178,"d":"yellow","f":-8},"green",["green","orange",-42,"orange"]],"c":"red","h":54,"b":"orange","g":["green",2,146,-6,{"e":52,"a":"orange","d":"red","c":"yellow","h":141,"b":35,"g":{"e":"violet","a":"blue","d":"yellow","c":"blue","h":100,"b":119,"g":"blue","f":"yellow"},"f":136,"i":"yellow"},194,["yellow",139,"green",["blue",14,"green","blue","blue",119,"violet",-5],{"a":61,"b":"orange"},"violet"]],"f":20},{"c":"orange","a":{"e":135,"c":"violet","a":111,"g":{"a":"red","b":96},"b":186,"d":33,"f":127},"b":{"e":83,"a":"yellow","d":"orange","c":"blue","h":"orange","b":0,"g":"orange","f":164,"i":"blue"},"d":-28},-42,{"e":"green","c":{"e":-20,"c":"yellow","a":66,"b":156,"d":"violet"},"a":[-9,129],"g":74,"b":{"e":"violet","c":"green","a":[52,"blue",["green",-8,"green","green"],"red",188,43,"green",{"e":"orange","a":40,"d":-6,"c":"orange","h":93,"b":"green","g":103,"f":"red"}],"g":{"e":"red","c":"yellow","a":16,"b":7,"d":70},"b":{"e":133,"a":150,"d":{"a":34,"b":"green"},"j":166,"c":156,"h":79,"b":"red","g":178,"f":-37,"i":163},"d":"blue","f":"green"},"d":{"c":"blue","a":"violet","b":177,"d":80},"f":[61,88,"yellow",{"c":"blue","a":"orange","b":"violet","d":"yellow"},{"c":119,"a":"violet","b":{"a":"red"},"d":84},95,170]},{"e":191,"c":2,"a":"orange","b":{"a":[-9,"green","violet",["green",132,"red",61,85],3,2]},"d":["green","yellow","violet",-46,48,"green"]}],["violet",["yellow"],["blue",{"e":-15,"c":{"e":["green","violet",0,3,183,165,-1,"orange","blue"],"a":"violet","d":20,"c":"violet","h":"yellow","b":60,"g":"violet","f":163,"i":135},"a":71,"b":{"c":[115,"green",25,"yellow","blue",66],"a":"yellow","b":"green"},"d":"violet","f":{"e":"yellow","c":"blue","a":"blue","b":59,"d":[69,71,"yellow","red",99,"green","yellow",144,43,-38]}},"yellow","blue","orange",55,{"c":[-9,-16,"green",100,28,"red","blue","blue",174],"a":-31,"b":106,"d":"violet"},"blue"],[141,[32,"orange",{"c":-6,"a":-7,"b":64},["blue",{"e":-24,"c":"yellow","a":153,"b":"orange","d":"blue","f":"violet"},"violet",-28,197,"yellow","green","green"],2,{"e":"violet","c":"red","a":"red","b":"yellow","d":"yellow"},["yellow"],"red"],["green",[-16,47],"blue",87,"red","green"],105,"violet",[[127,"violet",81],"red","blue",[193,178,-6],20,"red",61],-2,"blue",-35],{"c":-12,"a":189,"b":"red"},[12,196,["red",27,["violet","green",15,["yellow","green",152,56,187,"yellow",69],"violet"]],127,{"a":"yellow"},-35,[[180,{"c":"yellow","a":191,"b":"violet","d":"red"},41,33,-5],188,"red","violet",23,100,30,91,-15],"blue"],[[129,"blue",{"a":"red"},"violet","green",56,["yellow"],180,[156,"violet"],-49],48,"red",38,{"a":{"e":93,"a":"yellow","d":170,"c":{"e":116,"a":5,"d":89,"j":"blue","c":"blue","h":"red","b":"blue","g":-2,"f":"red","i":-7},"h":148,"b":149,"g":"red","f":-18,"i":-44}},101,183],[25,16,123]],{"e":{"c":"orange","a":{"e":[{"c":"green","a":"orange","b":100,"d":-30}],"a":187,"d":"green","c":{"a":122},"h":-10,"b":118,"g":-12,"f":63},"b":{"e":["violet","yellow","yellow",167,163,5],"a":-28,"d":[-2,61,"red",-18,"red",{"e":"yellow","a":"orange","d":"yellow","j":"green","c":"orange","h":-10,"b":-32,"g":115,"f":141,"i":164},"red",["violet",99,"orange","blue","orange","green","green","violet","yellow"]],"c":-24,"h":"blue","b":"violet","g":47,"f":156},"d":195},"a":{"a":[176]},"d":["violet",[["green",180,"violet","yellow"],{"e":133,"a":"violet","d":{"e":57,"a":"yellow","d":57,"j":"violet","c":"red","h":33,"b":"green","g":"yellow","f":"green","i":79},"j":"orange","c":"violet","h":62,"b":"blue","g":-37,"f":"violet","i":93},-43,"violet",103,"yellow",194,56],{"e":-19,"c":"yellow","a":"orange","b":-19,"d":"red","f":"yellow"}],"c":162,"h":[73,"green",[87,{"a":"green"}],[56,"green",[["green",-2,"green",-47,"yellow",-39,47],"red",129,[90,181,50,"green","green","green","blue",7,"violet"],-3,9,-12,171],"red","orange",159,["violet","yellow",77,86,"yellow","yellow","red",185],145,[81,133]],"yellow",-3,[{"c":["orange",108,82],"a":"violet","b":{"a":"yellow","b":"yellow"},"d":42}],"orange",[-27,["green",{"c":"violet","a":"violet","b":"orange","d":15},78],"red",23],"orange"],"b":{"e":"yellow","a":46,"d":[118,31,142,{"e":-48,"a":"blue","d":"green","c":"violet","h":69,"b":"orange","g":178,"f":"orange","i":"green"},{"e":109,"a":"orange","d":-7,"c":42,"h":168,"b":"blue","g":157,"f":{"a":93,"b":142},"i":38},[59,80],"orange",73,"violet"],"c":122,"h":{"e":153,"c":"yellow","a":11,"b":"orange","d":101},"b":"blue","g":"orange","f":[{"e":48,"c":-39,"a":77,"g":-33,"b":"yellow","d":30,"f":36},153,{"c":"violet","a":78,"b":63,"d":"orange"},117],"i":"red"},"g":"yellow","f":{"a":"orange","b":[{"a":87},"violet","orange",96,154,"orange","violet",{"a":[-45],"b":103}]}},"red"],[{"e":"violet","a":{"e":167,"a":{"e":"orange","c":{"e":"red","c":76,"a":"green","b":"violet","d":146,"f":152},"a":"violet","b":-8,"d":76,"f":"red"},"d":[102,"yellow","blue","blue",22,73],"c":"red","h":{"e":{"c":92,"a":178,"b":{"e":-43,"a":"yellow","d":136,"j":"red","c":193,"h":98,"b":"orange","g":49,"f":"yellow","i":"violet"}},"a":54,"d":138,"j":[0,[177,178],"red",52,[87,"violet",123,"orange","orange","yellow",48,"yellow"],"violet",100,"blue"],"c":3,"h":"green","b":175,"g":{"e":[175,-25,-47,"orange",60,185],"a":["orange",-49,156],"d":"yellow","j":8,"c":-28,"h":129,"b":[89,-12,67,"green",195,"red","violet",150,"red",106],"g":"violet","f":-29,"i":123},"f":"orange","i":71},"b":[172,["yellow","violet","green","blue",194],-46,{"a":102,"b":"green"}],"g":[{"e":{"c":23,"a":"yellow","b":-25},"a":"blue","d":"green","j":185,"c":"yellow","h":["orange","violet",-21],"b":{"c":191,"a":197,"b":"yellow"},"g":115,"f":-41,"i":"blue"},-17,[-23,64,"red",8,"orange",[105,-11,29,-23,30,65,15],170],"yellow","yellow",-46,"green","orange",143],"f":177},"d":"red","c":"red","h":135,"b":{"e":"red","a":"orange","d":["violet",[23,"red","violet","orange",66,{"c":"orange","a":"green","b":169,"d":57},"blue",125,"green"],110,135,[-40,"violet","yellow",-26,-23,44],"orange",28],"c":"orange","h":107,"b":91,"g":105,"f":{"e":{"e":164,"c":180,"a":"blue","b":"yellow","d":144},"c":"violet","a":"violet","g":95,"b":"red","d":"violet","f":"green"},"i":156},"g":["violet",108,["blue","yellow","red",[23,"yellow",3,159,112],{"e":-41,"c":"green","a":22,"b":"violet","d":"blue","f":"blue"},"violet",-27,"green","violet",-17],"green",{"e":{"e":[-19,96,-28,"orange"],"c":"yellow","a":"yellow","g":124,"b":97,"d":{"a":"blue"},"f":"green"},"a":46,"d":["blue",118,"yellow","yellow","yellow","green",["yellow",-10,90,167,"red",54,-15]],"j":106,"c":"red","h":[{"e":"red","c":28,"a":"yellow","b":170,"d":"blue","f":105},-40,"orange",188,"yellow",142],"b":117,"g":"violet","f":{"a":[-5,"red",46,182,"red","orange"]},"i":"yellow"},["orange",88,18,{"e":"blue","a":"violet","d":"blue","c":"violet","h":"violet","b":196,"g":103,"f":67,"i":13}],"blue","blue"],"f":-19,"i":{"a":166}},164],[{"e":{"e":"blue","a":13,"d":{"e":{"e":"orange","a":88,"d":"red","c":"yellow","h":[93,79],"b":"orange","g":109,"f":34,"i":-13},"a":-44,"d":"red","j":[173,78,"red",{"e":"yellow","a":-32,"d":"blue","j":"violet","c":"blue","h":119,"b":"green","g":-30,"f":193,"i":95},"orange",-43,-16],"c":["green",{"e":41,"c":"red","a":109,"b":159,"d":59},173,18,"violet",21,"red"],"h":"blue","b":44,"g":{"a":129,"b":-10},"f":-26,"i":27},"j":"red","c":{"a":{"c":-28,"a":"green","b":188,"d":"blue"},"b":"blue"},"h":[183,[118,[-7,"orange"],132,[23,175,"yellow","green",11,178,171,"orange","blue",18],134,1,"green",[-9,99],103,-25],"red",[65,"red","blue"],"violet","blue"],"b":"yellow","g":164,"f":-9,"i":{"c":51,"a":"green","b":115,"d":{"a":27,"b":"red"}}},"a":[{"e":[143,"violet",128,"red","yellow",185,"green","red","red"],"a":29,"d":"red","c":170,"h":[131,"violet",96,{"a":"yellow","b":"green"},139,22,176,"yellow",[-46,-14,"red","blue",83,141],[132,108,"blue","blue","green",197,"yellow"]],"b":"blue","g":"orange","f":"yellow","i":[-9]},"violet",56,[169,12,155,["red",197,{"e":"violet","a":22,"d":"violet","c":84,"h":"red","b":70,"g":"violet","f":-41},47,"violet"],[["green","green",179,56,"green","violet",171,"violet","violet"],"blue","red","green",-17,"green",190],"green","red",146,60],"yellow","red","yellow","violet"],"d":[[141,40,"yellow",1,"blue","green","yellow",{"e":13,"a":"blue","d":"red","c":"red","h":176,"b":"violet","g":164,"f":4,"i":"violet"}]],"c":72,"h":15,"b":"yellow","g":{"e":[-12,"blue",["red","blue",11],29,{"e":59,"c":"red","a":{"e":55,"a":"blue","d":"orange","c":"yellow","h":"violet","b":-19,"g":"green","f":"violet","i":197},"b":"orange","d":"violet","f":90},[-14,154,"violet","orange",74,{"e":"yellow","a":"violet","d":66,"c":"yellow","h":80,"b":"yellow","g":"yellow","f":"orange","i":"blue"},"green","red",116,149],"green",108],"c":{"c":28,"a":"blue","b":"yellow","d":"blue"},"a":36,"b":["orange","green","orange","green","red",46,55,"blue",["violet",98,[163,-35,163,-28],"blue","red",155,"blue"],-8],"d":163},"f":[9,"green",{"c":"green","a":"violet","b":68,"d":"yellow"},114,33,1,-25]},["red",[-20,{"c":"yellow","a":"red","b":"green","d":{"a":"red"}},"red",[[141,76],[174],100,{"e":126,"c":39,"a":["violet",94,"orange",102,"blue"],"b":55,"d":"yellow","f":"yellow"},146,{"c":169,"a":"red","b":"red"},[["green",-48,"violet","orange"],[80,-7,-22,"yellow","orange","yellow",185,"orange"],"green","violet","orange"],"red"],"yellow"],[{"a":["orange","blue"],"b":[{"a":-42,"b":"violet"},"green",99,-20,"blue"]},{"c":"blue","a":"violet","b":14,"d":9},"green",{"c":["blue",148,[38,139,125,52,"red",40,190,"yellow",21,"violet"],"violet",110,"green"],"a":{"c":97,"a":[35,"orange",44,"red",87,"orange","blue",61,"yellow"],"b":176,"d":144},"b":137},85,[192,-37,"orange",{"c":"yellow","a":-10,"b":[71]},"yellow",176,["green",14],{"a":102},-39],"violet",164],-9,"blue",[["blue"],70]]]] diff --git a/advent13.ipynb b/advent13.ipynb new file mode 100644 index 0000000..def6b70 --- /dev/null +++ b/advent13.ipynb @@ -0,0 +1,420 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false, + "scrolled": true + }, + "outputs": [], + "source": [ + "pi13 = [l.strip() for l in open('advent13.txt').read().splitlines()]" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "{'Alice': {'Bob': 54,\n", + " 'Carol': -81,\n", + " 'David': -42,\n", + " 'Eric': 89,\n", + " 'Frank': -89,\n", + " 'George': 97,\n", + " 'Mallory': -94},\n", + " 'Bob': {'Alice': 3,\n", + " 'Carol': -70,\n", + " 'David': -31,\n", + " 'Eric': 72,\n", + " 'Frank': -25,\n", + " 'George': -95,\n", + " 'Mallory': 11},\n", + " 'Carol': {'Alice': -83,\n", + " 'Bob': 8,\n", + " 'David': 35,\n", + " 'Eric': 10,\n", + " 'Frank': 61,\n", + " 'George': 10,\n", + " 'Mallory': 29},\n", + " 'David': {'Alice': 67,\n", + " 'Bob': 25,\n", + " 'Carol': 48,\n", + " 'Eric': -65,\n", + " 'Frank': 8,\n", + " 'George': 84,\n", + " 'Mallory': 9},\n", + " 'Eric': {'Alice': -51,\n", + " 'Bob': -39,\n", + " 'Carol': 84,\n", + " 'David': -98,\n", + " 'Frank': -20,\n", + " 'George': -6,\n", + " 'Mallory': 60},\n", + " 'Frank': {'Alice': 51,\n", + " 'Bob': 79,\n", + " 'Carol': 88,\n", + " 'David': 33,\n", + " 'Eric': 43,\n", + " 'George': 77,\n", + " 'Mallory': -3},\n", + " 'George': {'Alice': -14,\n", + " 'Bob': -12,\n", + " 'Carol': -52,\n", + " 'David': 14,\n", + " 'Eric': -62,\n", + " 'Frank': -18,\n", + " 'Mallory': -17},\n", + " 'Mallory': {'Alice': -36,\n", + " 'Bob': 76,\n", + " 'Carol': -34,\n", + " 'David': 37,\n", + " 'Eric': 40,\n", + " 'Frank': 18,\n", + " 'George': 7}}" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# import collections\n", + "\n", + "# Seating = collections.namedtuple('Seating', ['person', 'neighbour', 'gain'])\n", + "\n", + "preferences = {}\n", + "for line in pi13:\n", + " words = line.split()\n", + " gain = int(words[3])\n", + " if words[2] == 'lose':\n", + " gain *= -1\n", + " if words[0] not in preferences:\n", + " preferences[words[0]] = {}\n", + " preferences[words[0]][words[-1][:-1]] = gain\n", + "preferences" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def score(seating, prefs):\n", + " happiness = 0\n", + " for i in range(len(seating)):\n", + " l = (i - 1) % len(seating)\n", + " r = (i + 1) % len(seating)\n", + " happiness += prefs[seating[i]][seating[l]]\n", + " happiness += prefs[seating[i]][seating[r]]\n", + " #print(i, l, r, ':', seating[i],'->', seating[l], preferences[seating[i]][seating[l]], \n", + " # ';', seating[i],'->', seating[r], preferences[seating[i]][seating[r]])\n", + " return happiness" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "-333" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "s = list(preferences.keys())\n", + "score(list(preferences.keys()), preferences)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "709" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import itertools\n", + "\n", + "seatings = itertools.permutations(list(preferences.keys()))\n", + "\n", + "max(score(s, preferences) for s in seatings)" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "{'Alice': {'Bob': 54,\n", + " 'Carol': -81,\n", + " 'David': -42,\n", + " 'Eric': 89,\n", + " 'Frank': -89,\n", + " 'George': 97,\n", + " 'Mallory': -94},\n", + " 'Bob': {'Alice': 3,\n", + " 'Carol': -70,\n", + " 'David': -31,\n", + " 'Eric': 72,\n", + " 'Frank': -25,\n", + " 'George': -95,\n", + " 'Mallory': 11},\n", + " 'Carol': {'Alice': -83,\n", + " 'Bob': 8,\n", + " 'David': 35,\n", + " 'Eric': 10,\n", + " 'Frank': 61,\n", + " 'George': 10,\n", + " 'Mallory': 29},\n", + " 'David': {'Alice': 67,\n", + " 'Bob': 25,\n", + " 'Carol': 48,\n", + " 'Eric': -65,\n", + " 'Frank': 8,\n", + " 'George': 84,\n", + " 'Mallory': 9},\n", + " 'Eric': {'Alice': -51,\n", + " 'Bob': -39,\n", + " 'Carol': 84,\n", + " 'David': -98,\n", + " 'Frank': -20,\n", + " 'George': -6,\n", + " 'Mallory': 60},\n", + " 'Frank': {'Alice': 51,\n", + " 'Bob': 79,\n", + " 'Carol': 88,\n", + " 'David': 33,\n", + " 'Eric': 43,\n", + " 'George': 77,\n", + " 'Mallory': -3},\n", + " 'George': {'Alice': -14,\n", + " 'Bob': -12,\n", + " 'Carol': -52,\n", + " 'David': 14,\n", + " 'Eric': -62,\n", + " 'Frank': -18,\n", + " 'Mallory': -17},\n", + " 'Mallory': {'Alice': -36,\n", + " 'Bob': 76,\n", + " 'Carol': -34,\n", + " 'David': 37,\n", + " 'Eric': 40,\n", + " 'Frank': 18,\n", + " 'George': 7}}" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# import collections\n", + "\n", + "# Seating = collections.namedtuple('Seating', ['person', 'neighbour', 'gain'])\n", + "\n", + "preferences2 = {}\n", + "for line in pi13:\n", + " words = line.split()\n", + " gain = int(words[3])\n", + " if words[2] == 'lose':\n", + " gain *= -1\n", + " if words[0] not in preferences2:\n", + " preferences2[words[0]] = {}\n", + " preferences2[words[0]][words[-1][:-1]] = gain\n", + "preferences2" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "{'Alice': {'Bob': 54,\n", + " 'Carol': -81,\n", + " 'David': -42,\n", + " 'Eric': 89,\n", + " 'Frank': -89,\n", + " 'George': 97,\n", + " 'Mallory': -94,\n", + " 'me': 0},\n", + " 'Bob': {'Alice': 3,\n", + " 'Carol': -70,\n", + " 'David': -31,\n", + " 'Eric': 72,\n", + " 'Frank': -25,\n", + " 'George': -95,\n", + " 'Mallory': 11,\n", + " 'me': 0},\n", + " 'Carol': {'Alice': -83,\n", + " 'Bob': 8,\n", + " 'David': 35,\n", + " 'Eric': 10,\n", + " 'Frank': 61,\n", + " 'George': 10,\n", + " 'Mallory': 29,\n", + " 'me': 0},\n", + " 'David': {'Alice': 67,\n", + " 'Bob': 25,\n", + " 'Carol': 48,\n", + " 'Eric': -65,\n", + " 'Frank': 8,\n", + " 'George': 84,\n", + " 'Mallory': 9,\n", + " 'me': 0},\n", + " 'Eric': {'Alice': -51,\n", + " 'Bob': -39,\n", + " 'Carol': 84,\n", + " 'David': -98,\n", + " 'Frank': -20,\n", + " 'George': -6,\n", + " 'Mallory': 60,\n", + " 'me': 0},\n", + " 'Frank': {'Alice': 51,\n", + " 'Bob': 79,\n", + " 'Carol': 88,\n", + " 'David': 33,\n", + " 'Eric': 43,\n", + " 'George': 77,\n", + " 'Mallory': -3,\n", + " 'me': 0},\n", + " 'George': {'Alice': -14,\n", + " 'Bob': -12,\n", + " 'Carol': -52,\n", + " 'David': 14,\n", + " 'Eric': -62,\n", + " 'Frank': -18,\n", + " 'Mallory': -17,\n", + " 'me': 0},\n", + " 'Mallory': {'Alice': -36,\n", + " 'Bob': 76,\n", + " 'Carol': -34,\n", + " 'David': 37,\n", + " 'Eric': 40,\n", + " 'Frank': 18,\n", + " 'George': 7,\n", + " 'me': 0},\n", + " 'me': {'Alice': 0,\n", + " 'Bob': 0,\n", + " 'Carol': 0,\n", + " 'David': 0,\n", + " 'Eric': 0,\n", + " 'Frank': 0,\n", + " 'George': 0,\n", + " 'Mallory': 0,\n", + " 'me': 0}}" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "preferences2['me'] = {other: 0 for other in preferences2}\n", + "for other in preferences2:\n", + " preferences2[other]['me'] = 0\n", + "preferences2" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "668" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "seatings = itertools.permutations(list(preferences2.keys()))\n", + "\n", + "max(score(s, preferences2) for s in seatings)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.4.3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/advent13.txt b/advent13.txt new file mode 100644 index 0000000..35be357 --- /dev/null +++ b/advent13.txt @@ -0,0 +1,56 @@ +Alice would gain 54 happiness units by sitting next to Bob. +Alice would lose 81 happiness units by sitting next to Carol. +Alice would lose 42 happiness units by sitting next to David. +Alice would gain 89 happiness units by sitting next to Eric. +Alice would lose 89 happiness units by sitting next to Frank. +Alice would gain 97 happiness units by sitting next to George. +Alice would lose 94 happiness units by sitting next to Mallory. +Bob would gain 3 happiness units by sitting next to Alice. +Bob would lose 70 happiness units by sitting next to Carol. +Bob would lose 31 happiness units by sitting next to David. +Bob would gain 72 happiness units by sitting next to Eric. +Bob would lose 25 happiness units by sitting next to Frank. +Bob would lose 95 happiness units by sitting next to George. +Bob would gain 11 happiness units by sitting next to Mallory. +Carol would lose 83 happiness units by sitting next to Alice. +Carol would gain 8 happiness units by sitting next to Bob. +Carol would gain 35 happiness units by sitting next to David. +Carol would gain 10 happiness units by sitting next to Eric. +Carol would gain 61 happiness units by sitting next to Frank. +Carol would gain 10 happiness units by sitting next to George. +Carol would gain 29 happiness units by sitting next to Mallory. +David would gain 67 happiness units by sitting next to Alice. +David would gain 25 happiness units by sitting next to Bob. +David would gain 48 happiness units by sitting next to Carol. +David would lose 65 happiness units by sitting next to Eric. +David would gain 8 happiness units by sitting next to Frank. +David would gain 84 happiness units by sitting next to George. +David would gain 9 happiness units by sitting next to Mallory. +Eric would lose 51 happiness units by sitting next to Alice. +Eric would lose 39 happiness units by sitting next to Bob. +Eric would gain 84 happiness units by sitting next to Carol. +Eric would lose 98 happiness units by sitting next to David. +Eric would lose 20 happiness units by sitting next to Frank. +Eric would lose 6 happiness units by sitting next to George. +Eric would gain 60 happiness units by sitting next to Mallory. +Frank would gain 51 happiness units by sitting next to Alice. +Frank would gain 79 happiness units by sitting next to Bob. +Frank would gain 88 happiness units by sitting next to Carol. +Frank would gain 33 happiness units by sitting next to David. +Frank would gain 43 happiness units by sitting next to Eric. +Frank would gain 77 happiness units by sitting next to George. +Frank would lose 3 happiness units by sitting next to Mallory. +George would lose 14 happiness units by sitting next to Alice. +George would lose 12 happiness units by sitting next to Bob. +George would lose 52 happiness units by sitting next to Carol. +George would gain 14 happiness units by sitting next to David. +George would lose 62 happiness units by sitting next to Eric. +George would lose 18 happiness units by sitting next to Frank. +George would lose 17 happiness units by sitting next to Mallory. +Mallory would lose 36 happiness units by sitting next to Alice. +Mallory would gain 76 happiness units by sitting next to Bob. +Mallory would lose 34 happiness units by sitting next to Carol. +Mallory would gain 37 happiness units by sitting next to David. +Mallory would gain 40 happiness units by sitting next to Eric. +Mallory would gain 18 happiness units by sitting next to Frank. +Mallory would gain 7 happiness units by sitting next to George.