Better HN
topnewbestaskshowjobs
Log inSign up

nightcracker

4,235 karma · joined Mar 27, 2013 (13y ago) · 788 submissions

Submissions

comment 5y ago · link · parent

Yes, I am aware it has been 'superseded' but in my experience for lossless compression it's still usually better.

comment 5y ago · link · parent

    QOI_DIFF24 {
        u8 tag  :  4;   // b1110
        u8 dr   :  5;   // 5-bit   red channel difference: -15..16
        u8 dg   :  5;   // 5-bit green channel difference: -15..16
        u8 db   :  5;   // 5-bit  blue channel difference: -15..16
        u8 da   :  5;   // 5-bit alpha channel difference: -15..16
    }
It bothers me more than it should that the 5-bit signed differences aren't -16..15 matching two's complement but -15..16 instead.

comment 5y ago · link · parent

You could still stream the pixels, you'd just have to stream them in Z order. This may seem pedantic, but this applies to any mismatch between the order in which you store pixels and the order in which the format stores pixels.

E.g. some file formats may be row-major, others column-major, some block-based (like JPEG) or a fancy interleaving scheme (like Adam7). Some might store the channels interleaved, others separate the channels. If any of these choices doesn't match the desired output format, it breaks streaming.

comment 5y ago · link · parent

When I download that PNG file it is 10785 KB. If I re-encode it using FLIF 0.4 (to my knowledge still the best off-the-shelf lossless image compression) it is 7368 KB. That's 57% of the size of qoi, quite a lot smaller. You pay for it in encode/decode time though.

comment 5y ago · link · parent

