From 8064b4dc4bd36f0feced76a7f8e19892d0a86d41 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Tue, 20 Dec 2016 20:58:39 -0500 Subject: Day 20 --- src/bin/day20.rs | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/bin/day20.rs (limited to 'src') diff --git a/src/bin/day20.rs b/src/bin/day20.rs new file mode 100644 index 0000000..3ed55af --- /dev/null +++ b/src/bin/day20.rs @@ -0,0 +1,42 @@ +use std::io::{self, Read}; + +fn solve(input: &str) -> u32 { + let mut ranges = vec![]; + + for line in input.lines() { + let hyphen = line.find('-').unwrap(); + let (start, end) = line.split_at(hyphen); + let start: u32 = start.parse().unwrap(); + let end: u32 = end[1..].parse().unwrap(); + ranges.push((start, end)); + } + + ranges.sort(); + + let mut lowest = 0; + + for &(start, end) in &ranges { + if lowest >= start && lowest <= end { + lowest = end + 1; + } + } + + lowest +} + +fn main() { + let mut input = String::new(); + io::stdin().read_to_string(&mut input).unwrap(); + + println!("Part 1: {}", solve(&input)); +} + +#[test] +fn part1() { + let input = " +5-8 +0-2 +4-7 +"; + assert_eq!(3, solve(input.trim())); +} -- cgit 1.4.1 href='/libretls/tree/compat/getentropy_freebsd.c?h=3.3.3p1&id=cc13f4d43a9e6f8544f347800adbbe5000b83305'>tree commit diff
path: root/compat/getentropy_freebsd.c (unfollow)
Commit message (Expand)Author
2020-08-03doc: Indicate that only OpenSSL 1.1.1b and newer workJune McEnroe