TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Solving 100 Bushels using Matrix Factorization

8 pointsby RafelMri8 months ago

2 comments

vitus8 months ago
Another way to frame the brute-force solution: there are &quot;only&quot; 5151 cases when you naively consider the integral constraint and the total number of individuals.<p>Python one-liner:<p><pre><code> &gt;&gt;&gt; [(x, y, 100-x-y) for x in range(101) for y in range(101-x) if 0.5*x + 2*y + 3*(100-x-y) == 100] [(68, 30, 2), (70, 25, 5), (72, 20, 8), (74, 15, 11), (76, 10, 14), (78, 5, 17), (80, 0, 20)] </code></pre> If you want to make your state space even smaller, you can assert that at least 2&#x2F;3 of the people must be children (since 66 children + 34 women -&gt; 101 bushels, so you need at least 67 children), and you must have an even number of children to result in an integral number of bushels overall. As a result, you can replace the first `range` with range(68, 101, 2); that yields only 289 potential triples to check.<p>This is about a sixth of the number of cases as the article&#x27;s brute-force approach (33*50 = 1650).
defrost8 months ago
Earlier discussion:<p>32 points by jmount 21 hours ago | 13 comments <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=41688019">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=41688019</a>