Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
hddqsb
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
20 ms
·
181.
▲
by
hddqsb
4y ago
Unfortunately Go's playground messes with the time, so it's always going to say 0.00s even for the slow version. Here is a hacky workaround to measure the actual time using a syscall: https://go.dev/play/p
182.
▲
by
hddqsb
5y ago
How exactly can they contain nulls? fopen() takes a null-terminated filename, so if there is a null byte in the middle it would just truncate the filename.
183.
▲
by
hddqsb
5y ago
Oh wow, that's a pretty new feature! It was added in v569, 2020[1]. [1]: https://github.com/gwsw/less/commit/6a070fc53799fb86e0fe3880...
184.
▲
by
hddqsb
5y ago
Good tips. Small correction: `&` only filters by the most recent pattern.
185.
▲
by
hddqsb
5y ago
`COPY --chmod` is quite new, and as mentioned in the post requires BuildKit (i.e. `docker buildx`). A more portable solution is to use `chmod` right after unzipping the binary. The `COPY` command will then preserve the executable permission
186.
▲
by
hddqsb
5y ago
That's a bold claim. Do you have any references to support it? The examples in Docker's documentation use apt-get directly and I don't see any recommendation to use a base image as you describe.[1][2] With Debian, there are s
187.
▲
by
hddqsb
5y ago
Not just any example: Ghacks is owned by Softonic.
188.
▲
by
hddqsb
5y ago
If I use right click > Pin Tab in Firefox (and only have a single tab open), the tab stays open on Ctrl+W.
189.
▲
by
hddqsb
5y ago
Defining `left - 1` to be green `right` to be red can be thought of as "padding" the input to ensure that there is at least one green and one red, but I'll concede that it is sneaky. (A less sneaky version is to explicitly de
190.
▲
by
hddqsb
5y ago
Psst, if you use an inclusive-exclusive interval for the parameters and an exclusive-exclusive interval for the implementation (see my top-level comment), it becomes nicer and you can keep your original invariants. You just need `left -=
191.
▲
by
hddqsb
5y ago
The "+1" is not a superficial optimisation, it can be critical for correctness. Consider the following (correct) implementation, which uses +1: def binary_search(array, target): left, right = 0, len(array) wh
192.
▲
by
hddqsb
5y ago
This invariant has some surprising effects: - When the target appears multiple times, the search will find the last occurrence rather than the first. - If you return `right`, then you get the behaviour of C++'s std::upper_bound and Pyt
193.
▲
by
hddqsb
5y ago
The three special cases are unnecessary (see my top-level comment). Implementations that terminate early might seem faster at fist glance, but they can actually be slower: they only save 1 iteration on average*, and they require up to 2 bra
194.
▲
by
hddqsb
5y ago
Note that with this version, the expected number of calls to `predicate` can be 1 more than strictly necessary (depending on n). This happens when n is one more than a power of 2, e.g. if n is 65 then `bit` is 64 and the first call will be
195.
▲
by
hddqsb
5y ago
I love the colouring approach, that's same approach I use when explaining/analysing binary search. One advantage of this approach that was not explicitly mentioned is that the behaviour is clear and well-defined when the target el
196.
▲
by
hddqsb
5y ago
GNU dd has a similar feature, it prints the status on SIGUSR1. There is no keyboard shortcut though, so you'd have to open another terminal and run `pkill -USR1 -x dd`.
197.
▲
by
hddqsb
5y ago
On Linux, pv can actually determine the size of the output device (using lseek on stdout), so `pv </dev/zero >/dev/sdb` does give a correct ETA (tested with pv 1.6.6 on Debian).
198.
▲
by
hddqsb
5y ago
In fact VIRUS, ENNUI, GRIEF, SLAVE, INANE are all in the (original) solution list.
199.
▲
by
hddqsb
5y ago
Good point, though technically a hashtable can only test for existence and can't find the lower bound. Also, a hashtable is likely to require more memory.
200.
▲
by
hddqsb
5y ago
Great idea, but this link doesn't really work -- it always has the same secret word, because the Wayback Machine injects some JavaScript to make the Date function return a constant date (try running `console.log(new Date())`). The link
201.
▲
by
hddqsb
5y ago
Here is one way to fix it (but it will push you over 50 lines!) remaining="" output="" for ((i = 0; i < ${#actual}; i++)); do if [[ "${actual:$i:1}" != "${guess:$i:1}" ]]; then
202.
▲
by
hddqsb
5y ago
You have a typo: it should be `HISTFILE`, not `HIST_FILE`.
203.
▲
by
hddqsb
5y ago
Matrix multiplication is O(n^3), while transposing is O(n^2). So for a large matrix, transposing will only take a tiny fraction of the time spent in multiplication. (But the loop reordering trick mentioned in @mynameismon's link is a v
204.
▲
by
hddqsb
5y ago
There is a leaderboard at https://botfights.io/game/wordle for solving with all 12972 words as possible solutions, it might be of interest.
205.
▲
by
hddqsb
5y ago
Here is someone's write-up (with code) using the entropy method: https://jluebeck.github.io/posts/WordleSolver
206.
▲
by
hddqsb
5y ago
For the entropy strategy, the expected number of guesses on the full dictionary (allowing all 12972 words as possible solutions) is 4.233 (54910/12972)* according to my tests. The best score on https://botfights.io/game
207.
▲
by
hddqsb
5y ago
Which solution list did you use to calculate the mean attempts? Another comment mentioned https://botfights.io/game/wordle , if you evaluate your solver on their word list you could compare scores.
208.
▲
by
hddqsb
5y ago
Maximising the information gained using Shannon's entropy is a very good strategy (assuming the goal is to minimise the expected number of guesses), however it is not necessarily optimal! I have a counter example for a simplified versi
209.
▲
by
hddqsb
5y ago
To add to my previous comment... I realise that this blog post is about a strategy for humans to use rather than for an ideal solver, so a degree of inexactness is to be expected. Still, I dislike the way the words "best" and &q
210.
▲
by
hddqsb
5y ago
Interesting post, but the premise is misleading. The title says "Best ... strategy" and the first sentence reads "This post will derive an optimal ... strategy", but there is nothing to suggest that this strategy is opti
More ›