Back
Version 37
12/29/2024
/** @jsxImportSource https://esm.sh/react@18.2.0 */
import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
import React, { createRef, useEffect, useRef, useState } from "https://esm.sh/react@18.2.0";
function getUniqueLetters(word: string): string {
return [...new Set(word.toUpperCase().replace(/[^A-Z]/g, ""))].join("");
}
function generateHint(quote: string): { hint: string; source: "first" | "last" } {
const words = quote.split(" ");
let currentHint = "";
let uniqueLetters = "";
// Iterate through words, building the hint until we have exactly 4 unique letters
for (let i = 0; i < quote.length; i++) {
currentHint += quote[i];
uniqueLetters = getUniqueLetters(currentHint);
if (uniqueLetters.length === 4) {
return {
hint: currentHint,
source: "first",
};
}
}
// Fallback: if we can't find 4 unique letters, return the first word
return {
hint: words[0],
source: "first",
};
}
function generatePatristocratCipher(quote: string) {
// Remove all non-alphabetic characters and spaces
const cleanQuote = quote.toUpperCase().replace(/[^A-Z]/g, "");
bao-cipher.web.val.run
Updated: January 27, 2025