2 ms·
The algorithm only requires 12 holes, and scales the number of holes logarithmically. As opposed to make one group per unit, which scales the number of groups l
by pacala 13y ago
The algorithm only requires 12 holes, and scales the number of holes logarithmically. As opposed to make one group per unit, which scales the number of groups linearly. Less holes, less work, win.
If you squint your eyes a bit, you can even imagine where this comes from. To avoid creating too many holes, you start with a group of 7 stones, then double them, then again, until you "double" them 34 times. Obviously 34 is not a power of two, so you need some extra machinery to make it work for non powers of two.
- VLM 13y agoI have an algorithm that only takes 7 holes compared to your 12 which is seven bucks per sheep means make seven holes and shove 34 sheep into each money hole then count the total. Its an interesting Sunday morning to rack my brain trying to figure out which algorithm "wins" when parallel processed. Obviously 34 shamans working together could each count out seven dollars/rocks, but someone needs to count up all those rocks. There's an obvious token passing algorithm involving three shamans and I believe 7+34=41 rocks and 4 holes where one does a long count of the total and count++ every time upstream hands him a rock, then upstreams upstream does the same. So one dude counts to 34 using 34 rocks one time, the next dude counts to 7 (and does it 34 times) using 7 rocks, and the last dude counts every time dude 2 hands him a rock and never resets to zero (at least until done) giving him a total. You can tell scientists invented the original algorithm not engineers just by a simple observation of actually implementing the algo... "Yo shaman come over and mult 7 by 34 for me" "OK but how many rocks will I need to multiply this... do me a favor and whip out your iphone and google 7 asterisk 34 so I know a lower bound of how many rocks to bring to implement this algo.." The worst part of the whole discussion is it reads like a really extraordinarily bad stereotypical tech interview question. "So, I see you've got extensive experience on the job with Scala and Mysql and play framework, thats all very nice, but a major problem we often have here at BigCorp is sometimes we want to measure precisely 4 oz of rum but we only have a 3 oz and 5 oz cup and we were wondering what you thought of that ..." You know some kind of space alien anthropologist is going to hear this is how those ancient "humans" used to select their programmers and the space aliens who hear pop sci stories about human programmer interviews are going to think 1) We were insane/stupid 2) They're superior. Theres not much other reason for the whole story.
- anextio 13y ago> I have an algorithm that only takes 7 holes compared to your 12 which is seven bucks per sheep means make seven holes and shove 34 sheep into each money hole then count the total. Good thing for the shaman's job security that there are more numbers that can be multiplied than 7 and 34, then. Try multiplying 34x34. For large multiplications, using the method described uses a logarithmically smaller working space in a society where positional numbers didn't exist and paper was rare, expensive, or nonexistent.