Back
Version 70
12/30/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 hintWithSpaceRemoved = "";
// Iterate through words, building the hint until we have exactly 4 unique letters
for (let i = 0; i < quote.length; i++) {
currentHint += quote[i];
hintWithSpaceRemoved = currentHint.replace(/\s/g, "");
if (hintWithSpaceRemoved.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 buildKeyedAlphabet(
keyword: string,
positionLetter: string,
bao-cipher.web.val.run
Updated: January 29, 2025