You can find the blog post in which I share my line of thought here:
https://j19sch.github.io/blog/2019/solving-black-box-puzzle-31-with-data-analysis/
James Lyndsay has created a number of BlackBox Puzzles. Puzzle 31 is one of the puzzles with both a GUI and an API.
When exploring a BlackBox Puzzle through the GUI, you start from the input, observe the output, and try to find a pattern. Based on that pattern you form one or more hypotheses, which feedback into your exploration.
Using the API, however, allows you to get the output for all possible combinations of inputs (there are 512 for puzzle 31). Or rather, it allows you to do so more easily than through the GUI. Once you have that dataset, you can explore it starting from the output, from a range of inputs, etc.
Disclaimer: I knew the simple principle this puzzle adheres to before looking into this API/data analysis approach.
get_it_all.py
: get the output for all possible input combinations and write it to the csv filepuzzle31.csv
puzzle31.csv
: all input combinations and their outputpuzzle31.ods
: LibreOffice Calc sheet using tables, conditional formatting and filters to solve the puzzlepuzzle31.ipynb
: Jupyter notebook, run withjupyter notebook puzzle31.ipynb
- Install Python 3
- Create a virtual environment:
python -m venv venv
orpython3 -m venv venv
- Activate the virtual environment: (linux/mac)
source ./venv/bin/activate
or (win)venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- https://www.dataquest.io/blog/jupyter-notebook-tips-tricks-shortcuts/
- https://pandas.pydata.org/pandas-docs/stable/reference/frame.html
- https://github.com/jupyter/jupyter/wiki/A-gallery-of-interesting-Jupyter-Notebooks#introductory-tutorials
- https://seaborn.pydata.org/generated/seaborn.heatmap.html
- https://seaborn.pydata.org/index.html
- https://www.analyticsvidhya.com/blog/2016/01/12-pandas-techniques-python-data-manipulation/
- https://en.wikipedia.org/wiki/Pearson_correlation_coefficient