Live data from Hacker News

Arthur Whitney's one liner sudoku solver (2011)

dfns.dyalog.com

81–90 of 210 posts

Re: Arthur Whitney's one liner sudoku solver (2011)

#81
post #77
post #75

Earlier quoted context omitted.

Personally I believe it is interesting since it shows the current state of the art for the 3 LLMs. I was surprised that Claude was able to identify the language and explain the code. But, please feel free to downvote my comments. I guess the aggregate in the end will demonstrate whether it was a useful comment or spam + bullshit GPT slop.

It wasn't able to explain the code, it was wrong.

Perhaps you’ll be kind enough to post the explanation as a top level comment.

It’ll certainly help those of us who do not know K.

Re: Arthur Whitney's one liner sudoku solver (2011)

#82
post #55

Does anyone have any thoughts on what motivates people to play sudoku or write solvers for sudoku ? I have trouble finding motivation to solve artificial problems. That said I sink hundreds of hours into factorio.

Like many puzzles, there’s a regular release of endorphins as you progress, and a lot of satisfaction in completing something. I enjoy puzzles just like reading a book or playing a game, it’s another world I can step into for a bit of an escape, but I like to think it’s decent mental exercise. Overall I vastly prefer cryptic crosswords where solving each clue genuinely brings a smile to my face, but that’s more of a commitment of time (and for me sometimes a guarantee of frustration). I also like doing puzzles in the newspaper because me and my kids can sit together and all contribute. Coffee, breakfast, sat in the sun with a newspaper and a good pencil[1], absolute bliss if you ask me.

As for solvers, it’s a very elegant, well-formed problem with a lot of different potential solutions, many of which involve useful general techniques. I used to dabble clumsily in chess engines and honestly it’s the only time I’ve ever ended up reading Knuth directly for various bit twiddling hacks, so it’s always educational.

1: https://musgravepencil.com/products/600-news-wood-cased-roun...

Re: Arthur Whitney's one liner sudoku solver (2011)

#83
post #36

Earlier quoted context omitted.

To be fair K is a real language that's used by more than just him. Why array languages seem to gravitate to symbol soup that makes regex blush I'll never know.

[flagged]

Array language have been around far longer than any "HN crowd".

Re: Arthur Whitney's one liner sudoku solver (2011)

#84
post #24
post #20

Earlier quoted context omitted.

“Expressive” = like two cats fought while standing on the keyboard

I work with it daily in a bank, and I couldnt find a better way to express it. Many colleagues throwing their keyboard in despair at this stupid impossible to remember syntax.

Not that it's impossible to remember, bit it's definitely contrary to most traditional use of the symbols employed in it, though not without logic. My favorite is the functions from io package, called 0, 1, and 2 (yes, numbers) which handle interaction with stdin, stdout, and stderr respectively. In dyadic form they at least have a colon, but in monadic form they look like plain numbers: 1 "Hello world".

I suspect that to study k (and use kdb) efficiently, you need to actively forget what you knew about the syntax of other languages, and study k as a language from Mars that happens to map to ASCII characters somehow.

Re: Arthur Whitney's one liner sudoku solver (2011)

#85

Earlier quoted context omitted.

"Debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?" — Kernighan, Brian. The Elements of Programming Style (2e) . McGraw-Hill, 1978.

By becoming even more clever: https://www.linusakesson.net/programming/kernighans-lever/in...

It's a nice interpretation.

I prefer a different approach: "smart is good; clever isn't smart". If you have to express something in a clever, that is, highly contrived but actually working way, it means that you lack the right way to express it, and maybe your mental model of the problem is not that good. The theory of epicycles is clever; Kepler's laws are smart.

Re: Arthur Whitney's one liner sudoku solver (2011)

#86
post #69

Earlier quoted context omitted.

"Debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?" — Kernighan, Brian. The Elements of Programming Style (2e) . McGraw-Hill, 1978.

> how will you ever debug it? By being so smart that your program has obviously zero bugs in it!

This view is too static.

That is not possible, because the environment can (and at some point always will) change which wasn't planned for due to a lack of working crystal balls. Data, user behavior, the network, the system(s) the software runs on can all change over time.

Also, it is way too expensive to try to cover every single conceivable possibility, so we deliberately leave holes.

For non-trivial things we often prefer to wait to see what problems actually come up during use, and then fix exactly those, but not the many more problems that could come up but are too unlikely and/or too costly to guard against.

In a living environment the software lives too, and keeps changing and adapting.

Re: Arthur Whitney's one liner sudoku solver (2011)

#87
post #24
post #20

Earlier quoted context omitted.

“Expressive” = like two cats fought while standing on the keyboard

I work with it daily in a bank, and I couldnt find a better way to express it. Many colleagues throwing their keyboard in despair at this stupid impossible to remember syntax.

It is really easy to remember; it is so small that remembering is the least of the issue. The rest is just using it a lot; I find it readable and nice to work with. Unlike other some other languages we get shoved down your throats.

Re: Arthur Whitney's one liner sudoku solver (2011)

#88

Earlier quoted context omitted.

That sounds like 100+ lines in python or similar languages…

You should be able to do it in under 20 lines using the same matrix operations as the K code via numpy.

Numpy is indeed very apl. Just more horrible to me; not python-y and annoyingly verbose for the apl-er.

Re: Arthur Whitney's one liner sudoku solver (2011)

#89

Earlier quoted context omitted.

By becoming even more clever: https://www.linusakesson.net/programming/kernighans-lever/in...

Very unconvincing. If you become cleverer you can just write even more clever code and still not be able to debug it.

Great!

Re: Arthur Whitney's one liner sudoku solver (2011)

#90
Lines of code is a poor metric, because languages use lines differently.

A much better measure would be the number of nodes in a parse tree, of semantically meaningful non-terminals like "a constant" or "a function call".

An even better measure would also involve the depth and the branching factor of that tree.

Post reply on HN