Primel – guess a 5 digit prime number – each guess must be a prime
converged.yt
converged.yt
Anyway, this is a really cool example of that. It's wordle, but with a twist.
Step 1 is to find an optimal starting word. My most insightful finding so far has came from trying to define a cost function for comparing potential starting words. It turns out that "% of potential guesses [not] eliminated" is an excellent loss function.
Importantly, the full set of all Acceptable Guesses is knowable. For any given (guess, answer) pair, the game provides feedback about each character (or digit). There are basically three pieces of potential feedback: (N)ot Used, (U)sed Elsewhere, (E)xact Match. For example, a single guess might produce the feedback "NUNNE". Each of these will eliminate some subset of Acceptable Guesses which means you can attribute a fixed value between 0.0 and 1.0 to any piece of feedback, and multiply those together to get the loss score of a given guess. Average that across all Potential Answers to get a cost score.
Not sure what my goal of this post is. Guess I just wanted to share that these games are as much fun to analyze as they are to play (if not more).
If the answer has one E and you guess a word with two Es, only one of the Es will be marked correct (green/yellow). If one of the Es is in the correct place, it will be green and the other one grey. Otherwise the first E will be yellow and the second grey. So if the answer has fewer Es than your guess the game tells you.
If the answer has more Es than your guess there is no indication of this.
But there is a better strategy (similar to what is used in those interview puzzles of "From N weights, find 1 that is different in X measurements of a scale): The fact that you input some vowels and see that they are not in there, tells you that the remaining ones MUST be in the word (treating Y as a vowel as well). So it might be possible to come up with a strategy that uses that negative information as well to minimize the search space.
I’m sure it’s far from optimal, but I continue to use it because I obviously understand how I came to choose it, and it “works” and survivor bias is powerful :)
I recall seeing HN posts from people working out “optimal” starting words and guess patterns, but I just like mine :)
Maybe I shouldn't be sharing this, it's a bit sad to break the illusion that the creator is picking a new word for us every day.
https://aditya-sengupta.github.io/coding/2022/01/13/wordle.h...
3rd row for next 18 columns has drop down filter.
You guess any word with at least 2 vowels, if 3 better, no repeat letters. You get some grey, some yellow, some maybe green.
2nd column to 6th column on excel sheet is the Grey Letters, Not Found in Answer. In this, 2nd row, if u find any grey you type it here. The formula from row 4 downwards in this group checks if its top input cell is empty, if yes, true, if not empty, then it check if that letter exists in its row cell of column A. If exists, false (grey means no letter), otherwise true.
Column 7th to 11 are yellow. Same thing, row 2 gets input, 4th row onwards checks if this exists in Column A cell, true, otherwise false. If input cell empty, then True.
Column 12 to 16 gets green letter input. Here input goes by position, if 2nd letter is green, you type it in 2nd column of this group, which is 13th column.
Formula in 4th and next checks if input empty, true, otherwise if input exist in exact position, true, otherwise false.
17th column is empty & narrow, to create a gap.
18th column returns 0 if any false found in while row. Any false means this word is not the answer. Otherwise returns 1.
A separate one cell counts all those 1, tells me how many potential answers are. After every try/word, one can filter this last column on 1.
Now come up with a hash that starts with many zeroes.
12347
-
65393
++--
[solution next - omitted for spoiler reasons]
I was more surprised about how little trial and error I needed to find primes than about how few guesses it actually took... 12347
-
[solved]Edit: I checked, it's 9 vs 8 primes. But nearby prefixes also have more and there's a lot of variance. Still, there are overall more primes among the same range of smaller numbers (1000-5499 has ~4400 primes, 5500-99999 has ~4000).
Note that, despite this, you probably shouldn't include 0 in the starting guess (e.g. 10247) because 0 will be in the solution less frequently (can't be the leading digit), meaning you gain less info on average.
That being said, the pool you're really working from is the numbers with last digit 1, 3, 7, or 9. One out of every 4.6 such numbers under 10^5 is prime. So just guessing until you find a prime is practical.
> On calculators, it is printed as "log", but mathematicians usually mean natural logarithm (logarithm with base e ≈ 2.71828) rather than common logarithm when they write "log".
Also, the following script might help to make the game more accessible (or to help you cheat :P) -
// note: game doesn't seem to automatically clear at the end, so in the dev console use:
// window.localStorage.clear();
// then refresh the page
const prime = n => {
for (let i = 2, s = Math.sqrt(n); i <= s; i++) {
if (n % i === 0) {
return false;
}
}
return n > 1;
}
const generateNums = digits => (
m => [...Array(9 * m).keys()].map(i => i + m)
)(Math.pow(10, digits - 1));
const generate5DigitPrimes = () => generateNums(5).filter(prime);
const all5DigitPrimes = generate5DigitPrimes();
// updated to take an optional array (defaults to all5DigitPrimes)
// this means you can chain the check function to do things that normal regex can't do
// e.g. check(/some_regex/, check(/some_other_regex/))
const check = (r, a = all5DigitPrimes) => a.filter(p => r.test('' + p));
Usage:paste the above code into the dev console
type 'all5DigitPrimes' and press Enter to see a list of all 5-digit primes
type 'check(/some_regular_expression/)' to see a filtered list of primes that match your regular expression
There are 8,363 five digit primes. If you limit your guesses to numbers ending in 1, 3, 7, and 9, there is a 23% chance of randomly picking a prime.
That got me two substantially-different primes and narrowed my numbers a lot, which then became guesswork.
My guesses in the end:
-?---
?---!
?-??!
?!??!
!!!!!by the way am I supposed to take some meaning from the italicized '7' or was that just a typo?
Being a little smarter, prime number can only end in a 1, 3, 7 or 9 - (ending in 0, 2, 4, 6, 8 would be even, ending in 5 would be odd), so in fact it's more like 25% of 'likely' guesses.
Does work _much_ better in this range than at crypto sizes though.
This assumes that you can easily identify - multiples of 2 and 5 (by their last digit) - multiples of 3 (the sum of their digits is divisible by 3) - multiples of 11 (for two-digit ones, they have both digits the same: 11, 22, 33, ..., 99) - squares
So the first number that looks prime but isn't is the product of the two smallest primes that aren't "easy", which is 7*13 = 91.
Unlike Wordle, I assume it's unreasonable to expect a player to know primes so I don't think I'd call this cheating.
primes 10000 99999 | less
Then recall that "less" includes a regex-based search on the / key.This doesn't give you direction as to the best to try, of course, but it's hard to beat it in terms of bang for the buck if you're just going to try a few.
seq 10000 99999 | factor | grep '^\([^:]*\): \1$' | cut -d: -f1 >5_digit_primes.txt
Using that file with grep was helpful for refining guesses.
I am stronger in python, and definitely wrote a script to cheat at Words With Friends back in the day (always told my friend afterwards and only pulled that stunt a few times).
If I had known posix better, my script may very well have been a one-liner of bash. Awk-ward.
71429
Than I already had one digit guessed and simply clicked the unused numbers from the virtual numpad below and got to having all digits with just two being in the wrong place:
35869
Now this was easy to figure out.
Got the following score: 20 3/6
https://gist.github.com/nickponline/9a3fb1ee5333c52ed195625e...
N = 100000 primes = [False, True] * N // 2 for i in range(3, N, 2):
if primes[i]:
k = i ** 2
while k < N:
primes[k] = False
k += i * 2 if prime[i]:
primes.append(i)
k = i ** 2
while k < N:
prime[k] = False
k += i * 2
useful = [ str(i) for i in primes ]# Enter your clues
for i in useful: if i[0] == '6' and ('3' in i) and len(str(i)) == 5: print(i)
The intent, I think, is to mimic how Wordle works. Wordle has one puzzle per day, progress and statistics are stored in a cookie on your local machine (and only there). You can clear the cookie or use another browser or privacy mode to play multiple times per day, but you'll always get the same word.
So, since the puzzle will be the same, there isn't a huge amount of reason to let you reset.
The page could have made that clearer. (Wordle says it when you open it the first time, and also under the help menu.) I double-checked this by looking at the sourcecode.
Good point! Somehow, being numbers, I thought it would just make up another.
45677
56779 (Didn't read the instructions, the 5 should have stayed from 1st)
15809
35869
65839 (Solved)
EDIT: I'm slow today, just realized they are both the same primes.I had tried 18141, by the way, which I modestly think was a pretty good guess in hindsight given its only two factors are 3 and 6047. 19141 would have been a prime, but perhaps not the one I was supposed to find? I don't play Wordle so I'm a little confused
1+8+1+4+1 = 15 15/3 = 5
I think it should clear the whole guess after an invalid guess.
⬜⬜⬜30029 ⬜⬜⬜⬜12347 ⬜⬜⬜⬜33331 ⬜⬜⬜⬜13337 86539 65839
Also, might want to disable text selection via css because I kept selecting the numbers on the button on my phone.
Just say so!
65537
12497
80747
23459
64217
14771
95317
-+-
25943
+- -
65393
++--
65839
+++++
Some luck, but you can also lock in odd numbers before proceeding to add evens. And it obviously can't end in an even.Apparently I have stumbled over an idiom of the prime-enthusiast community.
E.g. 3 is a 1 digit number because that's the number of digits needed to uniquely identify 3. There are infinitely more ways to identify 3 the number with padded 0s but those aren't useful unless you're talking about combinations/sequences of groups of digits (like random numbers or PIN codes) instead of actual number values.
It’s not a significant digit[0], though, when it’s leading.
But I still love the concept!
⬛⬛⬛⬛ ⬛⬛⬛ ⬛
Partially interpreted:
⬛⬛🟨⬛⬛
🟨⬛🟨⬛⬛
🟨🟨🟨⬛🟩
🟩🟩🟩🟩🟩
Edit, I guess HN doesn't like emojis lol
1 2 [3] 4 7
[5][6](8)[9][3]
(6)(5)(8)(3)(9)
Fun game! Might take a while to explain to people though!
⬜⬜ 18413 ⬜ 28163 98123
⬜⬜⬜ ⬜ ⬜ ⬜ ⬜