Skip to content

Instantly share code, notes, and snippets.

Kevin Lynagh lynaghk

Block or report user

Report or block lynaghk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@lynaghk
lynaghk / SketchSystems.spec
Created Apr 22, 2019
# A big and slow sketch useful for perf testing.
View SketchSystems.spec
# A big and slow sketch useful for perf testing.
A
A1 -> A2
A2 -> A3
A3 -> A4
A1
A2
A3
A4
@lynaghk
lynaghk / sketch systems grammar.md
Last active Apr 22, 2019
Sketch.systems grammar
View sketch systems grammar.md

Sketch.systems uses the wonderful Instaparse Clojure(Script) library to parse statechart specifications. Unfortunately, the current grammar is quite memory intensive and on larger specs suffers from multi-second garbage collection pauses.

Suggestions welcome!

@lynaghk
lynaghk / 1-readme.md
Created Nov 25, 2018
shipping puzzle in minizinc
View 1-readme.md

First pass at shipping puzzle in MiniZinc. See https://kevinlynagh.com/notes/shipping-puzzle/

Runs in 2.5 seconds on my 2013 macbook air. Anything more than 7 routes takes more than a few minutes (and I stopped waiting).

I tried to improve perf by breaking symmetry in the rows of routes by ordering the routes according to the first leg. (i.e., the first non-zero value in a row of routes should be less than the first non-zero value of the next row of routes) But I couldn't figure out how to do that neatly.

View legs.txt
1 LOS_ANGELES CHARLOTTE F
2 CHARLOTTE NEW_YORK W
3 NEW_YORK JACKSONVILLE F
4 JACKSONVILLE SAN_JOSE R
5 SAN_JOSE DETROIT T
6 DETROIT SEATTLE R
7 SEATTLE AUSTIN T
8 AUSTIN COLUMBUS W
9 COLUMBUS PHILADELPHIA T
10 PHILADELPHIA PHOENIX T
View gist:f6a25748ca748ddb122146eb7e2e3a3c
<statechart> = (state / <whitespace> / <comments>)+
state = comments? state-name <whitespace>? <newline> block?
transition = comments? event-name <whitespace>? <'->'> <whitespace>? state-name <newline>
<block> = indent (state / transition / <whitespace> / <comments>)+ dedent
comments = comment (<newline> comment)* <newline>
<comment> = <'#'> #".*"
@lynaghk
lynaghk / jug.als
Last active Aug 25, 2018
Another Alloy jug puzzle
View jug.als
open util/ordering[State]
sig Jug {
max: Int
}
abstract sig Op {}
sig Pour extends Op {
@lynaghk
lynaghk / SketchSystems.spec
Last active Aug 7, 2018
# Test parallel spec.
View SketchSystems.spec
# Test parallel spec.
Search Inactive
touch search bar -> Search Active
Search Active&
touch cancel -> Search Inactive
touch result -> View Result
text input -> Loading
@lynaghk
lynaghk / sudoku.als
Created Jul 18, 2018
Solving sudoku in alloy
View sudoku.als
enum V {v1, v2, v3, v4, v5, v6, v7, v8, v9}
sig Cell {
val: V,
row: V,
col: V
}
pred disjointSubgrid[rows: set V, cols: set V]{
View SketchSystems.spec
LoadingAnimation
Loading
next -> AlmostDone
AlmostDone
next -> Finished
Finished
next -> App
App
@lynaghk
lynaghk / 0_readme.md
Last active Jun 27, 2018
Solving water pouring puzzle with Alloy
View 0_readme.md

Water pouring puzzle

Given a 5 quart jug, a 3 quart jug, and unlimited supply of water, can you measure exactly 4 quarts? (The jugs are irregularly shaped, so you can't eyeball half the volume or anything like that.)

The solution involves pouring water between the jugs.

I wanted to see if I could solve this puzzle with Alloy. My first attempt (specific.als) hardcodes the two jugs as named relations. It solves the puzzle (finds a counterexample) in about 500ms.

You can’t perform that action at this time.