Created
January 20, 2017 14:07
-
-
Save Rivsen/160c9a99cad118c5397f4e270667c2f4 to your computer and use it in GitHub Desktop.
play.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::iter::FromIterator; | |
fn main() { | |
let columns_number: i64 = 356; | |
println!("Number of columns_number: {}", columns_number); | |
let mut columns_array: Vec<String> = Vec::new(); | |
let mut last_column: Vec<char> = Vec::new(); | |
let mut i = 0; | |
loop { | |
if last_column.len() == 0 { | |
last_column.push('A'); | |
columns_array.push("A".to_string()); | |
continue; | |
} | |
let mut need_plus_up = true; | |
for column in last_column.iter_mut().rev() { | |
if need_plus_up { | |
if *column as u8 == 'Z' as u8 { | |
*column = 'A'; | |
} else { | |
*column = (1 + *column as u8) as char; | |
need_plus_up = false; | |
} | |
} | |
} | |
if need_plus_up { | |
last_column.insert(0, 'A'); | |
} | |
columns_array.push(String::from_iter(last_column.clone())); | |
i = i+1; | |
if i == columns_number-1 { | |
break; | |
} | |
} | |
for column in columns_array { | |
println!("{}", column); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment