Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/laszlokorte/einstein_puzzle

Einstein Puzzle Solver in Elixir
https://github.com/laszlokorte/einstein_puzzle

Last synced: about 19 hours ago
JSON representation

Einstein Puzzle Solver in Elixir

Awesome Lists containing this project

README

        

# EinsteinPuzzle

Einstein Puzzle Solver

## Run the Example

```sh
mix run -e 'Example.run'
```

## Example output

```elixir
EinsteinPuzzle.solve([
zelle: [1, 2, 3, 4, 5],
name: ~w(Henry James Ian John Ducan),
trinkt: ~w(Tee Wein Wodka Bier Scotch),
sport: ~w(Golf Solitär Poker Basketball Fußball),
waffe: ~w(Säbel Buschmesser Axt Flinte Pistole),
farbe: ~w(Rot Grün Gelb Blau Weiss)
], [
[name: "Henry", farbe: "Rot"],
[name: "James", waffe: "Säbel"],
[trinkt: "Wein", farbe: "Grün"],
[name: "Ian", trinkt: "Tee"],
[sport: "Golf", waffe: "Buschmesser"],
[sport: "Solitär", farbe: "Gelb"],
[trinkt: "Wodka", zelle: 3],
[name: "John", zelle: 1],
[sport: "Basketball", trinkt: "Bier"],
[name: "Ducan", sport: "Fußball"],
], [
{:farbe, "Grün", :farbe, "Weiss", :zelle, &EinsteinPuzzle.right_of/2},
{:sport, "Poker", :waffe, "Axt", :zelle, &EinsteinPuzzle.next_to/2},
{:sport, "Solitär", :waffe, "Flinte", :zelle, &EinsteinPuzzle.next_to/2},
{:name, "John", :farbe, "Blau", :zelle, &EinsteinPuzzle.next_to/2},
{:trinkt, "Scotch", :sport, "Poker", :zelle, &EinsteinPuzzle.next_to/2},
]) # => MapSet.new([
%{
farbe: "Gelb",
zelle: 1,
name: "John",
trinkt: "Scotch",
sport: "Solitär",
waffe: "Axt"
},
%{
farbe: "Blau",
zelle: 2,
name: "Ian",
trinkt: "Tee",
sport: "Poker",
waffe: "Flinte"
},
%{
farbe: "Rot",
zelle: 3,
name: "Henry",
trinkt: "Wodka",
sport: "Golf",
waffe: "Buschmesser"
},
%{
farbe: "Weiss",
zelle: 4,
name: "James",
trinkt: "Bier",
sport: "Basketball",
waffe: "Säbel"
},
%{
farbe: "Grün",
zelle: 5,
name: "Ducan",
trinkt: "Wein",
sport: "Fußball",
waffe: "Pistole"
}
])
```