Copying the question text verbatim certainly is copyright infringement (and I would guess unlikely to be fair use, but I'm not a lawyer). If you give the problem in your own words, it won't be, just like your solution isn't.

comment 5y ago · link · parent

Looking through some of these URLs through Google cache, a lot of these contain verbatim copies of the problem text. Fair enough, legally speaking, if you are the copyright holder.

However, in the DMCA itself HackerRank asks for the removal of entire repositories, claiming "the whole repository is infringing copyright as it contains the solution". This is a blatant lie, HackerRank is not an automatic copyright holder of any solutions to a problem they published.

comment 5y ago · link · parent

I don't know, only have some theories.

1. The name isn't particularly catchy or descriptive. It is the correct name for the data structure, but not too many people know the data structure.

2. People don't even know what they're missing. It's not a very Google-able problem to begin with. Slotmap provides an interesting solution to (circular) ownership and safe allocator / weak pointer design problems, but people don't recognize that they're having them or that slotmap could help.

As an example of this, the doubly linked list example (https://github.com/orlp/slotmap/blob/master/examples/doubly_...) can safely remove nodes from the linked list given their handle, in O(1), even from the middle, completely safely and correctly, even in the presence of double deletions or ABA memory re-use. You can't replicate this with just pointers, without introducing heavy refcounting solutions.

comment 5y ago · link · parent

SlotMap literally cannot, because it must keep track of versions of the used slots, and the slots include the memory space for the data.

DenseSlotMap sort of can. It still can't reclaim the memory used by empty slots for the same reason (at a cost of 8 bytes per slot), but can reclaim the memory used by the actual elements stored.

So if you store 1 million items at one point in a DenseSlotMap, and then clear them all and then shrink to fit (which is actually missing from the API, but I'll fix that soon) you will waste 7.6 megabytes on the empty slots but nothing on the actual data that used to be stored.

comment 5y ago · link · parent

This reddit post is such a shame, and I wish people would stop referring to it. The benchmarking code is not apples to apples at all in many places.

E.g. to benchmark removals they used `container.remove(index)` for data structures that support indices but for slotmap they used `slotmap.remove(keys[index])` which unfairly adds another layer of indirection.

comment 5y ago · link · parent

There is no fragmentation whatsoever in the traditional sense (unusable gaps left due to size mismatches), because a slotmap only stores a single type of value. Thus every slot is interchangeable and memory can always be reused.

For iteration however, there can be holes that need to be ignored, if the current number of elements in the slotmap is significantly lower than the the maximum capacity. If iteration needs to be very fast (for e.g. game engines) I do have a solution for that, which is the DenseSlotMap. It uses one extra layer of indirection for random access, but stores the actual data values contiguously in a vector, thus iteration is always fast.

comment 5y ago · link · parent

Hi, author of slotmap here if anyone has any questions.

Slotmap is essentially the Vec + indices solution, while allowing memory to be reused. It is still completely safe, as it automatically versions each slot, and checks the version contained in the key when indexing.

comment 5y ago · link · parent

> It's not hard being faster than zip if you are not compressing/uncompressing

Actually, since CPUs are so fast and disk IO is so slow, it is essentially impossible to beat a properly tuned program that reads data from disk and decompresses it on the fly using one that doesn't use compression at all.

comment 5y ago · link · parent

If a significant amount of your new customers find your physical shop through Google maps, what can you do? If someone wants to find a hardware store near them, good chance they'll just write "hardware store" on Google maps. The entry point of people's search is Google - you've already lost the game before it ever started.

comment 5y ago · link · parent

I did miss that, oops. That said, it's again unclear if that curve is pre- or post- biased sampling. If it is on the original data it is quite good, but with a heavy biased sample fairly meaningless.

comment 5y ago · link · parent

Very sloppy statistics. A lot of explanatory analysis on the model is done but the model is hardly justified in being predictive in the first place.

The paper (https://journals.plos.org/plosone/article?id=10.1371/journal...) [does not mention the sensitivity or specificity of the model at all, only mentions a '91% accuracy' number]* on a biased dataset (where the number of suicidal cases is oversampled and non-suicidal cases are undersampled), without even mentioning exactly how much they over/undersampled.

* I missed the ROC curve on page 7. However it's not clear if this ROC curve was computed on the under/oversampled dataset or the original.

comment 5y ago · link · parent

No, it is a Pokémon reference to the very similarly named Excadrill.

comment 5y ago · link · parent

Softball is a bigger ball, yes. But it's not lower velocity, at least if you consider the relevant metric: time from pitcher to plate. Because softball also pitches a lot closer to the plate.

comment 5y ago · link · parent

See my other comment, it would also immediately be constructive: https://news.ycombinator.com/item?id=29022963

comment 5y ago · link · parent

Regarding (b), a non-constructive proof of P=NP does not exist. Because such a proof is immediately constructive.

You can create an enumeration over all Turing machines, and run each of them on the problem, 'diagonally', so we perform one step of computation on machine 1, then 1, 2, 1, 2, 3, 1, 2, 3, 4, etc. This will eventually run each Turing machine for an arbitrary amount of steps. As soon as one of the Turing machines accepts, we also accept.

Suppose the nth Turing machine is our poly time machine we have proven to exist (although we don't know n). It takes n steps of our meta algorithm to run this machine 1 step, then n+1 metasteps for the next step and so forth. In total it takes n + n+1 + ... + n+k = O(k^2 + kn) metasteps to run the nth Turing machine k steps.

But here's the crux... n does not depend on the input size, only on our problem! Thus it is a constant. In other words, this meta algorithm is quadratically worse (due to k^2 steps) than the optimal algorithm, but it is poly time.

Note that the above algorithm doesn't work for co-NP, in which we require that the "no" instances get solved in poly time (in NP we only require the "yes" instances to get solved in poly time).

comment 5y ago · link · parent

From what I have read (I don't do 3D modeling myself) Blender has overhauled its UI significantly over the past couple of years to great praise of a lot of people.

comment 5y ago · link · parent

I would guess that India is too large to meaningfully include in such a statistic. On average in the country English literacy could be quite poor while in the relevant tech hubs it is quite good. But that's just a hypothesis.

comment 5y ago · link · parent

Rust sidesteps issues like this entirely through its Editions. Code from different editions can all each other, but editions can introduce breaking changes.

For example, in Rust 2018 and earlier calling arr.into_iter() on an array type would result in an iterator over references of elements of arr (which is the expected result of .iter(), but not .into_iter()). In Rust 2021 this is fixed and arr.into_iter() will take ownership of the array and return an iterator over the values themselves. But old crates that are specified to compile using Rust 2018 will still work, and you can still call them from Rust 2021 without problems.

If the C++ committee ever wants to fix its language it must introduce such backwards-incompatible changes. With the advent of modules this should be possible, you could compile each module using different editions yet still call each other.

comment 5y ago · link · parent

> I can zoom in and see lots of different colors

If you zoom in further, you'd soon realize your screen is nothing but pure red, green and blue subpixels at varying intensities.

comment 5y ago · link · parent

PNG is lossless, so it really does.

comment 5y ago · link · parent

See also https://allrgb.com/.

comment 5y ago · link · parent

Here in the Netherlands it's the exact opposite. We have infinite water, just not a lot of space.

comment 5y ago · link · parent

> and proving that a very simple physical machine can perform any computation (Turing completeness)

Not proving, conjecturing. It's not proven until this day: https://en.wikipedia.org/wiki/Church%E2%80%93Turing_thesis

comment 5y ago · link · parent

You are completely wrong about ? in my opinion. Between it, built-in load carrying tagged enums (also known as sum types) and the built-in Result and Option types, they essentially solve the exception problem while still being entirely explicit. It's probably my favourite feature of Rust.

comment 5y ago · link · parent

Which begs the question: without the fifty-move rule (only threefold repetition), what is the longest legal chess game?

comment 5y ago · link · parent

Experimental science is all based around ruling out the null hypothesis. For that it needs to be falsifiable.

The hypothesis 'the dog can differentiate between A and B' is very hard to falsify. Because the dog could differentiate, but choose to not act. You would need a fairly complete understanding of the dogs mental workings, and scanners to study them.

On the other hand, 'the dog can't differentiate between A and B' is much easier to falsify. If you repeat an experiment a sufficient amount of times and the dog consistently has different behavior between A and B, you can rule this null hypothesis out.

That is the real reason we always 'assume the worst'. Because 'assume the worst' is the easiest to scientifically rule out.

EDIT: I would suggest this video by Veritasium, which also touches on this, at a very fundamental level: https://www.youtube.com/watch?v=vKA4w2O61Xo.

12345
27