use rand::seq::SliceRandom; use rand::Rng; use rand_xoshiro::rand_core::SeedableRng; use rand_xoshiro::Xoshiro256PlusPlus; use std::collections::HashMap; use std::fs::File; use std::io::Write; fn main() -> std::io::Result<()> { // This should have been a Python script, but Rust is more of a meme // From https://ascii.co.uk/art/anime let header = r#" db db dpqb dp8b 8b qb_____dp_88 88/ . `p q'. \ .'. .-. ,-. `--. |. / 0 \ / 0 \ | \ |: `.__ ___.' | \\/ |. " | ( \. `-'-' ,' | _/`------------'. .| /. \\::(::[];)||:. \ /. ' \.`:;;;;'''/`. .| |. |/ `;--._.__/ |..| |: _/_,'''',,`. `:.' |. ` / , ',`. |/ \. -'/\/ ',\ |\ /\__-' /\ / ,: |.\ /. .| ' /-. ,: |..\ :. .| /| | , ,||: ..: |. .` | '//` ,:|: :| |.. .\ //\/ ,|: ..| \. .\ <./ ,'. ../ \_ ,..`.__ _,..,._/ `\|||/ `--'\|||/'"#; let letters = HashMap::from([ ( 'A', "0000000000 0000110000 0001001000 0001001000 0010000100 0011111100 0010000100 0100000010 0100000010 0000000000", ), ( 'D', "0000000000 0011110000 0010001000 0010000100 0010000100 0010000100 0010000100 0010001000 0011110000 0000000000", ), ( 'F', "0000000000 0011111110 0010000000 0010000000 0010000000 0011111110 0010000000 0010000000 0010000000 0000000000", ), ( 'H', "0000000000 0010000100 0010000100 0010000100 0010000100 0011111100 0010000100 0010000100 0010000100 0000000000", ), ( 'I', "0000000000 0111111100 0000100000 0000100000 0000100000 0000100000 0000100000 0000100000 0111111100 0000000000", ), ( 'L', "0000000000 0010000000 0010000000 0010000000 0010000000 0010000000 0010000000 0011111110 0011111110 0000000000", ), ( 'O', "0000000000 0001111000 0010000100 0100000010 0100000010 0100000010 0100000010 0010000100 0001111000 0000000000", ), ( 'P', "0000000000 0011111000 0010000100 0010000100 0010000100 0011111100 0010000000 0010000000 0010000000 0000000000", ), ( 'R', "0000000000 0011110000 0010001000 0010000100 0010001000 0011110000 0010100000 0010010000 0010001000 0000000000", ), ( 'S', "0000000000 0001111000 0010000100 0010000000 0011100000 0000111000 0000000100 0010000100 0001111000 0000000000", ), ( 'Y', "0000000000 0110000110 0110000110 0010000100 0001001000 0000110000 0000110000 0000110000 0000110000 0000000000", ), ( '0', "0000000000 0001111000 0010000100 0100000010 0100000010 0100000010 0100000010 0010000100 0001111000 0000000000", ), ( '1', "0000000000 0000110000 0001110000 0010110000 0000110000 0000110000 0000110000 0000110000 0001111000 0000000000", ), ( '2', "0000000000 0001111000 0010000100 0010000010 0000000100 0000001000 0000010000 0001100000 0011111110 0000000000", ), ( '4', "0000000000 0000011000 0000101000 0001001000 0010001000 0100001000 0111111110 0000001000 0000001000 0000000000", ), ( '🙂', "0000000000 0000000000 0011001100 0011001100 0000000000 0100000010 0100000010 0011001100 0001111000 0000000000", ), ]); let ans = "HAPPYAPRILFOOLSDAY202441🙂"; let mut rng = Xoshiro256PlusPlus::seed_from_u64(202441); let mut file = File::create("index.html")?; writeln!(file, "", header)?; for c in ans.chars() { let letter = letters[&c].chars(); let mut zeros = letter .enumerate() .filter(|(_, c)| matches!(c, '0')) .map(|(i, _)| i) .collect::>(); zeros.shuffle(&mut rng); let mut cnt = 0; for i in zeros { cnt += 1; writeln!( file, "
{}
", ((i / 11) as f32 + rng.gen_range(0.15..0.85)) * 50.0, ((i % 11) as f32 + rng.gen_range(0.15..0.85)) * 50.0, if cnt % 2 == 0 { "|" } else { "." } )?; } } writeln!(file, "")?; Ok(()) }