2026
Some Klong programs 2026.06.20
I've been playing around with the Klong interpreter, here are some simple programs:
Euler Problem 3
The objective is to find the largest prime factor of 600851475143.
Here is a straightforward approach:
{|/{x@(y!x)?0}({x@({#x?0}'+x!:\x)?2}(1+!x);x)}
(Create a matrix of 1..n modulo every element of 1..n, transpose the matrix, find every row with exactly two cases where this is zero, expand row indices to values in 1..n, filter for cases where modulo against n is zero)
There is of course a significantly more time and space efficient solution, but it's a little bit longer:
{|/{x@(y!x)?0}([2]{:[#(y!x)?0;x;x,y]}/3+!x-2;x)}
Euler Problem 4
The dyad ps will find the largest palindrome product composed from two x digit natural numbers in base y.
ps::{[b r];b::y;r::(b^x-1)_1+!(b^x)-1;|/{[r];r:::[b~10;$x;{(_x%b^y)!b}(x;!1+_log(b;x))];x*r~|r}'?,/r*:/r}
A projection for base 10 would be ps(;10).
Euler Problem 5
Find the smallest natural number evenly divisible by all numbers 1 through 20 using prime factorization. (Executes in 91ms)
p::{[2]{:[#(y!x)?0;x;x,y]}/3+!x-2}
f::{[t d];t::*(x@(y!x)?0),1;d::_y%t;:[t~1;,y;:[@x?d;t,.f(x;d);t,d]]}
m::{[r];r::f(p@3|_x^1%2;x);{(*r@x),#x}'=r}
s::{*/,/{(*x)^1_x}':{}{:[:_x?*y;x,y;x,(*y),(x?*y)|1_y]}/,/m'1+!x}
.p(s(20))
Euler Problem 6
Find the difference between the sum of the squares of the first 100 natural numbers and the square of the sum.
{(x*(2*x^2)+(3*x^3)-2+3*x)%12}@100
This approach uses the formulae for triangular and square pyramidal numbers.
Move-to-front transform
Monads to perform and reverse the well-known move-to-front transform on a sequence of octet values (array of integers 0-255).
mtf::{[a];a::!0xff;[] {[i t];i::a?#y;t::((i,i+1):_a);a::,/t@[1 0 2];x,i}/x}
rmtf::{[a];a::!0xff;,/:#'[] {[i t];i::a@y;t::((y,y+1):_a);a::,/t@[1 0 2];x,i}/x}
Old notes 2026.06.11
I ended up adding some of the aforementioned old notes from 2023 back. I filtered out the social commentary and a few of the less interesting technical posts, because I decided they would not be of use to anyone.
The article describing my FWH/LPC/SPI multi-tool is now done, too.
Untitled 2026.06.08
No matter how much expertise you have, there will never come a time when you don't have to deal with people whose thought patterns reduce to "Wow, you're so intelligent" followed soon after by "But you know, you're really an idiot when you disagree with me."
First post 2026.06.08
Here is the first post of Webbit's new micro-blogging system. It's quite nifty; I can insert thoughts and observations here, in CommonMark-compliant Markdown, at the end of a file corresponding to each year. You can imagine something a little like a log file, only for humans.
Anything not worthy of a proper article can go here. I wrote a similar system like this for an older web-site, but the new Webbit infrasturcture makes it a lot less fragile and cumbersome to use. (Who knows, I am hardly immune to rewriting everything a third fourth time...)
Maybe I'll consider migrating the old posts and inserting them before this one...