summary refs log tree commit diff homepage
path: root/2017/src/bin/day04.rs
blob: 2d6ca52b151d371a0445f74edcaf533a17abb578 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use std::collections::HashSet;
use std::io::{self, Read};

fn solve1(input: &str) -> u32 {
    let mut valid = 0;
    for phrase in input.lines() {
        let words = phrase.split_whitespace();
        if words.clone().count() == words.collect::<HashSet<&str>>().len() {
            valid += 1;
        }
    }
    valid
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();

    println!("Part 1: {}", solve1(&input));
}

#[test]
fn part1() {
    assert_eq!(1, solve1("aa bb cc dd ee"));
    assert_eq!(0, solve1("aa bb cc dd aa"));
    assert_eq!(1, solve1("aa bb cc dd aaa"));
}
an title='2021-01-12 20:58:51 -0500'>2021-01-12Render tag index in HTMLJune McEnroe 2021-01-12Add htagml -xJune McEnroe 2021-01-12Prevent matching the same tag twiceJune McEnroe 2021-01-12Process htagml file line by lineJune McEnroe 2021-01-12Split fields by tab onlyJune McEnroe 2021-01-12List both Makefile and html.sh under README.7June McEnroe 2021-01-12Add htagml exampleJune McEnroe 2021-01-12Use mandoc and htagml for bin htmlJune McEnroe 2021-01-12Add htagmlJune McEnroe 2021-01-12Replace causal.agency with a simple mdoc pageJune McEnroe 2021-01-11Publish "Using vi"June McEnroe 2021-01-11Enable diff.colorMovedJune McEnroe 2021-01-10Set less search case-insensitiveJune McEnroe 2021-01-10Set EXINITJune McEnroe 2021-01-09Add c -t flag to print expression typeJune McEnroe 2021-01-05Update taglineJune McEnroe