Skip to content

Instantly share code, notes, and snippets.

import Dict
indexed: [a] -> Dict.Dict Int a
indexed list = Dict.fromList (zip [0..(length list)] list)
type Palette = Dict.Dict Int Color
makePalette: [Color] -> Palette
makePalette colors = indexed colors
@skybrian
skybrian / sudoku2.dart
Created August 12, 2013 07:07
An optimized version of sudoku.dart that runs 8x faster.
// Solve Every Sudoku Puzzle in Dart, optimized version
// A translation of: http://norvig.com/sudopy.shtml
// Translated and optimized by Brian Slesinsky
// See http://norvig.com/sudoku.html
// Throughout this program we have:
// r is a row, e.g. 'A'
// c is a column, e.g. '3'
// s is a Square, e.g. 'A3'
@skybrian
skybrian / sudoku_output.txt
Last active December 20, 2015 21:59
Performance tests comparing sudoku.py with sudoku.dart
Python
------
$ python sudoku.py
All tests pass.
Solved 95 of 95 hard puzzles (avg 0.02 secs (47 Hz), max 0.10 secs).
Solved 11 of 11 hardest puzzles (avg 0.01 secs (130 Hz), max 0.01 secs).
Solved 99 of 99 random puzzles (avg 0.01 secs (155 Hz), max 0.02 secs).
Macintosh:~/dart/sudoku/bin skybrian
$ python sudoku.py
@skybrian
skybrian / sudoku.dart
Last active December 20, 2015 20:38
A line-by-line translation of Peter Norvig's Sudoku solver into Dart.
// Solve Every Sudoku Puzzle in Dart
// A translation of: http://norvig.com/sudopy.shtml
// Translated by Brian Slesinsky
// See http://norvig.com/sudoku.html
// Throughout this program we have:
// r is a row, e.g. 'A'
// c is a column, e.g. '3'
// s is a square, e.g. 'A3'