476 karma · joined April 22, 2013
[1]: http://web.archive.org/web/20101006104124/http://blog.okcupi...
As for my answer to the question, I try to limit my charitable contributions to charities praised for efficiency and effectiveness on the various watchdog sites, but I usually end up cracking and giving in person as well.
On a related note, writing my post reminded me of an old LessWrong post [1] I saw.
[1] http://lesswrong.com/lw/6z/purchase_fuzzies_and_utilons_sepa...
EDIT: While I have your attention, do you mind also pointing me to some resources to learn about this ">>=" operator? I recall it's something related to monads...
shift v = pad
(map Just (concatMap add (group (catMaybes v)))))
Nothing
(length v)
whereas the code gives: shift v = take n (v' <> empty n)
where
n = length v
v' = group (filter isJust v) >>= go
go (Just a : Just b : ts) = Just (a + b) : go ts
go ts = ts
From my understanding of the blog post's logic, the former doesn't handle the case where `v = replicate 4 (Just 2)`, since it returns `[Just 4, Just 2, Just 2, Nothing]`. Am I correct, and if so, why does the latter version fix this problem? For reference, I know little to no Haskell.Start : (Markus: $0) (Joe: 1BTC, $200)
Step 1: (Markus: $1200) (Joe: 1BTC, $200)
Step 2: (Markus: 1BTC) (Joe: $200 + 1200)
Step 3: (Markus: $200) (Joe: 1BTC, $1200)
Assuming Markus withdraws fiat before Joe does, Mt. Gox only had $200 in real money and $1200 in fake make-believe numbers, so Joe is left unable to withdraw.
So far I've tried median-of-medians, recursive quickselect, iterative quickselect tracking indices and partitioning in place, and heapq.nlargest. The implementation in Python 3.4.0 is both cleaner/easier to read and faster than anything I can make by an order of magnitude for 10,000 element lists. I'm sure someone else here can do better than me, but (s)he'd have a hard time beating CPython, imo.