A generator for 'Portia's Caskets'
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
build
imgs
js
README.md
index.html

README.md

portia

An interactive version of the classic 'Portia's Caskets' logic puzzle. See this blog post for additional details.

Generating puzzle data

Ensuring that the directory /portia/data is created and writable, the puzzle data is generated by running the Python script portia.py in the build directory.

> python portia.py

Expected output is:

-------------------------------------------
Generating Portia I data.
 --- creating file ../data/portia1.json
generated 348 puzzles
 --- completed writing out Portia I data.
-------------------------------------------
Generating Portia II data.
 --- creating file ../data/portia2.json
generated 16152 puzzles
 --- completed writing out Portia II data.
-------------------------------------------
Generating Portia III data.
 --- creating file ../data/portia3.json
generated 3600 puzzles
 --- completed writing out Portia III data.
-------------------------------------------

Each puzzle type has its own format:

Portia 1

{
  "caskets": [1,2,2],
  "truths": 0,
  "solution": 3,
  "position": "min",
  "id": "portia1-20"
}

Portia 2

{
  "caskets": [[1,1,3],[-1,-3,-3]],
  "truths": [1,0,1],
  "solution": 3,
  "id": "portia2-358"
}

Portia 3

{
  "caskets": [[1,1,2],[3,1,-2]],
  "truths": [0. 0, 0],
  "solution": 3,
  "id": "portia3-24"
}

Solving the Puzzles

You can interact with the puzzles using the page index.html, a live version of the page is found here.