[2017][rust][1.1]

sorbet
Alpha Chen 7 years ago
parent 26ac38d39f
commit 6acc2899be

@ -8,8 +8,9 @@ pub fn solve(input: &str) -> Result<String, Error> {
.collect::<Result<_, _>>()?; .collect::<Result<_, _>>()?;
// 1 // 1
let offset = 1; let offset = input.len() / 2;
let offset_iter = input.iter().skip(offset).cycle().take(input.len());
let offset_iter = input.iter().cycle().skip(offset).take(input.len());
Ok( Ok(
input input
.iter() .iter()
@ -20,3 +21,12 @@ pub fn solve(input: &str) -> Result<String, Error> {
.to_string(), .to_string(),
) )
} }
#[test]
fn part_two() {
assert_eq!(solve("1212").unwrap(), "6".to_string());
assert_eq!(solve("1221").unwrap(), "0".to_string());
assert_eq!(solve("123425").unwrap(), "4".to_string());
assert_eq!(solve("123123").unwrap(), "12".to_string());
assert_eq!(solve("12131415").unwrap(), "4".to_string());
}

Loading…
Cancel
Save