summaryrefslogtreecommitdiff
path: root/main.rs
diff options
context:
space:
mode:
authorAnthony Wang2024-03-24 15:00:55 -0500
committerAnthony Wang2024-03-24 15:00:55 -0500
commit64dcb8fed4366faa084780f4191917b3989a1a7a (patch)
tree00063694fc81f1de85f3e833bcc39551cc8e1e37 /main.rs
Initial commit
Diffstat (limited to 'main.rs')
-rw-r--r--main.rs214
1 files changed, 214 insertions, 0 deletions
diff --git a/main.rs b/main.rs
new file mode 100644
index 0000000..9d9b5b2
--- /dev/null
+++ b/main.rs
@@ -0,0 +1,214 @@
+use rand::seq::SliceRandom;
+use rand::thread_rng;
+use rand::Rng;
+use std::collections::HashMap;
+use std::fs::File;
+use std::io::Write;
+
+fn main() -> std::io::Result<()> {
+ 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
+0100000000
+0111000000
+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",
+ ),
+ (
+ '2',
+ "0000000000
+0001111000
+0010000100
+0010000010
+0000000100
+0000001000
+0000010000
+0001100000
+0011111110
+0000000000",
+ ),
+ (
+ '4',
+ "0000000000
+0000011000
+0000101000
+0001001000
+0010001000
+0100001000
+0111111110
+0000001000
+0000001000
+0000000000",
+ ),
+ ]);
+ let ans = "HAPPYAPRILFOOLSDAY2024";
+ let mut file = File::create("index.html")?;
+ let mut rng = thread_rng();
+ for c in ans.chars() {
+ let letter = letters[&c].chars();
+ let mut zeros = letter
+ .enumerate()
+ .filter(|(_, c)| matches!(c, '0'))
+ .map(|(i, _)| i)
+ .collect::<Vec<_>>();
+ zeros.shuffle(&mut rng);
+ for i in zeros {
+ writeln!(
+ file,
+ "<div style='color:white;position:absolute;top:{}px;left:{}px'>0</div>",
+ ((i / 11) as f32 + rng.gen_range(0.1..0.9)) * 50.0,
+ ((i % 11) as f32 + rng.gen_range(0.1..0.9)) * 50.0
+ )?;
+ }
+ }
+ Ok(())
+}