Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/laszlokorte/einstein_puzzle
- Owner: laszlokorte
- Created: 2023-12-22T03:19:33.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2023-12-23T16:00:47.000Z (11 months ago)
- Last Synced: 2024-04-09T23:06:25.742Z (7 months ago)
- Language: Elixir
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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"
}
])
```