A Sudoku Solver in APL
Channel:Dyalog · Length:9:43 · Published:2012-10-27 · Views:47334
Summary
A Dyalog demonstration of developing a Sudoku solver in APL, using an algorithm by Arthur Whitney with performance work by John Scholes. The narration steps through the array-oriented solution.
Why HN recommends it
Strongly recommended as a beautiful demonstration that APL can be read and reasoned about step by step.
I've always liked this video, where one of the Dyalog developers effortlessly writes a Sudoku solver in APL — HN, 2022
Functional programming · Algorithms & data structures
Subtitles (excerpt)
the indices of a three Vector a function for the indices of Omega to the^ 2 where Omega is three the three row three column reshape of the numbers the three row item replication and a three column item replication box denotes a function for the Box numbers of a 9x9 Sudoku puzzle we'll start with a smaller 4x4 puzzle the row column indices of a 4x4 array the join of each cell with its box number where box takes the first item of Omega to the power a half row column box numbers for each cell row column box numbers for a 4x4 puzzle itemwise comparison with a cell containing 334 there is contention where one is a member of each cell the outer product comparison with all cells is a rank four array enclosing the first two axes the shape of the shape produces a 4x4 map of 4x4 contention matrices C map denotes a function for the contention map here's a contention map for a 4x4 puzzle here is a 4x4 Sudoko puzzle with zeros representing blank squares the shape of the puzzle a contention map for the puzzle the third row second column left argument cell selection the cell item is the contention mask the puzzle again numbers in contention with a cell at 32 all numbers 1 to four without the contention numbers
On Hacker News
I've always liked this video, where one of the Dyalog developers effortlessly writes a Sudoku solver in APL: [VIDEO] — lizardactivist, 2022-03
> My point was that general programming usually looks more like writing the sorting algorithm than simply calling it. Thus, I would be more interested in seeing real examples of how the properties of J allow you to write algorithms more concisely or otherwise better. Ah - I see. Here[1] is quicksort in j. John scholes's videos are excellent and very illustrative, though they deal with apl rather … — moonchild, 2020-08
That 1975 APL demonstration is lovely. Much has been preserved in Dyalog and GNU APL - it's very interesting to see how timeless the core APL functions are. I'm very fond of a number of videos by the late John Scholes narrating APL solutions step by step, including the well-known demonstration of Conway's Game of Life in APL (0). His videos on depth-first search (1) and solving sudoku (2) are als… — paliilap, 2019-08
APL is great. If you haven't seen them, the late John Scholes did a number of absolutely beautiful demonstrations programming in APL[1], [2], [3]. [1]: [LINK] [2]: [VIDEO] [3]: [LINK] — geocar, 2019-07
I'm very much a believer in concise notation (more than most people I've worked with), but the advantages of having a name that can be unambiguously spoken are large enough to outweigh a small constant factor. I don't believe this holds up to scrutiny. APL as a language was made to be spoken, and it seems to have succeeded in that. Alan Perlis briefly touched on that in a great paper,[1] and just… — kick, 2020-03
Related videos
- Depth-first search in APL · Dyalog · 11:32
- Chris Crawford Dragon Speech "I Had a Dream" · Chris Crawford · 46:23
- Conway's Game Of Life in APL · Dyalog · 7:47
- Ruby Conf 12 - Y Not- Adventures in Functional Programming by Jim Weirich · Confreaks · 53:21
- The Soul of Erlang and Elixir • Sasa Juric • GOTO 2019 · GOTO Conferences · 42:02
- "Simple Made Easy" - Rich Hickey (2011) · Strange Loop Conference · 1:01:38
- "Making Impossible States Impossible" by Richard Feldman · elm-conf · 25:06
- William Byrd on "The Most Beautiful Program Ever Written" [PWL NYC] · PapersWeLove · 1:31:05
- The Value of Values with Rich Hickey · InfoQ · 31:43
- Why Isn't Functional Programming the Norm? – Richard Feldman · Metosin · 46:09
- Maybe Not - Rich Hickey · ClojureTV · 1:03:28
- Solving Problems the Clojure Way - Rafal Dittwald · Clojure/north · 1:02:26
- Lecture 1A: Overview and Introduction to Lisp · MIT OpenCourseWare · 1:12:55
- Lecture 1A | MIT 6.001 Structure and Interpretation, 1986 · MIT OpenCourseWare · 1:12:55
- CppCon 2017: Matt Kulukundis “Designing a Fast, Efficient, Cache-friendly Hash Table, Step by Step” · CppCon · 59:33
- Effective Programs - 10 Years of Clojure - Rich Hickey · ClojureTV · 1:14:51