Anagramator V.2
ANAGRAMATOR V.2
INPUT
How to Use
-
Type or paste the text to rearrange on the input box.
Maximum 15 characters (recommended max 9).
Acceptable characters: A-Z or 0-9 or any other characters (besides
white space
) that can be rendered onHTML
.Supports emoji or UNICODE character like 😵💫🤷♂️🫠➼▶ᴱᴹᴼᵀᵢᵥₑ
-
Click the RUN button or hit Enter on keyboard to run Anagramator V.2.
There will be DOWNLOAD RESULT to download the result as text file and OPEN TXT to open the output on a new tab.
For output size larger than 1,000 arrangements, the result will only available on DOWNLOAD RESULT and OPEN TXT.
- To clear everything, hit CLEAR button or delete/modify the input.
- Hit TOP to scroll to input box.
Techniques
- Fisher-Yates technique to shuffle the sequence.
- Web Workers API for input strings longer than 7 characters.
-
UNICODE input splitting technique implements
Intl.Segmenter()
method.function splitGraphemes(text) { const segmenter = new Intl.Segmenter(undefined, { granularity: "grapheme" }) return Array.from(segmenter.segment(text), (seg) => seg.segment) }
-
Also implements
Set.has()
because of (mostly)O(1)
compared toArray.includes()
which is alwaysO(n)
.
Limitations
-
Because this is a brute force method with some pointers, so then maximum input length is 15 characters so that it won't make you wait too long.
Recommended maximum length is 9 characters. Above 9, assuming there's no repeating character, the result size will increase significantly because of the factorial calculation.
As you can see,
9! = 362,880
, but then10! = 3,628,800
(10 times!). That's heavy and long brute force. - Please omit the white space before calculating.
- There will be an auto abort gate when each character looping reaches the limit. But you still can see some portion of the output (incomplete result).
FUAMLOR
Fuamlor is an anagram of formula.
Take for example the total rearrangements can be made from these two words: YES and BOBBY.
Factorial
Factorial operator (!
) is an exclamation after (right side) the number.
The operation is multiplication of the original integer, all the way descending to 1.
n! = n × (n-1) × (n-2) × (n-3) × ... × 1
n
is integer and larger than or equal to 0
(Pre-definition) 0! = 1
For instance, factorial(4)
➡️ 4!
➡️ 4 × 3 × 2 × 1 = 24
Alright, let's go.
YES ➡️ The set will be {E, S, Y} (must be sorted). The length is 3, and it has no repeating character.
The fuamlor for total rearrangements is:
Total =
original_size! ÷ (Π each_occurrence!)
Π
(uppercase pi) is math notation forproduct
Example: 2 × 4 × 8 × 10 × ...
Hence, for YES, total = 3! ÷ (1! • 1! • 1!) ➡️ 6 ÷ 1 = 6
Now, the fuamlor for subtotal of each member of the set.
Let's use variable
A, B, C
to shorten the fuamlor.Let
A
be original sizeB
is Π each_occurrence!C
is current character occurrenceSo then, Subtotal =
A! ÷ B ÷ A × C
Or, Subtotal =
(A - 1)! ÷ B × C
Therefore, each subtotal of E, Y, and S respectively:
- E
➡️ 3! ÷ (1!•1!•1!) ÷ 3 × 1 ➡️ 6 ÷ 1 ÷ 3 × 1 = 2
(OR) ➡️ (3 - 1)! ÷ (1!•1!•1!) × 1 ➡️ 2 ÷ 1 × 1 = 2
- S
➡️ 3! ÷ (1!•1!•1!) ÷ 3 × 1 ➡️ 6 ÷ 1 ÷ 3 × 1 = 2
(OR) ➡️ (3 - 1)! ÷ (1!•1!•1!) × 1 ➡️ 2 ÷ 1 × 1 = 2
- Y
➡️ 3! ÷ (1!•1!•1!) ÷ 3 × 1 ➡️ 6 ÷ 1 ÷ 3 × 1 = 2
(OR) ➡️ (3 - 1)! ÷ (1!•1!•1!) × 1 ➡️ 2 ÷ 1 × 1 = 2
If we add them up, 2 + 2 + 2 = 6 (same as total rearrangements).
- E
BOBBY ➡️ The set is {B, O, Y}.
The original length is 5 (not the size of the set), and it has one repeating character, B.
The B repeats thrice (3). For others (O and Y), each has one occurrence.
Total = 5! ÷ (3! • 1! • 1!) = 120 ÷ 6 = 20
Each subtotal:
- B
➡️ 5! ÷ (3!•1! •!) ÷ 5 × 3 ➡️ 120 ÷ 6 ÷ 5 × 3 ➡️ 4 × 3 = 12
(OR) ➡️ (5 - 1)! ÷ (3!•1! •!) × 3 ➡️ 24 ÷ 6 × 3 ➡️ 4 × 3 = 12
- O
➡️ 5! ÷ (3!•1! •!) ÷ 5 × 1 ➡️ 120 ÷ 6 ÷ 5 × 1 ➡️ 4 × 1 = 4
(OR) ➡️ (5 - 1)! ÷ (3!•1! •!) × 1 ➡️ 24 ÷ 6 × 1 ➡️ 4 × 1 = 4
- Y
➡️ 5! ÷ (3!•1! •!) ÷ 5 × 1 ➡️ 120 ÷ 6 ÷ 5 × 1 ➡️ 4 × 1 = 4
(OR) ➡️ (5 - 1)! ÷ (3!•1! •!) × 1 ➡️ 24 ÷ 6 × 1 ➡️ 4 × 1 = 4
The sum of each subtotal ➡️ 12 + 4 + 4 = 20 (equal to total rearrangements).
- B