horrible code

This commit is contained in:
AustrianToast 2024-12-13 16:49:50 +01:00
parent 4992819738
commit 1559682aa6
Signed by: AustrianToast
GPG Key ID: FA59D02DC1947418
4 changed files with 70 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 = 3
[[package]]
name = "jttg"
version = "0.1.0"

6
Cargo.toml Normal file
View File

@ -0,0 +1,6 @@
[package]
name = "jttg"
version = "0.1.0"
edition = "2021"
[dependencies]

56
src/main.rs Normal file
View File

@ -0,0 +1,56 @@
use std::env::args;
const KNOWN_GRAPHEMES: [&str; 10] = ["a", "i", "u", "e", "o", "ka", "ki", "ku", "ke", "ko"];
// look at the first letter, if it exists in KNOWN_GRAPHEMES, then add to graphemes
// else look at the first and second letter, if that exists in KNOWN_GRAPHEMES, then add that to grapehemes
fn split_word(word: String) -> Vec<String> {
let mut graphemes: Vec<String> = vec![];
let mut word_chars = word.chars();
let mut grapheme: String;
loop {
grapheme = match word_chars.next() {
Some(val) => String::from(val),
None => break,
};
dbg!(&grapheme);
let temp = grapheme.as_str();
if KNOWN_GRAPHEMES.contains(&temp) {
graphemes.push(grapheme);
} else {
grapheme.push(word_chars.next().unwrap());
let temp = grapheme.as_str();
if KNOWN_GRAPHEMES.contains(&temp) {
graphemes.push(grapheme);
}
}
}
return graphemes;
}
fn main() {
// dbg!(KNOWN_GRAPHEMES);
// dbg!(&args());
if args().len() != 2 {
panic!("fuck");
}
let input = match args().last() {
Some(val) => val.trim().to_lowercase(),
None => panic!("how?!"),
};
println!("Sanitised input: {}", input);
let graphemes = split_word(input);
dbg!(graphemes);
}