Rust Implementation of Problem 19

View source code here on GitHub!

Includes

Problem Solution

pub fn problems::p0019::p0019() -> utils::Answer
 1/*
 2Project Euler Problem 19
 3
 4Problem:
 5
 6*/
 7use chrono::DateTime;
 8
 9use crate::include::utils::Answer;
10
11pub fn p0019() -> Answer {
12    let mut answer: u8 = 0;
13    for year in 1901..2001 {
14        for month in 1..13 {
15            let day = DateTime::parse_from_rfc3339(&format!("{}-{:0>2}-01T01:00:00+00:00", year, month)).unwrap();
16            if day.to_rfc2822().starts_with("Sun") {
17                answer += 1;
18            }
19        }
20    }
21    return Answer::Int(answer.into());
22}

Tags: calendar, combinatorics