Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
play.rs
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