From 6fc08571bf3a4004c366df24481db43209563f4f Mon Sep 17 00:00:00 2001 From: logaritmisk Date: Tue, 5 Dec 2017 08:01:57 +0100 Subject: [PATCH] 2015/08-10, 2015/12-13, started on 2015/14 --- 2015/08/Cargo.lock | 2 +- 2015/08/src/main.rs | 97 +++++++---- 2015/09/Cargo.lock | 102 +++++------- 2015/09/Cargo.toml | 4 +- 2015/09/src/main.rs | 163 ++++++++++-------- 2015/10/Cargo.lock | 4 + 2015/10/Cargo.toml | 6 + 2015/10/input.txt | 1 + 2015/10/src/main.rs | 100 +++++++++++ 2015/12/Cargo.lock | 4 + 2015/12/Cargo.toml | 6 + 2015/12/input.txt | 1 + 2015/12/src/main.rs | 397 ++++++++++++++++++++++++++++++++++++++++++++ 2015/13/Cargo.lock | 4 + 2015/13/Cargo.toml | 6 + 2015/13/example.txt | 12 ++ 2015/13/input.txt | 56 +++++++ 2015/13/src/main.rs | 254 ++++++++++++++++++++++++++++ 2015/14/Cargo.toml | 6 + 2015/14/src/main.rs | 3 + 20 files changed, 1072 insertions(+), 156 deletions(-) create mode 100644 2015/10/Cargo.lock create mode 100644 2015/10/Cargo.toml create mode 100644 2015/10/input.txt create mode 100644 2015/10/src/main.rs create mode 100644 2015/12/Cargo.lock create mode 100644 2015/12/Cargo.toml create mode 100644 2015/12/input.txt create mode 100644 2015/12/src/main.rs create mode 100644 2015/13/Cargo.lock create mode 100644 2015/13/Cargo.toml create mode 100644 2015/13/example.txt create mode 100644 2015/13/input.txt create mode 100644 2015/13/src/main.rs create mode 100644 2015/14/Cargo.toml create mode 100644 2015/14/src/main.rs diff --git a/2015/08/Cargo.lock b/2015/08/Cargo.lock index fddcfe8..22f4fe8 100644 --- a/2015/08/Cargo.lock +++ b/2015/08/Cargo.lock @@ -1,4 +1,4 @@ -[root] +[[package]] name = "08" version = "0.1.0" diff --git a/2015/08/src/main.rs b/2015/08/src/main.rs index 829cd00..9d1a274 100644 --- a/2015/08/src/main.rs +++ b/2015/08/src/main.rs @@ -6,20 +6,22 @@ use std::str; enum StateMachine { Normal, Escape, - Hexadecimal(u8) + Hexadecimal(u8), +} + +fn code_length(input: &str) -> usize { + input.len() } fn memory_length(input: &str) -> usize { - let mut count: usize = 0; + let mut count = 0; let mut state = StateMachine::Normal; for c in input.chars() { state = match (c, state) { // Normal. - ('\\', StateMachine::Normal) => { - StateMachine::Escape - } + ('\\', StateMachine::Normal) => StateMachine::Escape, (_, s @ StateMachine::Normal) => { count += 1; @@ -27,9 +29,7 @@ fn memory_length(input: &str) -> usize { } // Escape. - ('x', StateMachine::Escape) => { - StateMachine::Hexadecimal(1) - } + ('x', StateMachine::Escape) => StateMachine::Hexadecimal(1), (_, StateMachine::Escape) => { count += 1; @@ -37,52 +37,57 @@ fn memory_length(input: &str) -> usize { } // Hexadecimal. - (_, StateMachine::Hexadecimal(mut hex)) => { - if hex == 2 { - count += 1; + (_, StateMachine::Hexadecimal(mut hex)) => if hex == 2 { + count += 1; - StateMachine::Normal - } else { - hex += 1; + StateMachine::Normal + } else { + hex += 1; - StateMachine::Hexadecimal(hex) - } - } + StateMachine::Hexadecimal(hex) + }, }; - - // println!("{} - {} => {:?}", count, c, state); } count - 2 } -fn code_length(input: &str) -> usize { - input.len() +fn string_length(input: &str) -> usize { + let mut count = 0; + + for c in input.chars() { + count += match c { + '"' => 2, + '\\' => 2, + _ => 1, + }; + } + + count + 2 + } fn main() { let stdin = io::stdin(); - let lines = stdin.lock().lines() + let lines = stdin + .lock() + .lines() .filter_map(|line| line.ok()) .collect::>(); - let count_1: usize = lines.iter() - .map(|line| code_length(&line)) - .sum(); + let code: usize = lines.iter().map(|line| code_length(line)).sum(); + let memory: usize = lines.iter().map(|line| memory_length(line)).sum(); + let string: usize = lines.iter().map(|line| string_length(line)).sum(); - let count_2: usize = lines.iter() - .map(|line| memory_length(&line)) - .sum(); - - println!("count_1={}", count_1); - println!("count_2={}", count_1 - count_2); + println!("part_one={}", code - memory); + println!("part_two={}", string - code); } #[cfg(test)] mod tests { - use super::{code_length, memory_length}; + use super::*; #[test] fn example_01() { @@ -115,4 +120,32 @@ mod tests { assert_eq!(6, code_length(line)); assert_eq!(1, memory_length(line)); } + + #[test] + fn example_05() { + let line = r#""""#; + + assert_eq!(6, string_length(line)); + } + + #[test] + fn example_06() { + let line = r#""abc""#; + + assert_eq!(9, string_length(line)); + } + + #[test] + fn example_07() { + let line = r#""aaa\"aaa""#; + + assert_eq!(16, string_length(line)); + } + + #[test] + fn example_08() { + let line = r#""\x27""#; + + assert_eq!(11, string_length(line)); + } } diff --git a/2015/09/Cargo.lock b/2015/09/Cargo.lock index b35a4dc..29acb54 100644 --- a/2015/09/Cargo.lock +++ b/2015/09/Cargo.lock @@ -1,105 +1,95 @@ -[root] +[[package]] name = "09" version = "0.1.0" dependencies = [ - "lazy_static 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "aho-corasick" -version = "0.5.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "lazy_static" -version = "0.1.16" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "lazy_static" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.18" +version = "0.2.34" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "memchr" -version = "0.1.11" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex" -version = "0.1.80" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex-syntax" -version = "0.3.9" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "thread-id" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "thread_local" -version = "0.2.7" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "unreachable" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "utf8-ranges" -version = "0.1.3" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi-build" -version = "0.1.1" +name = "void" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] -"checksum aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66" -"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum lazy_static 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "cf186d1a8aa5f5bee5fd662bc9c1b949e0259e1bcc379d1f006847b0080c7417" -"checksum libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "a51822fc847e7a8101514d1d44e354ba2ffa7d4c194dcab48870740e327cac70" -"checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20" -"checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f" -"checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" -"checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03" -"checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5" -"checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f" -"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" -"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" +"checksum aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d6531d44de723825aa81398a6415283229725a00fa30713812ab9323faa82fc4" +"checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" +"checksum lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8f31047daa365f19be14b47c29df4f7c3b581832407daabe6ae77397619237d" +"checksum libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)" = "36fbc8a8929c632868295d0178dd8f63fc423fd7537ad0738372bd010b3ac9b0" +"checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d" +"checksum regex 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ac6ab4e9218ade5b423358bbd2567d1617418403c7a512603630181813316322" +"checksum regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad890a5eef7953f55427c50575c680c42841653abd2b028b68cd223d157f62db" +"checksum thread_local 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1697c4b57aeeb7a536b647165a2825faddffb1d3bad386d507709bd51a90bb14" +"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" +"checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" +"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" diff --git a/2015/09/Cargo.toml b/2015/09/Cargo.toml index f676056..36ef547 100644 --- a/2015/09/Cargo.toml +++ b/2015/09/Cargo.toml @@ -4,5 +4,5 @@ version = "0.1.0" authors = ["logaritmisk "] [dependencies] -lazy_static = "0.1" -regex = "0.1" +lazy_static = "1.0" +regex = "0.2" diff --git a/2015/09/src/main.rs b/2015/09/src/main.rs index 4996721..93062d5 100644 --- a/2015/09/src/main.rs +++ b/2015/09/src/main.rs @@ -1,7 +1,10 @@ -#[macro_use] extern crate lazy_static; +#[macro_use] +extern crate lazy_static; extern crate regex; + use std::io::{self, Read}; +use std::iter::Iterator; use std::collections::BTreeMap; use regex::Regex; @@ -10,23 +13,61 @@ use regex::Regex; type Map<'a> = BTreeMap<&'a str, BTreeMap<&'a str, i64>>; -#[derive(Clone, Debug)] -struct Route<'a> { - vec: Vec<&'a str>, - distance: i64 +struct Permutations<'a, T: 'a> { + source: &'a [T], + iter: Vec, + done: bool, } -impl<'a> Route<'a> { - fn new() -> Route<'a> { - Route { - vec: Vec::new(), - distance: 0 +impl<'a, T> Permutations<'a, T> { + fn new(source: &'a [T]) -> Permutations { + Permutations { + source: source, + iter: vec![0; source.len()], + done: false, + } + } +} + +impl<'a, T> Iterator for Permutations<'a, T> +where + T: Clone, +{ + type Item = Vec; + + fn next(&mut self) -> Option { + if self.done { + None + } else { + let values = self.iter + .iter() + .map(|index| self.source[*index].clone()) + .collect::>(); + + let max = self.source.len() - 1; + + self.done = true; + + for i in self.iter.iter_mut().rev() { + if *i == max { + *i = 0; + + continue; + } + + *i += 1; + self.done = false; + + break; + } + + Some(values) } } } -fn process<'a>(input: &'a str) -> Route<'a> { +fn parse(input: &str) -> Map { lazy_static! { static ref RE: Regex = Regex::new(r"^([a-zA-Z]+) to ([a-zA-Z]+) = (\d+)$").unwrap(); } @@ -34,67 +75,49 @@ fn process<'a>(input: &'a str) -> Route<'a> { let mut map: Map = BTreeMap::new(); for line in input.lines() { - let caps = RE.captures(&line).unwrap(); + let caps = RE.captures(line).unwrap(); - let a = caps.at(1).unwrap(); - let b = caps.at(2).unwrap(); + let a = caps.get(1).unwrap().as_str(); + let b = caps.get(2).unwrap().as_str(); - let distance = caps.at(3).unwrap().parse::().unwrap(); + let distance = caps[3].parse::().unwrap(); - map.entry(a).or_insert(BTreeMap::new()).insert(b, distance); - map.entry(b).or_insert(BTreeMap::new()).insert(a, distance); + map.entry(a) + .or_insert_with(BTreeMap::new) + .insert(b, distance); + + map.entry(b) + .or_insert_with(BTreeMap::new) + .insert(a, distance); } - let mut routes = iterate(&map, None); - - routes.sort_by_key(|x| x.distance); - - routes.remove(0) + map } -fn iterate<'a>(map: &Map<'a>, route: Option>) -> Vec> { - let mut routes = Vec::new(); +fn routes<'a>(map: &'a Map<'a>) -> Vec<(Vec<&'a str>, i64)> { + let cities = map.keys().map(|city| *city).collect::>(); - if let Some(mut route) = route { - let prev = *route.vec.last().unwrap(); + Permutations::new(&cities) + .filter(|route| { + let mut iter = route.iter(); - let mut end = true; - - for (city, distance) in map.get(prev).unwrap().iter() { - if route.vec.contains(city) { - continue; + while let Some(needle) = iter.next() { + if iter.clone().any(|haystack| haystack == needle) { + return false; + } } - route.vec.push(*city); - route.distance += *distance; + true + }) + .map(|route| { + let distance = route + .windows(2) + .map(|cities| map[cities[0]][cities[1]]) + .sum(); - { - let mut sub_routes = iterate(&map, Some(route.clone())); - - routes.append(&mut sub_routes); - } - - end = false; - } - - if end { - routes.push(route); - } - } else { - for city in map.keys() { - let mut route = Route::new(); - - route.vec.push(*city); - - { - let mut sub_routes = iterate(&map, Some(route)); - - routes.append(&mut sub_routes); - } - } - } - - routes + (route, distance) + }) + .collect::>() } fn main() { @@ -102,15 +125,20 @@ fn main() { io::stdin().read_to_string(&mut input).unwrap(); - let result = process(&input); + let map = parse(&input); + let mut routes = routes(&map); - println!("{:?}", result); + routes.sort_by_key(|&(_, distance)| distance); + + + println!("shortest={:?}", routes.first().unwrap()); + println!("longest={:?}", routes.last().unwrap()); } #[cfg(test)] mod tests { - use super::process; + use super::*; #[test] fn example_01() { @@ -118,8 +146,13 @@ mod tests { London to Belfast = 518\n\ Dublin to Belfast = 141"; - let result = process(input); + let map = parse(input); + let mut routes = routes(&map); - assert_eq!(605, result.distance); + routes.sort_by_key(|&(_, distance)| distance); + + println!("{:#?}", routes); + + assert_eq!(605, routes[0].1); } } diff --git a/2015/10/Cargo.lock b/2015/10/Cargo.lock new file mode 100644 index 0000000..2877b39 --- /dev/null +++ b/2015/10/Cargo.lock @@ -0,0 +1,4 @@ +[[package]] +name = "day-10" +version = "0.1.0" + diff --git a/2015/10/Cargo.toml b/2015/10/Cargo.toml new file mode 100644 index 0000000..9f52cb9 --- /dev/null +++ b/2015/10/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "day-10" +version = "0.1.0" +authors = ["logaritmisk "] + +[dependencies] diff --git a/2015/10/input.txt b/2015/10/input.txt new file mode 100644 index 0000000..e7dcbbd --- /dev/null +++ b/2015/10/input.txt @@ -0,0 +1 @@ +1113122113 diff --git a/2015/10/src/main.rs b/2015/10/src/main.rs new file mode 100644 index 0000000..01a4850 --- /dev/null +++ b/2015/10/src/main.rs @@ -0,0 +1,100 @@ +use std::io::{self, Read}; +use std::iter::Iterator; + + +#[derive(Debug, PartialEq, Clone, Copy)] +enum Digit { + One, + Two, + Three, +} + + +struct LookAndSay { + values: Vec, +} + +impl LookAndSay { + fn from_string(input: &str) -> Self { + let values = input + .chars() + .map(|c| match c { + '1' => Digit::One, + '2' => Digit::Two, + '3' => Digit::Three, + _ => panic!("invalid input"), + }) + .collect::>(); + + LookAndSay { values: values } + } +} + +impl Iterator for LookAndSay { + type Item = Vec; + + fn next(&mut self) -> Option { + let mut values = Vec::new(); + + let mut state = self.values[0]; + let mut count = 0; + + for value in &self.values { + if *value == state { + count += 1; + } else { + values.push(match count { + 1 => Digit::One, + 2 => Digit::Two, + 3 => Digit::Three, + _ => unreachable!(), + }); + + values.push(state); + + state = *value; + count = 1; + } + } + + values.push(match count { + 1 => Digit::One, + 2 => Digit::Two, + 3 => Digit::Three, + _ => unreachable!(), + }); + + values.push(state); + + self.values = values.clone(); + + Some(values) + } +} + + +fn main() { + let mut input = String::new(); + + io::stdin() + .read_to_string(&mut input) + .expect("faild to read input"); + + for line in input + .lines() + .map(|line| line.trim()) + .filter(|line| !line.is_empty()) + { + let mut look_and_say = LookAndSay::from_string(line); + + // Skip 39 iterations to get number 40. + if let Some(value) = look_and_say.nth(39) { + println!("part_one={}", value.len()); + } + + // Skip 9 more iterations to get number 50. + if let Some(value) = look_and_say.nth(9) { + println!("part_two={}", value.len()); + } + } +} diff --git a/2015/12/Cargo.lock b/2015/12/Cargo.lock new file mode 100644 index 0000000..cdc119d --- /dev/null +++ b/2015/12/Cargo.lock @@ -0,0 +1,4 @@ +[[package]] +name = "day-12" +version = "0.1.0" + diff --git a/2015/12/Cargo.toml b/2015/12/Cargo.toml new file mode 100644 index 0000000..b2a2afe --- /dev/null +++ b/2015/12/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "day-12" +version = "0.1.0" +authors = ["logaritmisk "] + +[dependencies] diff --git a/2015/12/input.txt b/2015/12/input.txt new file mode 100644 index 0000000..bd91fda --- /dev/null +++ b/2015/12/input.txt @@ -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/2015/12/src/main.rs b/2015/12/src/main.rs new file mode 100644 index 0000000..16d5bac --- /dev/null +++ b/2015/12/src/main.rs @@ -0,0 +1,397 @@ +use std::io::{self, Read}; +use std::iter::Iterator; +use std::borrow::Cow; + + +#[derive(Clone, PartialEq, Debug)] +enum Token<'a> { + ObjectStart, + ObjectEnd, + ArrayStart, + ArrayEnd, + Number(i64), + String(Cow<'a, str>), +} + + +#[derive(Clone, PartialEq, Debug)] +enum State { + Unknown, + InObject, + InArray, + Number(usize), + String(usize), +} + + +struct Parser<'a> { + state: Vec, + input: &'a str, + index: usize, +} + +impl<'a> Parser<'a> { + fn new(input: &'a str) -> Self { + Parser { + state: Vec::new(), + input: input, + index: 0, + } + } +} + +impl<'a> Iterator for Parser<'a> { + type Item = Token<'a>; + + fn next(&mut self) -> Option> { + if self.index >= self.input.len() { + return None; + } + + let mut iter = self.input.chars().skip(self.index); + + let mut next = iter.next(); + + while let Some(ch) = next { + let state = self.state.last().unwrap_or(&State::Unknown).clone(); + + match (state, ch) { + // Unknown. + (State::Unknown, '-') => { + self.state.push(State::Number(self.index)); + + self.index += 1; + next = iter.next(); + } + (State::Unknown, '0'...'9') => { + self.state.push(State::Number(self.index)); + + self.index += 1; + next = iter.next(); + } + (State::Unknown, '"') => { + self.state.push(State::String(self.index + 1)); + + self.index += 1; + next = iter.next(); + } + (State::Unknown, '{') => { + self.state.push(State::InObject); + + self.index += 1; + + return Some(Token::ObjectStart); + } + (State::Unknown, '[') => { + self.state.push(State::InArray); + + self.index += 1; + + return Some(Token::ArrayStart); + } + + // Number. + (State::Number(_), '0'...'9') => { + self.index += 1; + next = iter.next(); + } + (State::Number(start), _) => { + self.state.pop(); + + return Some(Token::Number( + self.input[start..self.index].parse::().unwrap(), + )); + } + + // String. + (State::String(start), '"') => { + self.state.pop(); + + self.index += 1; + + return Some(Token::String(self.input[start..self.index - 1].into())); + } + (State::String(_), _) => { + self.index += 1; + next = iter.next(); + } + + // Object. + (State::InObject, '"') => { + self.state.push(State::String(self.index + 1)); + + self.index += 1; + next = iter.next(); + } + (State::InObject, '-') => { + self.state.push(State::Number(self.index)); + + self.index += 1; + next = iter.next(); + } + (State::InObject, '0'...'9') => { + self.state.push(State::Number(self.index)); + + self.index += 1; + next = iter.next(); + } + (State::InObject, '{') => { + self.state.push(State::InObject); + + self.index += 1; + + return Some(Token::ObjectStart); + } + (State::InObject, '[') => { + self.state.push(State::InArray); + + self.index += 1; + + return Some(Token::ArrayStart); + } + (State::InObject, '}') => { + self.state.pop(); + + self.index += 1; + + return Some(Token::ObjectEnd); + } + + // Array. + (State::InArray, '"') => { + self.state.push(State::String(self.index + 1)); + + self.index += 1; + next = iter.next(); + } + (State::InArray, '-') => { + self.state.push(State::Number(self.index)); + + self.index += 1; + next = iter.next(); + } + (State::InArray, '0'...'9') => { + self.state.push(State::Number(self.index)); + + self.index += 1; + next = iter.next(); + } + (State::InArray, '{') => { + self.state.push(State::InObject); + + self.index += 1; + + return Some(Token::ObjectStart); + } + (State::InArray, '[') => { + self.state.push(State::InArray); + + self.index += 1; + + return Some(Token::ArrayStart); + } + (State::InArray, ']') => { + self.state.pop(); + + self.index += 1; + + return Some(Token::ArrayEnd); + } + + // Everything else. + (_, _) => { + self.index += 1; + next = iter.next(); + } + } + } + + None + } +} + + +#[derive(Debug)] +struct Stack { + sum: i64, + in_object: bool, + expect_key: bool, + discard: bool, +} + + +fn main() { + let mut input = String::new(); + + io::stdin() + .read_to_string(&mut input) + .expect("faild to read input"); + + let mut total = 0; + let mut stack = Vec::new(); + + stack.push(Stack { + sum: 0, + in_object: false, + expect_key: false, + discard: false, + }); + + for line in input.lines() { + for value in Parser::new(line) { + match value { + Token::String(ref string) => { + let this = stack.last_mut().unwrap(); + + if this.in_object { + if this.expect_key { + this.expect_key = false; + } else if string == "red" { + this.expect_key = true; + this.discard = true; + } + } + } + Token::Number(number) => { + let this = stack.last_mut().unwrap(); + + if this.in_object { + this.expect_key = true; + } + + this.sum += number; + } + Token::ObjectStart => { + stack.push(Stack { + sum: 0, + in_object: true, + expect_key: true, + discard: false, + }); + } + Token::ObjectEnd => { + let this = stack.pop().unwrap(); + + if !this.discard { + let entry = stack.last_mut().unwrap(); + + entry.sum += this.sum; + } + } + Token::ArrayStart => { + stack.push(Stack { + sum: 0, + in_object: false, + expect_key: false, + discard: false, + }); + } + Token::ArrayEnd => { + let that = stack.pop().unwrap(); + let this = stack.last_mut().unwrap(); + + this.sum += that.sum; + + if this.in_object { + this.expect_key = true; + } + } + } + } + + let this = stack.last_mut().unwrap(); + + total += this.sum; + } + + println!("total={}", total); +} + + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn example_01() { + let mut parser = Parser::new(r#"[1,2,3]"#); + + assert_eq!(parser.next(), Some(Token::ArrayStart)); + assert_eq!(parser.next(), Some(Token::Number(1))); + assert_eq!(parser.next(), Some(Token::Number(2))); + assert_eq!(parser.next(), Some(Token::Number(3))); + assert_eq!(parser.next(), Some(Token::ArrayEnd)); + assert_eq!(parser.next(), None); + } + + #[test] + fn example_02() { + let mut parser = Parser::new(r#"{"a":2,"b":4}"#); + + assert_eq!(parser.next(), Some(Token::ObjectStart)); + assert_eq!(parser.next(), Some(Token::String("a".into()))); + assert_eq!(parser.next(), Some(Token::Number(2))); + assert_eq!(parser.next(), Some(Token::String("b".into()))); + assert_eq!(parser.next(), Some(Token::Number(4))); + assert_eq!(parser.next(), Some(Token::ObjectEnd)); + assert_eq!(parser.next(), None); + } + + #[test] + fn example_03() { + let mut parser = Parser::new(r#"[[[3]]]"#); + + assert_eq!(parser.next(), Some(Token::ArrayStart)); + assert_eq!(parser.next(), Some(Token::ArrayStart)); + assert_eq!(parser.next(), Some(Token::ArrayStart)); + assert_eq!(parser.next(), Some(Token::Number(3))); + assert_eq!(parser.next(), Some(Token::ArrayEnd)); + assert_eq!(parser.next(), Some(Token::ArrayEnd)); + assert_eq!(parser.next(), Some(Token::ArrayEnd)); + assert_eq!(parser.next(), None); + } + + #[test] + fn example_04() { + let mut parser = Parser::new(r#"{"a":{"b":4},"c":-1}"#); + + assert_eq!(parser.next(), Some(Token::ObjectStart)); + assert_eq!(parser.next(), Some(Token::String("a".into()))); + assert_eq!(parser.next(), Some(Token::ObjectStart)); + assert_eq!(parser.next(), Some(Token::String("b".into()))); + assert_eq!(parser.next(), Some(Token::Number(4))); + assert_eq!(parser.next(), Some(Token::ObjectEnd)); + assert_eq!(parser.next(), Some(Token::String("c".into()))); + assert_eq!(parser.next(), Some(Token::Number(-1))); + assert_eq!(parser.next(), Some(Token::ObjectEnd)); + assert_eq!(parser.next(), None); + } + + #[test] + fn example_05() { + let mut parser = Parser::new(r#"{"a":[-1,1]}"#); + + assert_eq!(parser.next(), Some(Token::ObjectStart)); + assert_eq!(parser.next(), Some(Token::String("a".into()))); + assert_eq!(parser.next(), Some(Token::ArrayStart)); + assert_eq!(parser.next(), Some(Token::Number(-1))); + assert_eq!(parser.next(), Some(Token::Number(1))); + assert_eq!(parser.next(), Some(Token::ArrayEnd)); + assert_eq!(parser.next(), Some(Token::ObjectEnd)); + assert_eq!(parser.next(), None); + } + + #[test] + fn example_06() { + let mut parser = Parser::new(r#"[-1,{"a":1}]"#); + + assert_eq!(parser.next(), Some(Token::ArrayStart)); + assert_eq!(parser.next(), Some(Token::Number(-1))); + assert_eq!(parser.next(), Some(Token::ObjectStart)); + assert_eq!(parser.next(), Some(Token::String("a".into()))); + assert_eq!(parser.next(), Some(Token::Number(1))); + assert_eq!(parser.next(), Some(Token::ObjectEnd)); + assert_eq!(parser.next(), Some(Token::ArrayEnd)); + assert_eq!(parser.next(), None); + } +} diff --git a/2015/13/Cargo.lock b/2015/13/Cargo.lock new file mode 100644 index 0000000..ba26201 --- /dev/null +++ b/2015/13/Cargo.lock @@ -0,0 +1,4 @@ +[[package]] +name = "day-13" +version = "0.1.0" + diff --git a/2015/13/Cargo.toml b/2015/13/Cargo.toml new file mode 100644 index 0000000..e590c6c --- /dev/null +++ b/2015/13/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "day-13" +version = "0.1.0" +authors = ["logaritmisk "] + +[dependencies] diff --git a/2015/13/example.txt b/2015/13/example.txt new file mode 100644 index 0000000..b67c3c6 --- /dev/null +++ b/2015/13/example.txt @@ -0,0 +1,12 @@ +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. diff --git a/2015/13/input.txt b/2015/13/input.txt new file mode 100644 index 0000000..9ddfd38 --- /dev/null +++ b/2015/13/input.txt @@ -0,0 +1,56 @@ +Alice would lose 2 happiness units by sitting next to Bob. +Alice would lose 62 happiness units by sitting next to Carol. +Alice would gain 65 happiness units by sitting next to David. +Alice would gain 21 happiness units by sitting next to Eric. +Alice would lose 81 happiness units by sitting next to Frank. +Alice would lose 4 happiness units by sitting next to George. +Alice would lose 80 happiness units by sitting next to Mallory. +Bob would gain 93 happiness units by sitting next to Alice. +Bob would gain 19 happiness units by sitting next to Carol. +Bob would gain 5 happiness units by sitting next to David. +Bob would gain 49 happiness units by sitting next to Eric. +Bob would gain 68 happiness units by sitting next to Frank. +Bob would gain 23 happiness units by sitting next to George. +Bob would gain 29 happiness units by sitting next to Mallory. +Carol would lose 54 happiness units by sitting next to Alice. +Carol would lose 70 happiness units by sitting next to Bob. +Carol would lose 37 happiness units by sitting next to David. +Carol would lose 46 happiness units by sitting next to Eric. +Carol would gain 33 happiness units by sitting next to Frank. +Carol would lose 35 happiness units by sitting next to George. +Carol would gain 10 happiness units by sitting next to Mallory. +David would gain 43 happiness units by sitting next to Alice. +David would lose 96 happiness units by sitting next to Bob. +David would lose 53 happiness units by sitting next to Carol. +David would lose 30 happiness units by sitting next to Eric. +David would lose 12 happiness units by sitting next to Frank. +David would gain 75 happiness units by sitting next to George. +David would lose 20 happiness units by sitting next to Mallory. +Eric would gain 8 happiness units by sitting next to Alice. +Eric would lose 89 happiness units by sitting next to Bob. +Eric would lose 69 happiness units by sitting next to Carol. +Eric would lose 34 happiness units by sitting next to David. +Eric would gain 95 happiness units by sitting next to Frank. +Eric would gain 34 happiness units by sitting next to George. +Eric would lose 99 happiness units by sitting next to Mallory. +Frank would lose 97 happiness units by sitting next to Alice. +Frank would gain 6 happiness units by sitting next to Bob. +Frank would lose 9 happiness units by sitting next to Carol. +Frank would gain 56 happiness units by sitting next to David. +Frank would lose 17 happiness units by sitting next to Eric. +Frank would gain 18 happiness units by sitting next to George. +Frank would lose 56 happiness units by sitting next to Mallory. +George would gain 45 happiness units by sitting next to Alice. +George would gain 76 happiness units by sitting next to Bob. +George would gain 63 happiness units by sitting next to Carol. +George would gain 54 happiness units by sitting next to David. +George would gain 54 happiness units by sitting next to Eric. +George would gain 30 happiness units by sitting next to Frank. +George would gain 7 happiness units by sitting next to Mallory. +Mallory would gain 31 happiness units by sitting next to Alice. +Mallory would lose 32 happiness units by sitting next to Bob. +Mallory would gain 95 happiness units by sitting next to Carol. +Mallory would gain 91 happiness units by sitting next to David. +Mallory would lose 66 happiness units by sitting next to Eric. +Mallory would lose 75 happiness units by sitting next to Frank. +Mallory would lose 99 happiness units by sitting next to George. diff --git a/2015/13/src/main.rs b/2015/13/src/main.rs new file mode 100644 index 0000000..907adf3 --- /dev/null +++ b/2015/13/src/main.rs @@ -0,0 +1,254 @@ +use std::io::{self, Read}; +use std::iter::Iterator; +use std::collections::HashMap; + + +type Map<'a> = HashMap<&'a str, HashMap<&'a str, i64>>; + + +struct Permutations<'a, T: 'a> { + source: &'a [T], + iter: Vec, + done: bool, +} + +impl<'a, T> Permutations<'a, T> { + fn new(source: &'a [T]) -> Permutations { + Permutations { + source: source, + iter: vec![0; source.len()], + done: false, + } + } +} + +impl<'a, T> Iterator for Permutations<'a, T> +where + T: Clone, +{ + type Item = Vec; + + fn next(&mut self) -> Option { + if self.done { + None + } else { + let values = self.iter + .iter() + .map(|index| self.source[*index].clone()) + .collect::>(); + + let max = self.source.len() - 1; + + self.done = true; + + for i in self.iter.iter_mut().rev() { + if *i == max { + *i = 0; + + continue; + } + + *i += 1; + self.done = false; + + break; + } + + Some(values) + } + } +} + + +#[derive(Clone, Copy)] +enum State { + From, + TriggerTo, + To, + Sign, + Happiness(bool), +} + +fn parse(input: &str) -> (&str, &str, i64) { + let mut state = State::From; + + let mut from = None; + let mut to = None; + let mut happiness = None; + + for token in input.split_whitespace() { + match (state, token) { + (State::From, name) => { + from = Some(name); + + state = State::Sign; + } + + (State::Sign, "gain") => { + state = State::Happiness(true); + } + (State::Sign, "lose") => { + state = State::Happiness(false); + } + + (State::Happiness(sign), value) => { + happiness = Some(value.parse::().unwrap() * if sign { 1 } else { -1 }); + + state = State::TriggerTo; + } + + (State::TriggerTo, "to") => { + state = State::To; + } + + (State::To, name) => { + let len = name.len(); + + to = Some(&name[0..len - 1]); + + break; + } + + (_, _) => (), + } + } + + (from.unwrap(), to.unwrap(), happiness.unwrap()) +} + +fn main() { + let mut input = String::new(); + + io::stdin() + .read_to_string(&mut input) + .expect("failed to read input"); + + let mut map = Map::new(); + + for line in input.lines().filter(|line| !line.is_empty()) { + let (from, to, happines) = parse(line); + + map.entry(from) + .or_insert_with(HashMap::new) + .insert(to, happines); + } + + { + let values = map.keys().collect::>(); + + let mut permutations = Permutations::new(&values) + .filter(|permutation| { + let mut iter = permutation.iter(); + + while let Some(needle) = iter.next() { + if iter.clone().any(|haystack| haystack == needle) { + return false; + } + } + + true + }) + .map(|permutation| { + let mut table = permutation.clone(); + + table.push(permutation.first().unwrap()); + + let happiness: i64 = table + .windows(2) + .map(|people| { + map[people[0]][people[1]] + map[people[1]][people[0]] + }) + .sum(); + + (permutation, happiness) + }) + .collect::>(); + + permutations.sort_by_key(|&(_, happiness)| happiness); + + println!("part_one={:?}", permutations.iter().rev().next().unwrap()); + } + + for other in map.values_mut() { + other.insert("Me", 0); + } + + let others = map.keys().map(|other| *other).collect::>(); + + for other in others { + map.entry("Me") + .or_insert_with(HashMap::new) + .insert(other, 0); + } + + { + let values = map.keys().collect::>(); + + let mut permutations = Permutations::new(&values) + .filter(|permutation| { + let mut iter = permutation.iter(); + + while let Some(needle) = iter.next() { + if iter.clone().any(|haystack| haystack == needle) { + return false; + } + } + + true + }) + .map(|permutation| { + let mut table = permutation.clone(); + + table.push(permutation.first().unwrap()); + + let happiness: i64 = table + .windows(2) + .map(|people| { + map[people[0]][people[1]] + map[people[1]][people[0]] + }) + .sum(); + + (permutation, happiness) + }) + .collect::>(); + + permutations.sort_by_key(|&(_, happiness)| happiness); + + println!("part_two={:?}", permutations.iter().rev().next().unwrap()); + } +} + + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_parse() { + assert_eq!( + parse("Alice would gain 54 happiness units by sitting next to Bob."), + ("Alice", "Bob", 54) + ); + assert_eq!( + parse("Alice would lose 79 happiness units by sitting next to Carol."), + ("Alice", "Carol", -79) + ); + assert_eq!( + parse("Alice would lose 2 happiness units by sitting next to David."), + ("Alice", "David", -2) + ); + + assert_eq!( + parse("Bob would gain 83 happiness units by sitting next to Alice."), + ("Bob", "Alice", 83) + ); + assert_eq!( + parse("Bob would lose 7 happiness units by sitting next to Carol."), + ("Bob", "Carol", -7) + ); + assert_eq!( + parse("Bob would lose 63 happiness units by sitting next to David."), + ("Bob", "David", -63) + ); + } +} diff --git a/2015/14/Cargo.toml b/2015/14/Cargo.toml new file mode 100644 index 0000000..e300071 --- /dev/null +++ b/2015/14/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "day-14" +version = "0.1.0" +authors = ["logaritmisk "] + +[dependencies] diff --git a/2015/14/src/main.rs b/2015/14/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/2015/14/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +}