This commit is contained in:
mehbark 2025-12-22 13:43:17 -05:00
commit 1ed618e300
Signed by: mbk
GPG key ID: E333EC1335FFCCDB
5 changed files with 69 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/target

7
Cargo.lock generated Normal file
View file

@ -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"

6
Cargo.toml Normal file
View file

@ -0,0 +1,6 @@
[package]
name = "blue-uncurse"
version = "0.1.0"
edition = "2024"
[dependencies]

4
README.md Normal file
View file

@ -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.
<https://github.com/mehbark/homelab/blob/856f6f327bb1bc7a1f5dd37370dd041d38ebb840/bots/puyo.ts#L799-L808>

51
src/main.rs Normal file
View file

@ -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}");
}