Skip to content

Instantly share code, notes, and snippets.

@maretekent
Created September 13, 2018 10:50
Show Gist options
  • Save maretekent/67d4606a869f91b092b67d2f459b8ccc to your computer and use it in GitHub Desktop.
Save maretekent/67d4606a869f91b092b67d2f459b8ccc to your computer and use it in GitHub Desktop.
snippet to rotate the number
use std::collections::VecDeque;
fn main() {
let num = 1970;
let mut buf: VecDeque<_> = num.to_string().chars().map(|d| d.to_digit(10).unwrap()).collect();;
for _ in 0..buf.len() {
println!("{:?}", buf);
let n = buf.pop_front().unwrap();
buf.push_back(n);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment