|
|
@ -21,7 +21,9 @@ fn solve(input: &str) -> Result<String, Box<Error>> {
|
|
|
|
.map(str::trim)
|
|
|
|
.map(str::trim)
|
|
|
|
.map(Claim::from_str)
|
|
|
|
.map(Claim::from_str)
|
|
|
|
.collect::<Result<_, _>>()?;
|
|
|
|
.collect::<Result<_, _>>()?;
|
|
|
|
let fabric = claims.iter().fold(HashMap::new(), |mut fabric: HashMap<(usize, usize), Vec<usize>>, claim| {
|
|
|
|
let fabric = claims.iter().fold(
|
|
|
|
|
|
|
|
HashMap::new(),
|
|
|
|
|
|
|
|
|mut fabric: HashMap<(usize, usize), Vec<usize>>, claim| {
|
|
|
|
for square_inch in claim.square_inches() {
|
|
|
|
for square_inch in claim.square_inches() {
|
|
|
|
fabric
|
|
|
|
fabric
|
|
|
|
.entry(square_inch)
|
|
|
|
.entry(square_inch)
|
|
|
@ -29,7 +31,8 @@ fn solve(input: &str) -> Result<String, Box<Error>> {
|
|
|
|
.or_insert(vec![claim.id]);
|
|
|
|
.or_insert(vec![claim.id]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fabric
|
|
|
|
fabric
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
let values: Vec<_> = fabric.values().collect();
|
|
|
|
let values: Vec<_> = fabric.values().collect();
|
|
|
|
let output = values
|
|
|
|
let output = values
|
|
|
|
.iter()
|
|
|
|
.iter()
|
|
|
|