Live data from Hacker News

Arthur Whitney's one liner sudoku solver (2011)

dfns.dyalog.com

51–60 of 210 posts

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

#52
post #13

Earlier quoted context omitted.

From the linked page (and the one linked beyond that), it's a breadth-first search actually. Keep a list of possible puzzle states at all times, pick a blank cell (theoretically arbitrary, but in practice intelligently for performance), add copies of the state with each possibility for that state added.

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.

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

#53
post #21

I'll sometimes gauge code complexity by comparing the number of lines of code against the output of tar -cf - . | gzip | base64 | wc -l IE "how much does it compress?" Looking at APL -- I'm reminded of what happens if I accidentally send the gzipped output to my tty... I'm impressed that there's anyone who can follow along (can you find the bug?) to code like p←{(↑⍵)∘{(⍺∨.=⍵)/⍳n×n∘}¨,⍵},(n*÷2){⍵,⍺⊥⌊⍵÷⍺}'⍳n n←⍴⍵ It re…

Legitimately curious how APL programmers think about maintainability and readability. Is code just thoroughly commented or otherwise documented?

I suspect that if you're fluent in the language, understanding an expression written in it comes just as easily and quickly as reading a sentence in a book does to me.

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

#54
post #21

I'll sometimes gauge code complexity by comparing the number of lines of code against the output of tar -cf - . | gzip | base64 | wc -l IE "how much does it compress?" Looking at APL -- I'm reminded of what happens if I accidentally send the gzipped output to my tty... I'm impressed that there's anyone who can follow along (can you find the bug?) to code like p←{(↑⍵)∘{(⍺∨.=⍵)/⍳n×n∘}¨,⍵},(n*÷2){⍵,⍺⊥⌊⍵÷⍺}'⍳n n←⍴⍵ It re…

Legitimately curious how APL programmers think about maintainability and readability. Is code just thoroughly commented or otherwise documented?

i've only seen these style of languages commented after a contest is over on stack programming challenges. I have no idea how one would learn all this stuff from code in the wild (like i learned most of python, for example). then again, i don't go searching github for k, apl, or perl for that matter.

I'm sure each of those languages makes some guarantee about the sorts of errors that can be introduced - as opposed to C (let me pick on it) where the errors you know you can introduce, and the errors that are introduced aren't a large union. However i have a hard enough time typing english consistently, so the various "symbol-y" languages just glaze my eyes, unfortunately.

It almost "feels" like these languages are an overreaction to the chestnut "they must get paid by LoC".

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

#56
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.

I don't particularly enjoy sudoku but I like word puzzle games.

They're all artificial problems, but your brain likes a challenge and you get a dopamine hit when you solve it, I suppose.

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

#57
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.

For me personally, I have little motivation to do classical sudokus. They either have a not-so-elegant solve path (usually set by a computer) or are too difficult for me to solve.

Variant sudokus on the other hand are a lot of fun. They often have very elegant solve paths and there are many neat tricks you can discover and reason about.

Some fun ones, if you'd like to try:

- https://logic-masters.de/Raetselportal/Raetsel/zeigen.php?id...

- https://logic-masters.de/Raetselportal/Raetsel/zeigen.php?id...

- https://logic-masters.de/Raetselportal/Raetsel/zeigen.php?id...

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

#58
Most people are put off by the symbols, that wasn't really the issue I had.

So I do love APL and arraylangs, and learning them was really helpful in a lot of other languages.

But they never became a daily driver for me not because of the symbols, which were honestly fine if you stick with it long enough, but after about 3-4 years of dabbling on and off I hit a wall with APL I just couldn't get past.

Most other languages I know there is a "generic-ish" approach to solving most problems, even if you have to cludge your way through suboptimally until you find "the trick" for that particular problem and then you can write something really elegant and efficient.

APL it felt like there was no cludge option -- you either knew the trick or you didn't. There was no "graceful degredation" strategy I could identify.

Now, is this actually the case? I can't tell if this is a case of "yeah, thats how it is, but if you learn enough tricks you develop an emergent problem solving intuition", or if its like, "no its tricks all the way down", or if its more like, "wait you didn't read the thing on THE strategy??".

Orrr maybe I just don't have the neurons for it, not sure. Not ruling it out.

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

#59

I’ve often wondered about languages like APL/k, are the programmers actually able to think about problems more efficiently?

I went to this tech talk on Dyalog (a modern APL-like language), and the speaker makes the argument that the notation allows certain idioms to be recognized more easily:

https://youtu.be/PlM9BXfu7UY?si=ORtwI1qmfmzhJGZX&t=3598

This particular snippet was in the context of compilers, but the rest of the talk has more on Dyalog and APL as a system of mathematical notation. The underlying theme is that optimizing mathematical expressions may be easier than optimizing general code.

Post reply on HN