frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Open in hackernews

My Mathematical Regression

https://blog.dahl.dev/posts/my-mathematical-regression/
53•aleda145•3d ago

Comments

ogogmad•1h ago

  me@localhost:~> bc
  d=1; for(i=21; i < 41; i++){d *= i;}; print d; print "\n";
  335367096786357081410764800000
  n = 1; for(i = 1; i < 21; i++){n *= i;}; print n; print "\n";
  2432902008176640000
  d/n;
  137846528820
I couldn't start Python for some reason, so I went 1337 and used BC, which comes preinstalled in every Unix-like OS. BC has a surprising advantage here since 40!/20! cannot be represented as a 64-bit integer since its value exceeds 2^64. That said, BC's stdlib does not provide the factorial function* - so I had to resort to for-loops instead.

* - What it does contain is sine, cosine, exponential, log, arctan, and Bessel J (?!?!?!?!)

qsort•36m ago
You don't need space for 40!/20!, for example:

  let ans = 1
  for (let i=1; i<21; ++i) {
    ans *= (41 - i)
    ans /= i
  }
The same idea can be trivially tweaked to compute any binomial coefficient without ever storing an integer greater than the final result.
ogogmad•9m ago
Good point. But what if `i` does not divide `ans` evenly? I suppose you could use floats and then round.
mb7733•1h ago
An intuitive motivation for the solution in the article (2n choose n). For an n*n grid you have to you will take 2n steps, n "over" and n "down". All that matters is the order of the steps. So if you think of there being 2n "slots", you have to pick n to be "over", and the rest are forced to be "down". So it's n choose 2n indeed.

You can also think of it another way, without using the formula combinations, and only the fact that there are n! permutations of n objects. We can think of this a permutation of 2n items, made up of two groups of n identical items each. Using (2n!) will overcount, due to the fact that each of the "over" steps are identical, and similarly for the "down" group. We have cut down our answer by dividing out all of the repeated sequences. There will be n! redundancies for all the ways we can permute the "over" group and, the same for the "down" group. So this results in (2n!) / (n! * n!), which is exactly equal to 2n choose n. See [1] which explains permutations with repetion this in general. [Note: We pretty much re-derived the formula for combinations!]

[1] https://brilliant.org/wiki/permutations-with-repetition/

aeve890•1h ago
Ha. When I found that problem I draw the grids and paths from the example, left for a coffee and when came back I just look at the drawings at an angle and thought "well this is just Pascal's triangle". And the solution was obvious.
the_red_mist•52m ago
Tbh your student reasoning is still dangerous... the patterns could have not generalized nicely. see moser's circle problem

needed to justify viewing this as "arranging down vs right movements" as another comment outlines

floppyd•50m ago
Noticing a pattern and just extending it without proving why it works is not really a solution. You can prove it without really "understanding" it using induction, but that still would be proof, same as just counting on a computer.
jp57•49m ago
I think one of the saddest thing is that the kind of person who would recognize, "we can solve this seemingly complicated problem by just applying this formula", would often have trouble even getting recognized in many corporate environments.

I managed a guy like that. He was capable of very complex thinking, but he wasn't in love with complexity, he was in love with simplicity. His solutions tended to be of the form, "we can ignore all these things, and just focus on X, and it will provide all the value." He'd notice something and simplify it and the benefit to the company would be measured in multiples of his salary.

Every manager who'd ever directly managed him knew what a treasure he was, but it was often hard for us to convince others of the value of his solutions because they were so simple, and people were convinced that hard problems must have complex solutions. (or else they would have solved them, right?)

He eventually got bored. He retired and joined a seminary.

xg15•37m ago
I imagine this is where the reputation of a good manager comes in and the ability to say to their boss "hey, we should keep this guy... just trust me on this."
cocoto•43m ago
Even if you don’t know or remember the basics of combinatorics you can solve the problem with basic dynamic programming : start with the unit grid and then expend it.
Mainan_Tagonist•29m ago
The more i think about math these days, the more i see it as a muscle one must constantly train to achieve its potential.

Give it too long a rest and you have to go back at full blast for weeks on end to hope to ever achieve past performance.

I am very bad at math and have always been in awe of those who can do it well.

purple-leafy•27m ago
Heh, this grid image is all too familiar to me right now.

I’m building a grid based game and engine, and I have a game replay format which is not video.

I hit a massive wall with compression, trying to compress unit pathing and was trying to solve a similar solution.

Given an NxN grid, and the 4 cardinal directions (NSEW) you can move in, plus an extra action that makes you move 2 cells instead of 1, and considering you can move 4 cells per second…

What’s the smallest worst-case raw compression artefact you can output for 1 player for a 1 minute game?

It’s an extremely fun problem to solve. I tried:

- encoding changes into bits eg using 2 bits for direction

- movement pattern batching (ie batching 2 moves into 3 bits)

- crowd patterns and movement prediction

- treating movement as a “projectile” and deriving intermediate states

And all sorts of other wild crap that I will write up about on game launch

tux3•18m ago
What a lot of games do is run a strictly deterministic simulation in lockstep. Then you don't save the path of every unit, you save one move command for the whole group. Then the game replays inputs, and the pathing algorithm should give the same result if there are no desyncs.
purple-leafy•13m ago
Yes you are definitely onto something! Love to see more people talking about deterministic games.

My game is strictly deterministic, so I get bot movement for free - but the player has agency so I need to capture their deviations

That’s the tricky part! Right now I do capture input (actually just deviations) and can replay whole games, but I think I’m at the limits in terms of compression - talking bytes here not KB

Steam Machine

https://store.steampowered.com/hardware/steammachine
434•theschwa•2h ago•408 comments

My Mathematical Regression

https://blog.dahl.dev/posts/my-mathematical-regression/
58•aleda145•3d ago•14 comments

Moebius: 0.2B image inpainting model with 10B-level performance

https://hustvl.github.io/Moebius/
146•DSemba•5h ago•38 comments

Deno Desktop

https://docs.deno.com/runtime/desktop/
916•GeneralMaximus•13h ago•339 comments

Show HN: Oak – Git replacement designed for agents

https://oak.space/oak/oak
73•zdgeier•3h ago•85 comments

Nintendo Wii U games running from a 1980's Bernoulli disk [video]

https://www.youtube.com/watch?v=8GZDOpV2OXk
53•zdw•23h ago•22 comments

Bain tests software takeover targets by vibecoding AI replicas

https://www.ft.com/content/e5bac4d1-b1f8-43a4-bd54-b182d5357af0
20•macleginn•4h ago•35 comments

Codex logging bug may write TBs to local SSDs

https://github.com/openai/codex/issues/28224
383•vantareed•11h ago•211 comments

Pledging another $400k to the Zig software foundation

https://mitchellh.com/writing/zig-donation-2026
595•tosh•5h ago•192 comments

Finding the Best Dog Treat with Statistics

https://www.wespiser.com/posts/2026-06-19-best-dog-treat.html
25•wespiser_2018•1h ago•4 comments

Charge Robotics (YC S21) Is Hiring Software and Hardware Engineers

https://jobs.ashbyhq.com/charge-robotics
1•justicz•2h ago

GLM 5.2 vs. Opus

https://techstackups.com/comparisons/glm-5.2-vs-opus/
410•ritzaco•12h ago•280 comments

The text in Claude Code’s “Extended Thinking” output

https://patrickmccanna.net/the-text-in-claude-codes-extended-thinking-output-is-not-authentic/
214•0o_MrPatrick_o0•4h ago•158 comments

Prompt Injection as Role Confusion

https://role-confusion.github.io
76•x312•3h ago•42 comments

Die analysis of the 8087 math coprocessor's fast bit shifter (2020)

https://www.righto.com/2020/05/die-analysis-of-8087-math-coprocessors.html
56•Jimmc414•5h ago•9 comments

DisplayMate

https://www.displaymate.com/
41•skibz•2h ago•13 comments

Blogger defeats photographer's copyright claim

https://blog.ericgoldman.org/archives/2026/06/blogger-defeats-photographers-copyright-claim-sokol...
30•speckx•2h ago•9 comments

Mexican government unveils a prototype for a new homegrown, ultra-affordable EV

https://gizmodo.com/mexico-just-showed-off-a-new-extremely-cheap-government-backed-ev-2000769080
88•speckx•2h ago•50 comments

window.showDirectoryPicker opens up a whole new world

https://steveharrison.dev/showdirectorypicker-opens-up-a-whole-new-world/
81•steveharrison•6h ago•82 comments

Show HN: Got sick of ads, so I made my own logic puzzle site

https://puzzlelair.com/
80•HaxleRose•6h ago•69 comments

Help I accidentally a wigglegram

https://lmao.center/blog/wiggle-accidents/
440•gregsadetsky•2d ago•113 comments

NSF slashes research programs to support new tech initiative, insiders say

https://www.science.org/content/article/exclusive-nsf-slashes-research-programs-support-new-tech-...
108•strangeloops85•2h ago•45 comments

Alan Greenspan has died

https://www.washingtonpost.com/obituaries/2026/06/22/alan-greenspan-most-powerful-central-banker-...
154•helsinkiandrew•7h ago•161 comments

Chevron signs 20-year power agreement with Microsoft for West Texas data center

https://www.chevron.com/newsroom/2026/q2/chevron-signs-20-year-power-agreement-with-microsoft-for...
79•cdrnsf•5h ago•73 comments

Granularity comes at a cost

https://www.sidhantbansal.com/2026/Granularity-comes-at-a-cost/
40•sidhantbansal•3d ago•6 comments

Show HN: CleverCrow: give tokens to your favorite projects

https://clevercrow.io
42•zhubert•1d ago•62 comments

There is minimal downside to switching to open models

https://www.marble.onl/posts/cancel_claude.html
370•amarble•22h ago•298 comments

DHL Set to Transport Goods on New Wind-Powered Cargo Ships

https://www.wsj.com/pro/sustainable-business/dhl-set-to-transport-goods-on-new-wind-powered-cargo...
106•julienchastang•4h ago•44 comments

Show HN: Selector Forge – browser extension for AI-generated resilient selectors

https://github.com/Intuned/selector-forge
23•ahmadilaiwi•5h ago•0 comments

Munich 1991: The Roots of the Current AI Boom

https://people.idsia.ch/~juergen/ai-boom-roots-munich-1991.html
192•tosh•3d ago•87 comments