From 1ed618e300265f4237a0b58040aa58a006ab7fcb Mon Sep 17 00:00:00 2001 From: mehbark Date: Mon, 22 Dec 2025 13:43:17 -0500 Subject: [PATCH] initial --- .gitignore | 1 + Cargo.lock | 7 +++++++ Cargo.toml | 6 ++++++ README.md | 4 ++++ src/main.rs | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 69 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 README.md create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..b408ff4 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "blue-uncurse" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..97f2e49 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "blue-uncurse" +version = "0.1.0" +edition = "2024" + +[dependencies] diff --git a/README.md b/README.md new file mode 100644 index 0000000..fd2414d --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# blue uncurse +output lines of less than 2000 characters (suitable for discord messages) that contain every four-letter word in `etoaisnhrldum`, so you can get blue uncursed. + + diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..6d31acc --- /dev/null +++ b/src/main.rs @@ -0,0 +1,51 @@ +use std::collections::HashSet; + +const LETTERS: [u8; 13] = *b"etoaisnhrldum"; + +fn overlap(first: &[u8], second: &[u8]) -> usize { + if &first[first.len().saturating_sub(second.len())..] == second { + second.len() + } else { + overlap(first, &second[..second.len() - 1]) + } +} + +fn main() { + let mut remaining = HashSet::new(); + + for a in LETTERS { + for b in LETTERS { + for c in LETTERS { + for d in LETTERS { + remaining.insert([a, b, c, d]); + } + } + } + } + + eprintln!("words: {}", remaining.len()); + + let mut last = *b"aaaa"; + remaining.remove(&last); + + let mut output = String::from_utf8_lossy(&last).to_string(); + + while let Some(word) = remaining + .iter() + .max_by_key(|word| overlap(&last, &word[..])) + { + let word = *word; + remaining.remove(&word); + let added = &word[overlap(&last, &word[..])..]; + last = word; + output.push_str(&String::from_utf8_lossy(added)); + + if output.len() > 1996 { + println!("{output}"); + output.clear(); + output.push_str(&String::from_utf8_lossy(&word)); + } + } + + println!("{output}"); +}