From: Zachary Vance Date: Tue, 10 Nov 2026 03:08:35 +0000 (-0500) Subject: Hack-a-day 2026 X-Git-Url: https://git.za3k.com/?a=commitdiff_plain;h=6bec147fcad3c42aca08816d2d49b8ec61469b6e;p=blog.git Hack-a-day 2026 --- diff --git a/posts/hack2026-asm.md b/posts/hack2026-asm.md new file mode 100644 index 0000000..137c3c1 --- /dev/null +++ b/posts/hack2026-asm.md @@ -0,0 +1,35 @@ +--- +author: admin +categories: +- technical +date: 2026-11-05 +tags: +- hack-a-day +title: "Hack-a-Day, Day 05: Assembly Coding" +--- + +Whew, hey everyone. Yes, hack-a-day is happening this year! I was a few days late starting (out of state), and then I did an assembly programming project! But then I promptly got a nasty bug and was laid up in bed for four days. Not a fast start! But that's okay, I'm feeling good. + +I'm thinking this year will be AI-light to AI-none. Last year it was novel for me, this year I want a break from it. And really, hack-a-day is about learning and flow for me, as much as shiny demos. + +On day 5, I decided to learn some X86-64 assembly coding. AI help was limited to an assembly cheatsheet (I didn't know assembly), and some final bugfix help after I got sick, since I was over my 1-day budget. + +The problem is to solve the following equation using positive integers. As far as I know it doesn't have a specific name, although it has a short [lineage](https://en.wikipedia.org/wiki/Diophantine_equation): Euler conjectured no solutions, Elkies found infinitely many solutions, and Frye found the smallest by computer search. + + x^4 + y^4 + z^4 = w^4 + +We're given the hint that there is exactly one solution with all numbers less than 1 million. I'll avoid posting the answer here, but you can find it if you follow the wikipedia link above. + +The algorithm I'm using was worked out by me and Kragen Javier Sittaker (mostly Kragen), although it's been long enough I had to reinvent it. It turns out it's the same one that Frye used to solve it originally, in 1988 -- although he used a parallel implementation I don't know the details of. + +Brute force search doesn't work -- one million times one million, times one million, times one million, is too many possibilities to try (10^24). So instead we make two lists, one of numbers x^4 + y^4 (in sorted order), and one of numbers w^4 - z^4 (in sorted order). And then it's easy to see if they're ever equal. Of course, those would be lists of a trillion things, so we can't make them either. We use a priority heap of a million elements, instead. + +For fast testing, we hint the solver has to the right bounds for X, Y, etc. For me it takes about 4 hours for the full run. + +I'm happy I got this to work! I'm sure my assembly isn't the best, since it's about my second assembly program, but I learned a little about x86 and about the intel syntax and nasm macros. + +Python and x86-64 assembly versions both [on github](https://github.com/za3k/hack2026-asm). + +Next project will be something a little more chill. + +Happy hacking! diff --git a/template.md b/template.md index 27f04d3..06e1505 100644 --- a/template.md +++ b/template.md @@ -2,8 +2,8 @@ author: admin categories: - Uncategorized -date: 2026-??-?? +date: 2026-11-?? tags: -- untagged -title: TITLE +- hack-a-day +title: "Hack-a-Day, Day XX: TITLE" ---