Skip to content

Instantly share code, notes, and snippets.

@shapr
Created May 25, 2022 13:25
Show Gist options
  • Save shapr/d1e7f18e792ea1a4e95aea6ebe122d2e to your computer and use it in GitHub Desktop.
Save shapr/d1e7f18e792ea1a4e95aea6ebe122d2e to your computer and use it in GitHub Desktop.
fn solution(s: &str) -> Vec<String> {
let mut pile_of_strings = Vec::new();
let slice: &[char] = &s.chars().collect::<Vec<_>>()[..];
for piece in slice.chunks(2) {
if piece.len() > 1 {
pile_of_strings.push(piece.iter().collect());
} else {
// let squished : &str = &[piece,&['_']].concat();
pile_of_strings.push(&[piece, &['_']].concat().iter().collect());
// pile_of_strings.push(&'_');
}
}
return pile_of_strings;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment