Late start, but day 6 was suprisingly easy.
This commit is contained in:
parent
5030dfa2a4
commit
fb12dc3954
|
@ -0,0 +1 @@
|
||||||
|
bhzhtzzsczszsjjjzddfzdfzfjfzfbbnntnzznwzzvfvrrqmrmmdzzfqfhqhsqqpwpgwpppbtbnnstthmhrrsmmvsmmhjmjfmfsfjfnfnjjvcjjszjszjsszbznzbnzndzzmlldsdgdcddmqmfqqlcllbvllztzctzczdzttlmtlthtmhtmhmmszsllvzvdzzzsqzqbqccvfvcffzsfslfsllcglclwlvwvzzdsslggtzzgzdzmzddjljvvztttsgscsstztjztjztzvzwwthtftppnmpmmcpmmjlmjjjsfjsjppgcgwcggzffzwzbbmbrbprpqqpccfncfnffvcffsqqtzqzqwzwvzwwwbjbfbcbfblltnlnhhcthtvvzzfcfgfddlggbbshsggplglqqbrbggsvvzdvvlfvlvpvhhmggbrrnppjfjhffttfpffbdfbfvfqvvtcvvbvnnhbhhglgjgzzghhwrrtntrtwwfdfdmmcmtctftpptllzqllzflfrrgqgvgdvdfdbddprrrgccqvqnnmtmvmffpzzqggfbfnfwwqdqldqqlnqnttnbttrffnmmzwzjjtrjtrtmmqsmqmffqmfqfhhbthbhdhvdhvdvmvdmdhdshsqslldzztvvmzzdcccmbbhfhshrrrpsrrqqmdmmgdmmwdmdjdqqmcmttpgtgwgpwpprbrprhrsrllhsllprlplhppfzpffbhbccwdwbbrpbpvpqqmsspjssmbbmfmrmnrnwwgbwwbpwpjwwhqqgcqcvqccgffzpfftcffqlqjjznnlflhhlcczhzvhzhmzhmhfhnnqznntstwtggqjgjhggsvslltjlttfjjgffjzjwzzqzrrhlhzhbhphmhlmlzmzsmzmccvllgrrpbrbfbjfjttqjttdrdhhggqgddppqgpqgpgtptjptpllwccmwcmcpmcppdrrtstqqczqzvvlsltlddnvdvggcqqblqqsjqjttzhtzzszllqsqfqddqdbqddwqddfzzlczcscfsfpfdpdrpddsggcqchcfcpcssstwstwtggghvhqhzzqssjddwjwbjjsnjnfnwwglwwfnfhnnscsggzgjzzhzmmqfqsqwqrwqqqdtdcttzvvnbngbbcdbdggddnmddgzghhzgghwwbjbttlwlcctlccwwdhhrqrvrjjlglssgttpllwclwwtptwptwtvthtbhbzhbzhhrsrwwwnrwrfwfnwnhhnqqdjqjpqqwdwttzhttcdttvztzltzlzmzddrsdsfdsfftdfffmwffrjrffqrfqfsfqqqgqjggwzzrnnqfnqffdbfbtbbrpbrpbptpwttjmjjzrrhhqppdzdtdjttqwwtddjdzzmgzzhwwwdsdgssprsrgsgbbphhdpdwppnfppdqqwzzpbzzqwqpqsqhqdhqqtwwjnnmvmwvmmwwgjgzjjvcjcvcjcnjcncmmphmmvmwmwpwbbtbffhnhshgssgvgvrrbwbtbddqmqfqvvfqvqdvvdbvdbdcdfdlflmffrwwgmmttrztrrfrqrpqrrzjrjpjdpjprrnhhbhcbbcwwqlwwcssbddfrfjrfjfrjfjvvdmdtdzzlvzlzhzmhmhphchnnfqnffvccfpfbfpfqpprrmttzrzzjzmjmzjmmfvmmrzrqqdllgjlglcchssgllsbllrbrlrjlrrhhfwwsqwsstpssznzcznzqzssvtvtrrqwqvvtssgfsfhssljjnwjnjddjdggclcrrfsfhsstgtdtctfttvvsbvvbtbttcgcssjlslhlpljpppwzwnwdnngmgjjbzznwwdllrrfppshhvdhhldhdbbdbjbdjjrnjjzhzfhhsqqbqgmsbvnjsptlrsszlqfmgprvscphmqztbgtlrqvcgdzcptcqjncrdtfqnghnbmwwmcjgtjlbvqqzslgbbntrdfnvfjvfgcgngndjcspgwmpnsrqzzvzljbzlzzrwflrqqqmhsvqwbmdftnhwwzgqrlhddbbtwvbphljmstcjzvpjqwcnhlvpqvqdgvntgqzqwrlwbwvngwtqgrhznlzcvbwqmwncccjctrdzrmzjsvrmcfpjjcczhbvdfwhqvczggfmrspvprvvthvtqnsphpcsdmbrtbdqljvssdrhwjsrrlzprstpgqcbpmnpdgzgjttwcfrgjnsghmszlclgvmlsjrqfvflbnhwwphtvrnrbhdvdglcvgpzfsjpwwhtlvvdzthsrldfzhnlrblzsjjnwclqsqzgdbflhvpwcrtfbfbjcjttbjpvfgvfcswnqqwshbmqlscdzzwshfqwsvwnwzltbnrmzzhzvtwpzqcgwshpvzgtcmwrtrwctnpzbznnwqphnrgwljtrcwlqmvlndwrdrctztnmswslqmbjcmtlrmcpjvzccqszrnflqnqzttbhqlrhbmqdpscqvfgtdbnwjdcljwcbgbgjfzgrgpwqzqgbnrtpntfthhdbqmswvhnmwmszpghgjjzrbnbbfjblpstdfslmmmqfdcrhblqjqfphnldrvvfpnfrcvprjnqbzbspfpjtgqhnjbhnrwzcjvdbshhqpgrmzqpmjfmqwqvvdbddbsldwzzsrhnhsjjnvljrbwcnjrnjpmrrvfthftgptgtlpbgqffthflgftwcrqcqwqwrmrcmfrcqgmrnqjbscdcgrqlhjzthvzdgjbvpswflqcgsnlmgmvcsttsgmnqdtvwdvrndvfdcvrcwmqlmlhtrvthsndsrmnsfmdmfnpfmfhzjqmtcjzcrnsjdztztvgdtlrmbdmmstbfgpmmzthcslpvgrpgfljfgqlqhldfwvvvdvbzjtdtppbtrnqwsqztjrsjhtfrgmvsdngvsdzjgpwrldqpzdpvhljzpjvttwltdwcrhcbrgrvdrmpwvdwjchqsjfprbgtjtzggvgrgmlvvwqrjfprbbgjjqrtdfnrdffwbswbvqtqtfsrhsgrjhftqldhmcnmsnfflmdrzqdjmbqqgqsttdmtrrvfsjnccnhcpcvqtrzdjzrpwswmjvvgsgwvnmdgqwlctrlhqnsmczbwsjhmtgvdcgsndzlstcwchcztqqbtdwfvlljdvdlzljslgnzpmqvzfcvqhdzvgchffqgfwrnmwqzwgbzblpmvddlvnhglrhdnwzqwztzgjczjpwcjwmpnrnrhncfjfggrbphrjztwtfqmfjlwfhnqfftfghbnvtwgtmdzzrdrtmfrwhrrbhzmcllsgqzwzzqtgdggvzptvtdcpzmtmsfcfbjtzlbdrwhdbtdhhrgggmddnzsvjwgcdcqfppqwphfvlhmgqsznlhmgpnjvcvrwwppnphchgsrhjwjcpjggsrcwrvnllfgrmjltfzwhmbqwpwwzmrtlqcprrqztcgnghcbvzrbfptjmhtdcfhhffdbrswqpnpppnpqwtflrrmqgjzctmmvvvwzllbsfdvpqjtmvpjcpmjztscsgbdznfgcmtjzdqzwqrsvstnnvddcstzqjtnbsnlptpmbmfqmhppgnjrffqrtchgptbmwlwbwbcqqfngpbwtwdmlmdstmqwcwjtbwbbbhghgptmvhfmvqfvpwqzwnbjdhpwlgjgvprdjbnlzhnllssbpvzfzspwsscfpqtpdvtzvqncfrfrgddsdglqvpblmpcczlqfdmwzmgvrljhqtcglcvfhbdwhbttqqrjbqwhsrhrbjwmtqwqddvdggdwfsmnpbpvvgsqnvvrqntwmbzdnqpmmqtbnlsbmslpfmqjtgvbddhwvlvjtlrhqdpfnjwtbhwjwdrpgctbbrdqvbbnvgqwngrhqfvwzmlqtmhfqphnmczlbdpnbmpvwrsjbcnjnvcfgnsvlhpzdgdzgvfbgwdcrswznrggnghzssdwqvvlwftqhbnwdvghhvjlqqmcnqmvbwhrrnsswlwmwbsmpcpdzzgmcmqnzpvjpzqbwcsgdhqtqhcpbtqftvscmntsbdcbrndvlfhprpblzbjcpqhfljtvnvtgvrcgqbsgl
|
|
@ -1,7 +1,11 @@
|
||||||
use crate::utilities::*;
|
use crate::utilities::*;
|
||||||
|
|
||||||
pub fn part1() -> usize {
|
pub fn part1(input: &str) -> usize {
|
||||||
unimplemented!()
|
input
|
||||||
|
.as_bytes()
|
||||||
|
.windows(4)
|
||||||
|
.position(|x| !find_dupes_stupid(x))
|
||||||
|
.unwrap()+4
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -10,6 +14,10 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_part1() {
|
fn test_part1() {
|
||||||
assert_eq!(part1(), 0);
|
assert_eq!(part1("mjqjpqmgbljsphdztnvjfqwrcgsmlb"), 7);
|
||||||
|
assert_eq!(part1("bvwbjplbgvbhsrlpgdmjqwftvncz"), 5);
|
||||||
|
assert_eq!(part1("nppdvjthqldpwncqszvftbrmjlhg"), 6);
|
||||||
|
assert_eq!(part1("nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg"), 10);
|
||||||
|
assert_eq!(part1("zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw"), 11);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
use crate::utilities::*;
|
use crate::utilities::*;
|
||||||
|
|
||||||
pub fn part2() -> usize {
|
pub fn part2(input: &str) -> usize {
|
||||||
unimplemented!()
|
input
|
||||||
|
.as_bytes()
|
||||||
|
.windows(14)
|
||||||
|
.position(|x| !find_dupes_stupid(x))
|
||||||
|
.unwrap()+14
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -10,6 +14,10 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_part2() {
|
fn test_part2() {
|
||||||
assert_eq!(part2(), 0);
|
assert_eq!(part2("mjqjpqmgbljsphdztnvjfqwrcgsmlb"), 19);
|
||||||
|
assert_eq!(part2("bvwbjplbgvbhsrlpgdmjqwftvncz"), 23);
|
||||||
|
assert_eq!(part2("nppdvjthqldpwncqszvftbrmjlhg"), 23);
|
||||||
|
assert_eq!(part2("nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg"), 29);
|
||||||
|
assert_eq!(part2("zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw"), 26);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,11 @@ mod utilities;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let _input = include_str!("./input.txt");
|
let _input = include_str!("./input.txt");
|
||||||
let _structured_input = utilities::parse(_input);
|
// let _structured_input = utilities::parse(_input);
|
||||||
|
|
||||||
println!("Part One");
|
println!("Part One");
|
||||||
println!("Result: {}", part1::part1());
|
println!("Result: {}", part1::part1(_input));
|
||||||
|
|
||||||
println!("Part Two");
|
println!("Part Two");
|
||||||
println!("Result: {}", part2::part2());
|
println!("Result: {}", part2::part2(_input));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,14 @@
|
||||||
pub fn parse(input: &str) -> usize {
|
/* pub fn parse(input: &str) -> usize {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
|
} */
|
||||||
|
|
||||||
|
pub fn find_dupes_stupid<T: PartialEq>(slice: &[T]) -> bool {
|
||||||
|
for i in 1..slice.len() {
|
||||||
|
if slice[i..].contains(&slice[i - 1]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -8,9 +17,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse() {
|
fn test_parse() {
|
||||||
let input =
|
let input = "test";
|
||||||
"test"
|
|
||||||
;
|
|
||||||
assert_eq!(parse(input), 0);
|
assert_eq!(parse(input), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
0
src/day07/input.txt
Normal file
0
src/day07/input.txt
Normal file
15
src/day07/part1.rs
Normal file
15
src/day07/part1.rs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
use crate::utilities::*;
|
||||||
|
|
||||||
|
pub fn part1() -> usize {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_part1() {
|
||||||
|
assert_eq!(part1(), 0);
|
||||||
|
}
|
||||||
|
}
|
15
src/day07/part2.rs
Normal file
15
src/day07/part2.rs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
use crate::utilities::*;
|
||||||
|
|
||||||
|
pub fn part2() -> usize {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_part2() {
|
||||||
|
assert_eq!(part2(), 0);
|
||||||
|
}
|
||||||
|
}
|
14
src/day07/solve.rs
Normal file
14
src/day07/solve.rs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
mod part1;
|
||||||
|
mod part2;
|
||||||
|
mod utilities;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let _input = include_str!("./input.txt");
|
||||||
|
let _structured_input = utilities::parse(_input);
|
||||||
|
|
||||||
|
println!("Part One");
|
||||||
|
println!("Result: {}", part1::part1());
|
||||||
|
|
||||||
|
println!("Part Two");
|
||||||
|
println!("Result: {}", part2::part2());
|
||||||
|
}
|
16
src/day07/utilities.rs
Normal file
16
src/day07/utilities.rs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
pub fn parse(input: &str) -> usize {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_parse() {
|
||||||
|
let input =
|
||||||
|
"test"
|
||||||
|
;
|
||||||
|
assert_eq!(parse(input), 0);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue