Skip to content

Instantly share code, notes, and snippets.

@kmark
Created April 27, 2018 02:41
Show Gist options
  • Save kmark/9ca9d417d7744e5831d4811928916dde to your computer and use it in GitHub Desktop.
Save kmark/9ca9d417d7744e5831d4811928916dde to your computer and use it in GitHub Desktop.
// https://www.reddit.com/r/programmingcirclejerk/comments/8f7gjg/psa_there_are_over_1000_people_in_the_us_named/dy1c4ey/
fn main() {
const JERK: &str = "INFINITY";
fn exaggerate(mut acc: String, ch: char) -> String {
acc.push(ch);
acc.push(' ');
acc
}
JERK.chars().enumerate().zip(JERK.chars().rev()).map(|((y_idx, ch), rev_ch)| {
match y_idx {
0 => JERK.chars().fold(String::with_capacity(JERK.len() * 2), exaggerate),
i if i == (JERK.len() - 1) => JERK.chars().rev().fold(String::with_capacity(JERK.len() * 2), exaggerate),
_ => format!("{: <1$}{2}", ch, (JERK.len() * 2) - 2, rev_ch),
}
}).for_each(|jizz| println!("{}", jizz));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment