Live data from Hacker News

Arthur Whitney's one liner sudoku solver (2011)

dfns.dyalog.com

31–40 of 210 posts

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

#31
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?

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

#33
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…

It probably isn't. At least, not for Python.

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

#34

Earlier quoted context omitted.

As a kdb+/Q programmer I would say it depends on the type of problem. For example, when working with arrays of data it certainly is easier to think and write “avg a+b” to add two arrays together and then take the average. In a non-array programming language you would probably first need to do some bounds checking, then a big for loop, a temporary variable to hold the sum and the count as you loop over the two arrays,…

Well no, not in a non-array programming language. In any language that has a semi-decent type/object system and some kind of functional programming support, `avg a+b` would just be `avg(a, b)`, which is not any easier or harder, with an array type defined somewhere. Once you make your basic array operations (Which they have to be made in q anyways, just in the stdlib), you can compose them just like you would in q, a…

Why would it be avg(a, b)?

What if I want to take the average difference of two arrays?

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

#37
post #14
post #9

Earlier quoted context omitted.

Meta: No need to DV a comment you don't like for no reason. Engage instead. Why not have a chat?

People are saturated with anger and frustration after doom scrolling. They engage with their pitchforks.

A few anonymous downvotes are what qualifies as pitchforks these days?

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

#38
post #9

Earlier quoted context omitted.

Meta: No need to DV a comment you don't like for no reason. Engage instead. Why not have a chat?

Wouldn't it be more productive/rewarding to instead engage with comments I do like?

Only you can say what's best for you.

If have to ask: What's rewarding about only having your viewpoint reinforced?

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

#39
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?

[deleted]
Post reply on HN