{"cells":[{"metadata":{},"cell_type":"markdown","source":"<div class=\"alert alert-success\">  \n</div>"},{"metadata":{},"cell_type":"markdown","source":"<div>\n    <h1 align=\"center\">\"Reverse Game of Life\"</h1></h1>\n    <h3 align=\"center\">Z3 Constraint Satisfaction</h3>    \n    \n</div>"},{"metadata":{},"cell_type":"markdown","source":"**The codes of this address have been used:**\n\nhttps://www.kaggle.com/jamesmcguigan/game-of-life-z3-constraint-satisfaction\n\nYou can also find the full description there.\nThanks to Mr. [James McGuigan](https://www.kaggle.com/jamesmcguigan)\n"},{"metadata":{},"cell_type":"markdown","source":"<div class=\"alert alert-success\">  \n</div>"},{"metadata":{},"cell_type":"markdown","source":"There are 10 forks of this notebook running in parallel as a poor man's version of cluster compute using a modulo loop to subdivide the data, with the submission.csv file acting as a filesystem cache. They each reimport the output of each other, with the accumilated results of multiple 9-hour commit sessions merged together. \n\nWe also import any boards solved via the Hashmap Solver, which identifies geometric duplicates discovered from the training dataset, and generated data using forward play\n\nhttps://www.kaggle.com/jamesmcguigan/game-of-life-hashmap-solver/"},{"metadata":{"trusted":true},"cell_type":"code","source":"# Merge submission files from various sources into a single file. Reverse sort puts non-zero entries first, \n# then use awk to deduplicate on id\n\n!find ./ ../input/ /ai-games/puzzles/game_of_life/ -name 'submission.csv' | xargs cat | sort -nr | uniq | awk -F',' '!a[$1]++' | sort -n > ./submission_previous.csv\n!find ./ ../input/ /ai-games/puzzles/game_of_life/ -name 'submission.csv' | xargs cat | sort -nr | uniq | awk -F',' '!a[$1]++' | sort -n > ./submission.csv\n!find ./ ../input/ /ai-games/puzzles/game_of_life/ -name 'timeouts.csv'   | xargs cat | sort -nr | uniq | awk -F',' '!a[$1]++' | sort -n > ./timeouts.csv\n\n\n# Count number of non-zero entries in each submission.csv file\n!( for FILE in $(find ./ ../input/ /ai-games/puzzles/game_of_life/ -name '*submission.csv' | sort ); do cat $FILE | grep ',1' | wc -l | tr '\\n' ' '; echo $FILE; done) | sort -n;\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# Cleanup python caches to prevent poluting kaggle notebook outputs\n!find ./ -name '__pycache__' -or -name '*.py[cod]'  -delete\n\n\n# Count number of non-zero entries in each submission.csv file\n!( for FILE in *.csv; do cat $FILE | grep ',1,' | wc -l | tr '\\n' ' '; echo $FILE; done ) | sort -n;\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"!ls\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<div class=\"alert alert-success\">  \n</div>"}],"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat":4,"nbformat_minor":4}