From 76d7dcd5ad275f76e38a33a45e0fbdf2948c6b29 Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Fri, 2 Jun 2017 16:57:40 +0100 Subject: [PATCH] Renamed wordsearch, added example problem --- .../count_1l.txt | 0 04-word-search/example-wordsearch.txt | 40 + .../exmaple-wordsearch-solution.txt | 41 + 04-word-search/wordsearch-creation.ipynb | 1650 +++++++++++++++++ .../wordsearch-solution00.txt | 0 .../wordsearch-solution01.txt | 0 .../wordsearch-solution02.txt | 0 .../wordsearch-solution03.txt | 0 .../wordsearch-solution04.txt | 0 .../wordsearch-solution05.txt | 0 .../wordsearch-solution06.txt | 0 .../wordsearch-solution07.txt | 0 .../wordsearch-solution08.txt | 0 .../wordsearch-solution09.txt | 0 .../wordsearch-solution10.txt | 0 .../wordsearch-solution11.txt | 0 .../wordsearch-solution12.txt | 0 .../wordsearch-solution13.txt | 0 .../wordsearch-solution14.txt | 0 .../wordsearch-solution15.txt | 0 .../wordsearch-solution16.txt | 0 .../wordsearch-solution17.txt | 0 .../wordsearch-solution18.txt | 0 .../wordsearch-solution19.txt | 0 .../wordsearch-solution20.txt | 0 .../wordsearch-solution21.txt | 0 .../wordsearch-solution22.txt | 0 .../wordsearch-solution23.txt | 0 .../wordsearch-solution24.txt | 0 .../wordsearch-solution25.txt | 0 .../wordsearch-solution26.txt | 0 .../wordsearch-solution27.txt | 0 .../wordsearch-solution28.txt | 0 .../wordsearch-solution29.txt | 0 .../wordsearch-solution30.txt | 0 .../wordsearch-solution31.txt | 0 .../wordsearch-solution32.txt | 0 .../wordsearch-solution33.txt | 0 .../wordsearch-solution34.txt | 0 .../wordsearch-solution35.txt | 0 .../wordsearch-solution36.txt | 0 .../wordsearch-solution37.txt | 0 .../wordsearch-solution38.txt | 0 .../wordsearch-solution39.txt | 0 .../wordsearch-solution40.txt | 0 .../wordsearch-solution41.txt | 0 .../wordsearch-solution42.txt | 0 .../wordsearch-solution43.txt | 0 .../wordsearch-solution44.txt | 0 .../wordsearch-solution45.txt | 0 .../wordsearch-solution46.txt | 0 .../wordsearch-solution47.txt | 0 .../wordsearch-solution48.txt | 0 .../wordsearch-solution49.txt | 0 .../wordsearch-solution50.txt | 0 .../wordsearch-solution51.txt | 0 .../wordsearch-solution52.txt | 0 .../wordsearch-solution53.txt | 0 .../wordsearch-solution54.txt | 0 .../wordsearch-solution55.txt | 0 .../wordsearch-solution56.txt | 0 .../wordsearch-solution57.txt | 0 .../wordsearch-solution58.txt | 0 .../wordsearch-solution59.txt | 0 .../wordsearch-solution60.txt | 0 .../wordsearch-solution61.txt | 0 .../wordsearch-solution62.txt | 0 .../wordsearch-solution63.txt | 0 .../wordsearch-solution64.txt | 0 .../wordsearch-solution65.txt | 0 .../wordsearch-solution66.txt | 0 .../wordsearch-solution67.txt | 0 .../wordsearch-solution68.txt | 0 .../wordsearch-solution69.txt | 0 .../wordsearch-solution70.txt | 0 .../wordsearch-solution71.txt | 0 .../wordsearch-solution72.txt | 0 .../wordsearch-solution73.txt | 0 .../wordsearch-solution74.txt | 0 .../wordsearch-solution75.txt | 0 .../wordsearch-solution76.txt | 0 .../wordsearch-solution77.txt | 0 .../wordsearch-solution78.txt | 0 .../wordsearch-solution79.txt | 0 .../wordsearch-solution80.txt | 0 .../wordsearch-solution81.txt | 0 .../wordsearch-solution82.txt | 0 .../wordsearch-solution83.txt | 0 .../wordsearch-solution84.txt | 0 .../wordsearch-solution85.txt | 0 .../wordsearch-solution86.txt | 0 .../wordsearch-solution87.txt | 0 .../wordsearch-solution88.txt | 0 .../wordsearch-solution89.txt | 0 .../wordsearch-solution90.txt | 0 .../wordsearch-solution91.txt | 0 .../wordsearch-solution92.txt | 0 .../wordsearch-solution93.txt | 0 .../wordsearch-solution94.txt | 0 .../wordsearch-solution95.txt | 0 .../wordsearch-solution96.txt | 0 .../wordsearch-solution97.txt | 0 .../wordsearch-solution98.txt | 0 .../wordsearch-solution99.txt | 0 .../wordsearch-solving.ipynb | 474 +++-- .../wordsearch-words | 0 .../wordsearch00.txt | 0 .../wordsearch01.txt | 0 .../wordsearch02.txt | 0 .../wordsearch03.txt | 0 .../wordsearch04.txt | 0 .../wordsearch05.txt | 0 .../wordsearch06.txt | 0 .../wordsearch07.txt | 0 .../wordsearch08.txt | 0 .../wordsearch09.txt | 0 .../wordsearch10.txt | 0 .../wordsearch11.txt | 0 .../wordsearch12.txt | 0 .../wordsearch13.txt | 0 .../wordsearch14.txt | 0 .../wordsearch15.txt | 0 .../wordsearch16.txt | 0 .../wordsearch17.txt | 0 .../wordsearch18.txt | 0 .../wordsearch19.txt | 0 .../wordsearch20.txt | 0 .../wordsearch21.txt | 0 .../wordsearch22.txt | 0 .../wordsearch23.txt | 0 .../wordsearch24.txt | 0 .../wordsearch25.txt | 0 .../wordsearch26.txt | 0 .../wordsearch27.txt | 0 .../wordsearch28.txt | 0 .../wordsearch29.txt | 0 .../wordsearch30.txt | 0 .../wordsearch31.txt | 0 .../wordsearch32.txt | 0 .../wordsearch33.txt | 0 .../wordsearch34.txt | 0 .../wordsearch35.txt | 0 .../wordsearch36.txt | 0 .../wordsearch37.txt | 0 .../wordsearch38.txt | 0 .../wordsearch39.txt | 0 .../wordsearch40.txt | 0 .../wordsearch41.txt | 0 .../wordsearch42.txt | 0 .../wordsearch43.txt | 0 .../wordsearch44.txt | 0 .../wordsearch45.txt | 0 .../wordsearch46.txt | 0 .../wordsearch47.txt | 0 .../wordsearch48.txt | 0 .../wordsearch49.txt | 0 .../wordsearch50.txt | 0 .../wordsearch51.txt | 0 .../wordsearch52.txt | 0 .../wordsearch53.txt | 0 .../wordsearch54.txt | 0 .../wordsearch55.txt | 0 .../wordsearch56.txt | 0 .../wordsearch57.txt | 0 .../wordsearch58.txt | 0 .../wordsearch59.txt | 0 .../wordsearch60.txt | 0 .../wordsearch61.txt | 0 .../wordsearch62.txt | 0 .../wordsearch63.txt | 0 .../wordsearch64.txt | 0 .../wordsearch65.txt | 0 .../wordsearch66.txt | 0 .../wordsearch67.txt | 0 .../wordsearch68.txt | 0 .../wordsearch69.txt | 0 .../wordsearch70.txt | 0 .../wordsearch71.txt | 0 .../wordsearch72.txt | 0 .../wordsearch73.txt | 0 .../wordsearch74.txt | 0 .../wordsearch75.txt | 0 .../wordsearch76.txt | 0 .../wordsearch77.txt | 0 .../wordsearch78.txt | 0 .../wordsearch79.txt | 0 .../wordsearch80.txt | 0 .../wordsearch81.txt | 0 .../wordsearch82.txt | 0 .../wordsearch83.txt | 0 .../wordsearch84.txt | 0 .../wordsearch85.txt | 0 .../wordsearch86.txt | 0 .../wordsearch87.txt | 0 .../wordsearch88.txt | 0 .../wordsearch89.txt | 0 .../wordsearch90.txt | 0 .../wordsearch91.txt | 0 .../wordsearch92.txt | 0 .../wordsearch93.txt | 0 .../wordsearch94.txt | 0 .../wordsearch95.txt | 0 .../wordsearch96.txt | 0 .../wordsearch97.txt | 0 .../wordsearch98.txt | 0 .../wordsearch99.txt | 0 04-wordsearch/wordsearch-creation.ipynb | 1345 -------------- 05-display-board/display-board-solution.ipynb | 2 +- problem-ideas.ipynb | 2 +- 209 files changed, 2095 insertions(+), 1459 deletions(-) rename {04-wordsearch => 04-word-search}/count_1l.txt (100%) create mode 100644 04-word-search/example-wordsearch.txt create mode 100644 04-word-search/exmaple-wordsearch-solution.txt create mode 100644 04-word-search/wordsearch-creation.ipynb rename {04-wordsearch => 04-word-search}/wordsearch-solution00.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution01.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution02.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution03.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution04.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution05.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution06.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution07.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution08.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution09.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution10.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution11.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution12.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution13.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution14.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution15.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution16.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution17.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution18.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution19.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution20.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution21.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution22.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution23.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution24.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution25.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution26.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution27.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution28.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution29.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution30.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution31.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution32.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution33.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution34.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution35.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution36.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution37.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution38.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution39.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution40.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution41.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution42.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution43.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution44.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution45.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution46.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution47.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution48.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution49.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution50.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution51.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution52.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution53.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution54.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution55.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution56.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution57.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution58.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution59.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution60.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution61.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution62.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution63.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution64.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution65.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution66.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution67.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution68.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution69.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution70.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution71.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution72.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution73.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution74.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution75.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution76.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution77.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution78.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution79.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution80.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution81.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution82.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution83.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution84.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution85.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution86.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution87.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution88.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution89.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution90.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution91.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution92.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution93.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution94.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution95.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution96.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution97.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution98.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solution99.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch-solving.ipynb (70%) rename {04-wordsearch => 04-word-search}/wordsearch-words (100%) rename {04-wordsearch => 04-word-search}/wordsearch00.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch01.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch02.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch03.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch04.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch05.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch06.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch07.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch08.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch09.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch10.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch11.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch12.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch13.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch14.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch15.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch16.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch17.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch18.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch19.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch20.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch21.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch22.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch23.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch24.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch25.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch26.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch27.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch28.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch29.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch30.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch31.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch32.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch33.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch34.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch35.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch36.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch37.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch38.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch39.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch40.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch41.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch42.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch43.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch44.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch45.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch46.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch47.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch48.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch49.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch50.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch51.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch52.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch53.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch54.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch55.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch56.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch57.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch58.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch59.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch60.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch61.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch62.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch63.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch64.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch65.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch66.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch67.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch68.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch69.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch70.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch71.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch72.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch73.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch74.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch75.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch76.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch77.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch78.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch79.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch80.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch81.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch82.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch83.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch84.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch85.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch86.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch87.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch88.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch89.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch90.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch91.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch92.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch93.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch94.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch95.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch96.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch97.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch98.txt (100%) rename {04-wordsearch => 04-word-search}/wordsearch99.txt (100%) delete mode 100644 04-wordsearch/wordsearch-creation.ipynb diff --git a/04-wordsearch/count_1l.txt b/04-word-search/count_1l.txt similarity index 100% rename from 04-wordsearch/count_1l.txt rename to 04-word-search/count_1l.txt diff --git a/04-word-search/example-wordsearch.txt b/04-word-search/example-wordsearch.txt new file mode 100644 index 0000000..294bad3 --- /dev/null +++ b/04-word-search/example-wordsearch.txt @@ -0,0 +1,40 @@ +10x10 +fhjpamownq +wsdseuqeev +ieaeladhcr +piedtiriah +rzsiwovspu +oawhakieab +browpcfrda +ecnotopssr +dikchdnpnb +bstapleokr +adapting +apace +bombing +cackles +carnal +chump +coccyxes +cowhides +crazies +crumbled +dock +fickler +foaming +guts +knows +lived +minuend +molested +mown +pears +probed +rhubarb +rioted +shinier +solaria +staple +tops +wide +winced \ No newline at end of file diff --git a/04-word-search/exmaple-wordsearch-solution.txt b/04-word-search/exmaple-wordsearch-solution.txt new file mode 100644 index 0000000..5c285ea --- /dev/null +++ b/04-word-search/exmaple-wordsearch-solution.txt @@ -0,0 +1,41 @@ +10x10 +...p.mown. +.sdse..ee. +.e.elad.cr +pi.dtir.ah +rzsiwovspu +oawh.kieab +brow.c.rda +ecnotops.r +d.kc.d...b +.staple... +apace +cowhides +crazies +dock +knows +lived +mown +pears +probed +rhubarb +rioted +staple +tops +wide + +adapting +bombing +cackles +carnal +chump +coccyxes +crumbled +fickler +foaming +guts +minuend +molested +shinier +solaria +winced \ No newline at end of file diff --git a/04-word-search/wordsearch-creation.ipynb b/04-word-search/wordsearch-creation.ipynb new file mode 100644 index 0000000..5259725 --- /dev/null +++ b/04-word-search/wordsearch-creation.ipynb @@ -0,0 +1,1650 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "import string\n", + "import re\n", + "import random\n", + "import collections\n", + "import copy\n", + "\n", + "from enum import Enum\n", + "Direction = Enum('Direction', 'left right up down upleft upright downleft downright')\n", + " \n", + "delta = {Direction.left: (0, -1),Direction.right: (0, 1), \n", + " Direction.up: (-1, 0), Direction.down: (1, 0), \n", + " Direction.upleft: (-1, -1), Direction.upright: (-1, 1), \n", + " Direction.downleft: (1, -1), Direction.downright: (1, 1)}\n", + "\n", + "cat = ''.join\n", + "wcat = ' '.join\n", + "lcat = '\\n'.join" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "# all_words = [w.strip() for w in open('/usr/share/dict/british-english').readlines()\n", + "# if all(c in string.ascii_lowercase for c in w.strip())]\n", + "# words = [w for w in all_words\n", + "# if not any(w in w2 for w2 in all_words if w != w2)]\n", + "# open('wordsearch-words', 'w').write(lcat(words))" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "# ws_words = [w.strip() for w in open('wordsearch-words').readlines()\n", + "# if all(c in string.ascii_lowercase for c in w.strip())]\n", + "# ws_words[:10]" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "ws_words = [w.strip() for w in open('/usr/share/dict/british-english').readlines()\n", + " if all(c in string.ascii_lowercase for c in w.strip())]" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def empty_grid(w, h):\n", + " return [['.' for c in range(w)] for r in range(h)]" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def show_grid(grid):\n", + " return lcat(cat(r) for r in grid)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "..........\n", + "..........\n", + "..........\n", + "..........\n", + "..........\n", + "..........\n", + "..........\n", + "..........\n", + "..........\n", + "..........\n" + ] + } + ], + "source": [ + "grid = empty_grid(10, 10)\n", + "print(show_grid(grid))" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def indices(grid, r, c, l, d):\n", + " dr, dc = delta[d]\n", + " w = len(grid[0])\n", + " h = len(grid)\n", + " inds = [(r + i * dr, c + i * dc) for i in range(l)]\n", + " return [(i, j) for i, j in inds\n", + " if i >= 0\n", + " if j >= 0\n", + " if i < h\n", + " if j < w]" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def gslice(grid, r, c, l, d):\n", + " return [grid[i][j] for i, j in indices(grid, r, c, l, d)]" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def set_grid(grid, r, c, d, word):\n", + " for (i, j), l in zip(indices(grid, r, c, len(word), d), word):\n", + " grid[i][j] = l\n", + " return grid" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "..........\n", + "..........\n", + "...t......\n", + "....e.....\n", + ".....s....\n", + "......t...\n", + ".......w..\n", + "........o.\n", + ".........r\n", + "..........\n" + ] + } + ], + "source": [ + "set_grid(grid, 2, 3, Direction.downright, 'testword')\n", + "print(show_grid(grid))" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'..e.....'" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cat(gslice(grid, 3, 2, 15, Direction.right))" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "<_sre.SRE_Match object; span=(0, 4), match='keen'>" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "re.match(cat(gslice(grid, 3, 2, 4, Direction.right)), 'keen')" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "<_sre.SRE_Match object; span=(0, 3), match='kee'>" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "re.match(cat(gslice(grid, 3, 2, 3, Direction.right)), 'keen')" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [], + "source": [ + "re.fullmatch(cat(gslice(grid, 3, 2, 3, Direction.right)), 'keen')" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "re.match(cat(gslice(grid, 3, 2, 4, Direction.right)), 'kine')" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def could_add(grid, r, c, d, word):\n", + " s = gslice(grid, r, c, len(word), d)\n", + " return re.fullmatch(cat(s), word)" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "<_sre.SRE_Match object; span=(0, 4), match='keen'>" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "could_add(grid, 3, 2, Direction.right, 'keen')" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [], + "source": [ + "could_add(grid, 3, 2, Direction.right, 'kine')" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "random.choice(list(Direction))" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def fill_grid(grid, words, word_count, max_attempts=10000):\n", + " attempts = 0\n", + " added_words = []\n", + " w = len(grid[0])\n", + " h = len(grid)\n", + " while len(added_words) < word_count and attempts < max_attempts:\n", + " attempts += 1\n", + " r = random.randrange(w)\n", + " c = random.randrange(h)\n", + " word = random.choice(words)\n", + " d = random.choice(list(Direction))\n", + " if len(word) >=4 and not any(word in w2 for w2 in added_words) and could_add(grid, r, c, d, word):\n", + " set_grid(grid, r, c, d, word)\n", + " added_words += [word]\n", + " attempts = 0\n", + " return grid, added_words" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "40" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "g = empty_grid(20, 20)\n", + "g, ws = fill_grid(g, ws_words, 40)\n", + "len(ws)" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "..pouchexecrate.....\n", + ".hazardous....t.wive\n", + "...sniradnam.aselcnu\n", + "s.weeklies.rnb......\n", + "e..lamenessse.o.....\n", + "i.tsallab..s.a.i....\n", + "tslim.......f.c.l...\n", + "iwheelbase...f.tges.\n", + "ed....llabhgihinirr.\n", + "dw.limbs..nj.bitev.s\n", + "te.wiltediu.ructs.e.\n", + "elsombretv.oqes..a..\n", + "ll..e..te.iela....m.\n", + "ie.a..un.lheleiretoc\n", + "ord..bi.scsp...kiths\n", + "ts.malcentilitren...\n", + "..i.e.sexetrov.stolb\n", + ".r.s...ruof....htrof\n", + "bgnihsirevopmi.....c\n", + "....graciousness....\n", + "40 words added\n", + "lameness impoverishing plasters wilted toilet forth coterie hazardous abutting chequing weeklies sombre execrate mastiffs boilers uncles centilitre mandarins wheelbase graciousness vortexes dwellers ballast limbs four tans highball wive broils beads mils reactive select deities shtik juveniles blots pouch brim coon\n" + ] + } + ], + "source": [ + "print(show_grid(g))\n", + "print(len(ws), 'words added')\n", + "print(wcat(ws))" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def present(grid, word):\n", + " w = len(grid[0])\n", + " h = len(grid)\n", + " for r in range(h):\n", + " for c in range(w):\n", + " for d in Direction:\n", + " if cat(gslice(grid, r, c, len(word), d)) == word:\n", + " return True, r, c, d\n", + " return False, 0, 0, list(Direction)[0]" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "lameness (True, 4, 3, )\n", + "impoverishing (True, 18, 13, )\n", + "plasters (True, 14, 11, )\n", + "wilted (True, 10, 3, )\n", + "toilet (True, 15, 0, )\n", + "forth (True, 17, 19, )\n", + "coterie (True, 13, 19, )\n", + "hazardous (True, 1, 1, )\n", + "abutting (True, 15, 4, )\n", + "chequing (True, 14, 9, )\n", + "weeklies (True, 3, 2, )\n", + "sombre (True, 11, 2, )\n", + "execrate (True, 0, 7, )\n", + "mastiffs (True, 12, 18, )\n", + "boilers (True, 3, 13, )\n", + "uncles (True, 2, 19, )\n", + "centilitre (True, 15, 6, )\n", + "mandarins (True, 2, 11, )\n", + "wheelbase (True, 7, 1, )\n", + "graciousness (True, 19, 4, )\n", + "vortexes (True, 16, 13, )\n", + "dwellers (True, 8, 1, )\n", + "ballast (True, 5, 8, )\n", + "limbs (True, 9, 3, )\n", + "four (True, 17, 10, )\n", + "tans (True, 1, 14, )\n", + "highball (True, 8, 13, )\n", + "wive (True, 1, 16, )\n", + "broils (True, 9, 13, )\n", + "beads (True, 11, 5, )\n", + "mils (True, 6, 4, )\n", + "reactive (True, 3, 11, )\n", + "select (True, 14, 10, )\n", + "deities (True, 9, 0, )\n", + "shtik (True, 14, 19, )\n", + "juveniles (True, 9, 11, )\n", + "blots (True, 16, 19, )\n", + "pouch (True, 0, 2, )\n", + "brim (True, 18, 0, )\n", + "coon (True, 18, 19, )\n" + ] + } + ], + "source": [ + "for w in ws:\n", + " print(w, present(g, w))" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def interesting(grid, words, words_limit=40, direction_slack=1):\n", + " dirs = set(present(grid, w)[3] for w in words)\n", + " return len(words) > words_limit and len(dirs) + direction_slack >= len(delta)" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 48, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "interesting(g, ws)" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def interesting_grid(width=20, height=20, words_limit=40, direction_slack=1):\n", + " boring = True\n", + " while boring:\n", + " grid = empty_grid(width, height)\n", + " grid, words = fill_grid(grid, ws_words, 80)\n", + " boring = not interesting(grid, words, words_limit=words_limit, direction_slack=direction_slack)\n", + " return grid, words" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "dexawwt....ybossm..t\n", + "snaprhlukulele..o.er\n", + "...erioteb.hrevordla\n", + "..sivc..pr.tdekcahkp\n", + "atve..h.oiselapcy.cd\n", + "nesrehpargohtill.pue\n", + "n.leaveyis.smuguhhrt\n", + "eyhsifnt.r...aeesetc\n", + "xverbseebasedlritl.a\n", + ".r..k.wie..mdonaiaeg\n", + "..ac.nsof.admeeulsoo\n", + "g.opo.cmanaotpqiinmp\n", + "nc.us.a.lpnteaerdkiu\n", + "ionjoys.leirinioicns\n", + "wnkcent.skeracllkase\n", + "oab..erusopxeao.antt\n", + "dureifidimuhed.nskea\n", + "aga...capitols..scrl\n", + "h.v.sandblaster..i.i\n", + "s.e..sdratoelhitsn.d\n", + "61 words added; 8 directions\n", + "newscast kittenish cocks lithographers truckle leotards they exposure dehumidifier sandblaster alien paddle shadowing gondola wrest joys minster pales chairs fishy capitols based gums pheromones saki moiety waxed guano thriven dilate moray icons adman ukulele hacked rope rise clue acted nicknack spar verbs boss annex neck repeater befalls drover leave pans brave brigs opus live noun tail riot care hits quilt part\n" + ] + } + ], + "source": [ + "g, ws = interesting_grid()\n", + "print(show_grid(g))\n", + "print(len(ws), 'words added; ', len(set(present(g, w)[3] for w in ws)), 'directions')\n", + "print(wcat(ws))" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def datafile(name, sep='\\t'):\n", + " \"\"\"Read key,value pairs from file.\n", + " \"\"\"\n", + " with open(name) as f:\n", + " for line in f:\n", + " splits = line.split(sep)\n", + " yield [splits[0], int(splits[1])]" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def normalise(frequencies):\n", + " \"\"\"Scale a set of frequencies so they sum to one\n", + " \n", + " >>> sorted(normalise({1: 1, 2: 0}).items())\n", + " [(1, 1.0), (2, 0.0)]\n", + " >>> sorted(normalise({1: 1, 2: 1}).items())\n", + " [(1, 0.5), (2, 0.5)]\n", + " >>> sorted(normalise({1: 1, 2: 1, 3: 1}).items()) # doctest: +ELLIPSIS\n", + " [(1, 0.333...), (2, 0.333...), (3, 0.333...)]\n", + " >>> sorted(normalise({1: 1, 2: 2, 3: 1}).items())\n", + " [(1, 0.25), (2, 0.5), (3, 0.25)]\n", + " \"\"\"\n", + " length = sum(f for f in frequencies.values())\n", + " return collections.defaultdict(int, ((k, v / length) \n", + " for (k, v) in frequencies.items()))\n" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": {}, + "outputs": [], + "source": [ + "english_counts = collections.Counter(dict(datafile('count_1l.txt')))\n", + "normalised_english_counts = normalise(english_counts)" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": {}, + "outputs": [], + "source": [ + "wordsearch_counts = collections.Counter(cat(ws_words))\n", + "normalised_wordsearch_counts = normalise(wordsearch_counts)" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": {}, + "outputs": [], + "source": [ + "normalised_wordsearch_counts = normalise(collections.Counter(normalised_wordsearch_counts) + collections.Counter({l: 0.05 for l in string.ascii_lowercase}))" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def weighted_choice(d):\n", + " \"\"\"Generate random item from a dictionary of item counts\n", + " \"\"\"\n", + " target = random.uniform(0, sum(d.values()))\n", + " cuml = 0.0\n", + " for (l, p) in d.items():\n", + " cuml += p\n", + " if cuml > target:\n", + " return l\n", + " return None\n", + "\n", + "def random_english_letter():\n", + " \"\"\"Generate a random letter based on English letter counts\n", + " \"\"\"\n", + " return weighted_choice(normalised_english_counts)\n", + "\n", + "def random_wordsearch_letter():\n", + " \"\"\"Generate a random letter based on wordsearch letter counts\n", + " \"\"\"\n", + " return weighted_choice(normalised_wordsearch_counts)" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'aaaaaabbccddeeeeeeeeeeeffggghhhhhhiiiiiiiiillllmmnnnnnnnooooooooooppppqrrrrrrrssstttttttttuuwyyyyyyz'" + ] + }, + "execution_count": 36, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cat(sorted(random_english_letter() for i in range(100)))" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'aaaaaaaabbbccccddeeeeeeeeggghhhiiiiiiiijjkkllllnnnnoooooooooopppqqrrrrrssssssttttttuuuuvvwxxxxxyzzzz'" + ] + }, + "execution_count": 37, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cat(sorted(random_wordsearch_letter() for i in range(100)))" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'x'" + ] + }, + "execution_count": 38, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "random_wordsearch_letter()" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def pad_grid(g0):\n", + " grid = copy.deepcopy(g0)\n", + " w = len(grid[0])\n", + " h = len(grid)\n", + " for r in range(h):\n", + " for c in range(w):\n", + " if grid[r][c] == '.':\n", + " grid[r][c] = random_wordsearch_letter()\n", + " return grid" + ] + }, + { + "cell_type": "code", + "execution_count": 53, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "dexawwtmxepybossmezt\n", + "snaprhlukulelefaoder\n", + "ijreriotebahrevordla\n", + "jrsivcciprstdekcahkp\n", + "atvecshkoiselapcydcd\n", + "nesrehpargohtilljpue\n", + "nuleaveyisasmuguhhrt\n", + "eyhsifntzrmnsaeesetc\n", + "xverbseebasedlritlla\n", + "prcckzwiefamdonaiaeg\n", + "osacqnsofgadmeeulsoo\n", + "gdoporcmanaotpqiinmp\n", + "ncmusbaslpnteaerdkiu\n", + "ionjoyswleirinioicns\n", + "wnkcentcskeracllkase\n", + "oabsuerusopxeaodantt\n", + "dureifidimuhedgnskea\n", + "agagvccapitolsgyscrl\n", + "hkvgsandblasterdhihi\n", + "syenesdratoelhitsnod\n" + ] + } + ], + "source": [ + "padded = pad_grid(g)\n", + "print(show_grid(padded))" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "dexawwt....ybossm..t\n", + "snaprhlukulele..o.er\n", + "...erioteb.hrevordla\n", + "..sivc..pr.tdekcahkp\n", + "atve..h.oiselapcy.cd\n", + "nesrehpargohtill.pue\n", + "n.leaveyis.smuguhhrt\n", + "eyhsifnt.r...aeesetc\n", + "xverbseebasedlritl.a\n", + ".r..k.wie..mdonaiaeg\n", + "..ac.nsof.admeeulsoo\n", + "g.opo.cmanaotpqiinmp\n", + "nc.us.a.lpnteaerdkiu\n", + "ionjoys.leirinioicns\n", + "wnkcent.skeracllkase\n", + "oab..erusopxeao.antt\n", + "dureifidimuhed.nskea\n", + "aga...capitols..scrl\n", + "h.v.sandblaster..i.i\n", + "s.e..sdratoelhitsn.d\n" + ] + } + ], + "source": [ + "print(show_grid(g))" + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "newscast (True, 7, 6, )\n", + "kittenish (True, 14, 9, )\n", + "cocks (True, 12, 1, )\n", + "lithographers (True, 5, 14, )\n", + "truckle (True, 7, 18, )\n", + "leotards (True, 19, 12, )\n", + "they (True, 3, 11, )\n", + "exposure (True, 15, 12, )\n", + "dehumidifier (True, 16, 13, )\n", + "sandblaster (True, 18, 4, )\n", + "alien (True, 9, 17, )\n", + "paddle (True, 12, 9, )\n", + "shadowing (True, 19, 0, )\n", + "gondola (True, 9, 19, )\n", + "wrest (True, 0, 5, )\n", + "joys (True, 13, 3, )\n", + "minster (True, 11, 18, )\n", + "pales (True, 4, 14, )\n", + "chairs (True, 3, 5, )\n", + "fishy (True, 7, 5, )\n", + "capitols (True, 17, 6, )\n", + "based (True, 8, 8, )\n", + "gums (True, 6, 14, )\n", + "pheromones (True, 5, 17, )\n", + "saki (True, 16, 16, )\n", + "moiety (True, 11, 7, )\n", + "waxed (True, 0, 4, )\n", + "guano (True, 17, 1, )\n", + "thriven (True, 0, 6, )\n", + "dilate (True, 19, 19, )\n", + "moray (True, 0, 16, )\n", + "icons (True, 13, 12, )\n", + "adman (True, 7, 13, )\n", + "ukulele (True, 1, 7, )\n", + "hacked (True, 3, 17, )\n", + "rope (True, 5, 8, )\n", + "rise (True, 12, 15, )\n", + "clue (True, 4, 15, )\n", + "acted (True, 8, 19, )\n", + "nicknack (True, 19, 17, )\n", + "spar (True, 12, 4, )\n", + "verbs (True, 8, 1, )\n", + "boss (True, 0, 12, )\n", + "annex (True, 4, 0, )\n", + "neck (True, 14, 5, )\n", + "repeater (True, 13, 11, )\n", + "befalls (True, 8, 8, )\n", + "drover (True, 2, 17, )\n", + "leave (True, 6, 2, )\n", + "pans (True, 1, 3, )\n", + "brave (True, 15, 2, )\n", + "brigs (True, 2, 9, )\n", + "opus (True, 10, 19, )\n", + "live (True, 1, 6, )\n", + "noun (True, 10, 5, )\n", + "tail (True, 11, 12, )\n", + "riot (True, 2, 4, )\n", + "care (True, 14, 13, )\n", + "hits (True, 19, 13, )\n", + "quilt (True, 11, 14, )\n", + "part (True, 3, 19, )\n" + ] + } + ], + "source": [ + "for w in ws:\n", + " print(w, present(padded, w))" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "metadata": {}, + "outputs": [], + "source": [ + "def decoys(grid, words, all_words, limit=100):\n", + " decoy_words = []\n", + " dlen_limit = max(len(w) for w in words)\n", + " while len(words) + len(decoy_words) < limit:\n", + " d = random.choice(all_words)\n", + " if d not in words and len(d) >= 4 and len(d) <= dlen_limit and not present(grid, d)[0]:\n", + " decoy_words += [d]\n", + " return decoy_words" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['friendship',\n", + " 'stepping',\n", + " 'featheriest',\n", + " 'thriftily',\n", + " 'mutilation',\n", + " 'nook',\n", + " 'clewing',\n", + " 'meditated',\n", + " 'gooier',\n", + " 'cripples',\n", + " 'ponderously',\n", + " 'roundelay',\n", + " 'curtailed',\n", + " 'redeemed',\n", + " 'perimeters',\n", + " 'harelips',\n", + " 'overcompensating',\n", + " 'rejoicings',\n", + " 'adobe',\n", + " 'decreasing',\n", + " 'interstices',\n", + " 'curd',\n", + " 'orientate',\n", + " 'blueberries',\n", + " 'juniors',\n", + " 'broadloom',\n", + " 'debarring',\n", + " 'chandeliers',\n", + " 'segues',\n", + " 'army',\n", + " 'snuck',\n", + " 'pugilistic',\n", + " 'snugs',\n", + " 'dexterity',\n", + " 'dallies',\n", + " 'curving',\n", + " 'newsletter',\n", + " 'torn',\n", + " 'beaching',\n", + " 'limit',\n", + " 'blackguards',\n", + " 'breezier',\n", + " 'reoccur',\n", + " 'cabins']" + ] + }, + "execution_count": 44, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ds = decoys(padded, ws, ws_words)\n", + "ds" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "opted (True, 5, 7, )\n", + "haywire (True, 8, 9, )\n", + "busting (True, 4, 17, )\n", + "succinct (True, 7, 17, )\n", + "institute (True, 16, 18, )\n", + "illicit (True, 13, 14, )\n", + "hypersensitivity (True, 16, 15, )\n", + "placement (True, 3, 11, )\n", + "bathrobe (True, 0, 5, )\n", + "inured (True, 4, 0, )\n", + "caveats (True, 3, 8, )\n", + "revisiting (True, 2, 11, )\n", + "pulp (True, 15, 11, )\n", + "teacup (True, 7, 16, )\n", + "threading (True, 18, 6, )\n", + "queered (True, 5, 13, )\n", + "parking (True, 6, 9, )\n", + "advent (True, 1, 11, )\n", + "chasuble (True, 19, 19, )\n", + "mosey (True, 7, 5, )\n", + "highboys (True, 19, 4, )\n", + "recharging (True, 18, 19, )\n", + "flue (True, 12, 2, )\n", + "plywood (True, 3, 18, )\n", + "gluing (True, 12, 12, )\n", + "worrier (True, 1, 12, )\n", + "karma (True, 17, 9, )\n", + "peepers (True, 8, 7, )\n", + "vulnerable (True, 17, 10, )\n", + "boycott (True, 15, 1, )\n", + "rummy (True, 5, 4, )\n", + "tonic (True, 8, 13, )\n", + "children (True, 15, 0, )\n", + "reales (True, 6, 1, )\n", + "rectal (True, 7, 15, )\n", + "sledded (True, 14, 16, )\n", + "collocates (True, 14, 5, )\n", + "edict (True, 17, 4, )\n", + "captor (True, 14, 5, )\n", + "amulet (True, 9, 4, )\n", + "slipper (True, 2, 13, )\n", + "foot (True, 0, 0, )\n", + "chef (True, 14, 4, )\n", + "goods (True, 6, 15, )\n", + "salter (True, 1, 5, )\n", + "crows (True, 18, 0, )\n", + "paeans (True, 12, 14, )\n", + "fences (True, 0, 18, )\n", + "iron (True, 5, 9, )\n", + "liras (True, 0, 19, )\n", + "stages (True, 19, 16, )\n", + "defer (True, 14, 2, )\n", + "racy (True, 5, 4, )\n", + "gaps (True, 7, 11, )\n", + "aspen (True, 12, 10, )\n", + "rams (True, 6, 0, )\n", + "friendship (False, 0, 0, )\n", + "stepping (False, 0, 0, )\n", + "featheriest (False, 0, 0, )\n", + "thriftily (False, 0, 0, )\n", + "mutilation (False, 0, 0, )\n", + "nook (False, 0, 0, )\n", + "clewing (False, 0, 0, )\n", + "meditated (False, 0, 0, )\n", + "gooier (False, 0, 0, )\n", + "cripples (False, 0, 0, )\n", + "ponderously (False, 0, 0, )\n", + "roundelay (False, 0, 0, )\n", + "curtailed (False, 0, 0, )\n", + "redeemed (False, 0, 0, )\n", + "perimeters (False, 0, 0, )\n", + "harelips (False, 0, 0, )\n", + "overcompensating (False, 0, 0, )\n", + "rejoicings (False, 0, 0, )\n", + "adobe (False, 0, 0, )\n", + "decreasing (False, 0, 0, )\n", + "interstices (False, 0, 0, )\n", + "curd (False, 0, 0, )\n", + "orientate (False, 0, 0, )\n", + "blueberries (False, 0, 0, )\n", + "juniors (False, 0, 0, )\n", + "broadloom (False, 0, 0, )\n", + "debarring (False, 0, 0, )\n", + "chandeliers (False, 0, 0, )\n", + "segues (False, 0, 0, )\n", + "army (False, 0, 0, )\n", + "snuck (False, 0, 0, )\n", + "pugilistic (False, 0, 0, )\n", + "snugs (False, 0, 0, )\n", + "dexterity (False, 0, 0, )\n", + "dallies (False, 0, 0, )\n", + "curving (False, 0, 0, )\n", + "newsletter (False, 0, 0, )\n", + "torn (False, 0, 0, )\n", + "beaching (False, 0, 0, )\n", + "limit (False, 0, 0, )\n", + "blackguards (False, 0, 0, )\n", + "breezier (False, 0, 0, )\n", + "reoccur (False, 0, 0, )\n", + "cabins (False, 0, 0, )\n" + ] + } + ], + "source": [ + "for w in ws + ds:\n", + " print(w, present(padded, w))" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "s.esevresed...dwhims\n", + "e.tbk..vapourse.bn.d\n", + "h.ificembracesnslo.e\n", + "ctr.egukiwic..ddui.r\n", + "inor.dwh.rips.rrftsa\n", + "reue.eeisrar.tiefiyl\n", + "mmli.mgrg.muarth.slc\n", + "ieft.un.a.bnbuemdole\n", + "nn.nesimrliertseepad\n", + "ei.imeloeccdeh.epob.\n", + "dfsaprlrio.saf.smri.\n", + "cnpdt.ofrn.usu..ap.h\n", + "oom.ispeccgntlpew.sa\n", + "tcu.e.l.lu.eda.vsgin\n", + "e.bdsb.oarrmneloplsg\n", + "r.olaetrleromrkr.isa\n", + "ibatnhd.nlpoaeic.bir\n", + "eesiee.i.luepno.o.e.\n", + "snt.d.o.y.pcte.p.mr.\n", + "u....jtoquesylduol..\n", + "sfesevresedpzcdwhims\n", + "eotbkvgvapoursehbnyd\n", + "hiificembracesnslone\n", + "ctrnegukiwicurdduivr\n", + "inorydwhrripscrrftsa\n", + "reueleeisrarvtiefiyl\n", + "mmlinmgrgzmuarthgslc\n", + "ieftuunyanbnbuemdole\n", + "nncnesimrliertseepad\n", + "eirimeloeccdehzepobm\n", + "dfsaprlrioisafesmriq\n", + "cnpdtsofrnausuodapxh\n", + "oomlispeccgntlpewasa\n", + "tcuaehlzluledakvsgin\n", + "eibdsbeoarrmneloplsg\n", + "rbolaetrleromrkrnisa\n", + "ibatnhdtnlpoaeicibir\n", + "eesieerimluepnoholey\n", + "sntadvoaycpctespsmro\n", + "uamapjtoquesylduoldp\n", + "56 words added; 8 directions\n", + "Present: abreast bigwig bluff bodes bumps clothe concur confinement coteries crier cull daintier declared dendrites denim deserves embraces empties federal fluorite from glib guarded hangar herds iambic joiner kiwi loudly menus mocked panoply pearl poem polling prints proposition pruned resume rices riches rips roped rove seal seem shucks sissier swamped syllabi tine toque truthful unstabler vapours whims\n", + "Decoys: abrasions adapters aimlessness alkali awakens blowing burnouses burped cattily coal commences confusion contrivance crudest curies depravity distribute diva emigrate emulsion giveaway hangman house lifeboats maze middy mines mystified obtain organic parsons postulate prefixes pretenders razors scone sloes spuds straight subtleties systematise turncoats unpacked waivers\n" + ] + } + ], + "source": [ + "g, ws = interesting_grid()\n", + "p = pad_grid(g)\n", + "ds = decoys(p, ws, ws_words)\n", + "print(show_grid(g))\n", + "print(show_grid(p))\n", + "print(len(ws), 'words added; ', len(set(present(g, w)[3] for w in ws)), 'directions')\n", + "print('Present:', wcat(sorted(ws)))\n", + "print('Decoys:', wcat(sorted(ds)))" + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "...p.mown.\n", + ".sdse..ee.\n", + ".e.elad.cr\n", + "pi.dtir.ah\n", + "rzsiwovspu\n", + "oawh.kieab\n", + "brow.c.rda\n", + "ecnotops.r\n", + "d.kc.d...b\n", + ".staple...\n", + "\n", + "fhjpamownq\n", + "wsdseuqeev\n", + "ieaeladhcr\n", + "piedtiriah\n", + "rzsiwovspu\n", + "oawhakieab\n", + "browpcfrda\n", + "ecnotopssr\n", + "dikchdnpnb\n", + "bstapleokr\n", + "14 words added; 6 directions\n", + "Present: apace cowhides crazies dock knows lived mown pears probed rhubarb rioted staple tops wide\n", + "Decoys: adapting bombing boor brick cackles carnal casino chaplets chump coaster coccyxes coddle collies creels crumbled cunt curds curled curlier deepen demeanor dicier dowses ensuing faddish fest fickler foaming gambol garoting gliding gristle grunts guts ibex impugns instants kielbasy lanyard loamier lugs market meanly minuend misprint mitts molested moonshot mucking oaks olives orgasmic pastrami perfect proceed puckered quashed refined regards retraces revel ridges ringlet scoff shinier siren solaria sprain sunder sunup tamped tapes thirds throw tiller times trains tranquil transfix typesets uric wariness welts whimsy winced winced\n" + ] + } + ], + "source": [ + "g, ws = interesting_grid(width=10, height=10, words_limit=5, direction_slack=6)\n", + "p = pad_grid(g)\n", + "ds = decoys(p, ws, ws_words)\n", + "print(show_grid(g))\n", + "print()\n", + "print(show_grid(p))\n", + "print(len(ws), 'words added; ', len(set(present(g, w)[3] for w in ws)), 'directions')\n", + "print('Present:', wcat(sorted(ws)))\n", + "print('Decoys:', wcat(sorted(ds)))" + ] + }, + { + "cell_type": "code", + "execution_count": 98, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['fickler',\n", + " 'adapting',\n", + " 'chump',\n", + " 'foaming',\n", + " 'molested',\n", + " 'carnal',\n", + " 'crumbled',\n", + " 'guts',\n", + " 'minuend',\n", + " 'bombing',\n", + " 'winced',\n", + " 'coccyxes',\n", + " 'solaria',\n", + " 'shinier',\n", + " 'cackles']" + ] + }, + "execution_count": 98, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ds_original = ['regards', 'perfect', 'instants', 'refined', 'coddle', 'fickler', 'gambol', 'misprint', 'tapes', 'impugns', 'moonshot', 'chump', 'brick', 'siren', 'faddish', 'winced', 'kielbasy', 'market', 'puckered', 'trains', 'welts', 'cackles', 'foaming', 'proceed', 'gliding', 'guts', 'uric', 'oaks', 'molested', 'curled', 'boor', 'solaria', 'gristle', 'bombing', 'loamier', 'ensuing', 'cunt', 'sunder', 'revel', 'coaster', 'grunts', 'mucking', 'typesets', 'carnal', 'whimsy', 'scoff', 'coccyxes', 'meanly', 'sprain', 'minuend', 'ringlet', 'fest', 'winced', 'shinier', 'dicier', 'thirds', 'olives', 'garoting', 'pastrami', 'tranquil', 'tamped', 'sunup', 'crumbled', 'throw', 'ridges', 'chaplets', 'curlier', 'lugs', 'collies', 'adapting', 'demeanor', 'deepen', 'lanyard', 'tiller', 'transfix', 'wariness', 'times', 'mitts', 'dowses', 'creels', 'curds', 'quashed', 'orgasmic', 'ibex', 'retraces', 'casino']\n", + "ds = random.sample(ds_original, 15)\n", + "ds" + ] + }, + { + "cell_type": "code", + "execution_count": 89, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['regards',\n", + " 'perfect',\n", + " 'instants',\n", + " 'refined',\n", + " 'coddle',\n", + " 'fickler',\n", + " 'gambol',\n", + " 'misprint',\n", + " 'tapes',\n", + " 'impugns',\n", + " 'moonshot',\n", + " 'chump',\n", + " 'brick',\n", + " 'siren',\n", + " 'faddish',\n", + " 'winced',\n", + " 'kielbasy',\n", + " 'market',\n", + " 'puckered',\n", + " 'trains',\n", + " 'welts',\n", + " 'cackles',\n", + " 'foaming',\n", + " 'proceed',\n", + " 'gliding',\n", + " 'guts',\n", + " 'uric',\n", + " 'oaks',\n", + " 'molested',\n", + " 'curled',\n", + " 'boor',\n", + " 'solaria',\n", + " 'gristle',\n", + " 'bombing',\n", + " 'loamier',\n", + " 'ensuing',\n", + " 'cunt',\n", + " 'sunder',\n", + " 'revel',\n", + " 'coaster',\n", + " 'grunts',\n", + " 'mucking',\n", + " 'typesets',\n", + " 'carnal',\n", + " 'whimsy',\n", + " 'scoff',\n", + " 'coccyxes',\n", + " 'meanly',\n", + " 'sprain',\n", + " 'minuend',\n", + " 'ringlet',\n", + " 'fest',\n", + " 'winced',\n", + " 'shinier',\n", + " 'dicier',\n", + " 'thirds',\n", + " 'olives',\n", + " 'garoting',\n", + " 'pastrami',\n", + " 'tranquil',\n", + " 'tamped',\n", + " 'sunup',\n", + " 'crumbled',\n", + " 'throw',\n", + " 'ridges',\n", + " 'chaplets',\n", + " 'curlier',\n", + " 'lugs',\n", + " 'collies',\n", + " 'adapting',\n", + " 'demeanor',\n", + " 'deepen',\n", + " 'lanyard',\n", + " 'tiller',\n", + " 'transfix',\n", + " 'wariness',\n", + " 'times',\n", + " 'mitts',\n", + " 'dowses',\n", + " 'creels',\n", + " 'curds',\n", + " 'quashed',\n", + " 'orgasmic',\n", + " 'ibex',\n", + " 'retraces',\n", + " 'casino']" + ] + }, + "execution_count": 89, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ds_original" + ] + }, + { + "cell_type": "code", + "execution_count": 99, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "grid = [['.', '.', '.', 'p', '.', 'm', 'o', 'w', 'n', '.'], ['.', 's', 'd', 's', 'e', '.', '.', 'e', 'e', '.'], ['.', 'e', '.', 'e', 'l', 'a', 'd', '.', 'c', 'r'], ['p', 'i', '.', 'd', 't', 'i', 'r', '.', 'a', 'h'], ['r', 'z', 's', 'i', 'w', 'o', 'v', 's', 'p', 'u'], ['o', 'a', 'w', 'h', '.', 'k', 'i', 'e', 'a', 'b'], ['b', 'r', 'o', 'w', '.', 'c', '.', 'r', 'd', 'a'], ['e', 'c', 'n', 'o', 't', 'o', 'p', 's', '.', 'r'], ['d', '.', 'k', 'c', '.', 'd', '.', '.', '.', 'b'], ['.', 's', 't', 'a', 'p', 'l', 'e', '.', '.', '.']]\n", + "padded_grid = [['f', 'h', 'j', 'p', 'a', 'm', 'o', 'w', 'n', 'q'], ['w', 's', 'd', 's', 'e', 'u', 'q', 'e', 'e', 'v'], ['i', 'e', 'a', 'e', 'l', 'a', 'd', 'h', 'c', 'r'], ['p', 'i', 'e', 'd', 't', 'i', 'r', 'i', 'a', 'h'], ['r', 'z', 's', 'i', 'w', 'o', 'v', 's', 'p', 'u'], ['o', 'a', 'w', 'h', 'a', 'k', 'i', 'e', 'a', 'b'], ['b', 'r', 'o', 'w', 'p', 'c', 'f', 'r', 'd', 'a'], ['e', 'c', 'n', 'o', 't', 'o', 'p', 's', 's', 'r'], ['d', 'i', 'k', 'c', 'h', 'd', 'n', 'p', 'n', 'b'], ['b', 's', 't', 'a', 'p', 'l', 'e', 'o', 'k', 'r']]\n", + "present_words = ['probed', 'staple', 'rioted', 'cowhides', 'tops', 'knows', 'lived', 'rhubarb', 'crazies', 'dock', 'apace', 'mown', 'pears', 'wide']\n", + "decoy_words = ['fickler', 'adapting', 'chump', 'foaming', 'molested', 'carnal', 'crumbled', 'guts', 'minuend', 'bombing', 'winced', 'coccyxes', 'solaria', 'shinier', 'cackles']\n", + "Directions: [('probed', '`(True, 3, 0, )`'), ('staple', '`(True, 9, 1, )`'), ('rioted', '`(True, 6, 7, )`'), ('cowhides', '`(True, 8, 3, )`'), ('tops', '`(True, 7, 4, )`'), ('knows', '`(True, 8, 2, )`'), ('lived', '`(True, 2, 4, )`'), ('rhubarb', '`(True, 2, 9, )`'), ('crazies', '`(True, 7, 1, )`'), ('dock', '`(True, 8, 5, )`'), ('apace', '`(True, 5, 8, )`'), ('mown', '`(True, 0, 5, )`'), ('pears', '`(True, 0, 3, )`'), ('wide', '`(True, 4, 4, )`')]\n" + ] + } + ], + "source": [ + "print('grid = ', g)\n", + "print('padded_grid = ', p)\n", + "print('present_words = ', ws)\n", + "print('decoy_words = ', ds)\n", + "print('Directions: ', [(w, '`' + str(present(g, w)) + '`') for w in ws])" + ] + }, + { + "cell_type": "code", + "execution_count": 100, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "# with open('example-wordsearch.txt', 'w') as f:\n", + "# f.write('10x10\\n')\n", + "# f.write(show_grid(p))\n", + "# f.write('\\n')\n", + "# f.write(lcat(sorted(ws + ds)))\n", + "# with open('exmaple-wordsearch-solution.txt', 'w') as f:\n", + "# f.write('10x10\\n')\n", + "# f.write(show_grid(g))\n", + "# f.write('\\n')\n", + "# f.write(lcat(sorted(ws)) + '\\n\\n')\n", + "# f.write(lcat(sorted(ds)))" + ] + }, + { + "cell_type": "code", + "execution_count": 77, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "probed 3 0 6 Direction.down [(3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0)]\n", + "staple 9 1 6 Direction.right [(9, 1), (9, 2), (9, 3), (9, 4), (9, 5), (9, 6)]\n", + "rioted 6 7 6 Direction.upleft [(6, 7), (5, 6), (4, 5), (3, 4), (2, 3), (1, 2)]\n", + "cowhides 8 3 8 Direction.up [(8, 3), (7, 3), (6, 3), (5, 3), (4, 3), (3, 3), (2, 3), (1, 3)]\n", + "tops 7 4 4 Direction.right [(7, 4), (7, 5), (7, 6), (7, 7)]\n", + "knows 8 2 5 Direction.up [(8, 2), (7, 2), (6, 2), (5, 2), (4, 2)]\n", + "lived 2 4 5 Direction.downright [(2, 4), (3, 5), (4, 6), (5, 7), (6, 8)]\n", + "rhubarb 2 9 7 Direction.down [(2, 9), (3, 9), (4, 9), (5, 9), (6, 9), (7, 9), (8, 9)]\n", + "crazies 7 1 7 Direction.up [(7, 1), (6, 1), (5, 1), (4, 1), (3, 1), (2, 1), (1, 1)]\n", + "dock 8 5 4 Direction.up [(8, 5), (7, 5), (6, 5), (5, 5)]\n", + "apace 5 8 5 Direction.up [(5, 8), (4, 8), (3, 8), (2, 8), (1, 8)]\n", + "mown 0 5 4 Direction.right [(0, 5), (0, 6), (0, 7), (0, 8)]\n", + "pears 0 3 5 Direction.downright [(0, 3), (1, 4), (2, 5), (3, 6), (4, 7)]\n", + "wide 4 4 4 Direction.upright [(4, 4), (3, 5), (2, 6), (1, 7)]\n" + ] + }, + { + "data": { + "text/plain": [ + "[(7, 5), (2, 3), (3, 5)]" + ] + }, + "execution_count": 77, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cts = collections.Counter()\n", + "for w in ws:\n", + " _, r, c, d = present(g, w)\n", + " inds = indices(g, r, c, len(w), d)\n", + " for i in inds:\n", + " cts[i] += 1\n", + " print(w, r, c, len(w), d, inds)\n", + "[i for i in cts if cts[i] > 1]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 143, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0\n", + "1\n", + "2\n", + "3\n", + "4\n", + "5\n", + "6\n", + "7\n", + "8\n", + "9\n", + "10\n", + "11\n", + "12\n", + "13\n", + "14\n", + "15\n", + "16\n", + "17\n", + "18\n", + "19\n", + "20\n", + "21\n", + "22\n", + "23\n", + "24\n", + "25\n", + "26\n", + "27\n", + "28\n", + "29\n", + "30\n", + "31\n", + "32\n", + "33\n", + "34\n", + "35\n", + "36\n", + "37\n", + "38\n", + "39\n", + "40\n", + "41\n", + "42\n", + "43\n", + "44\n", + "45\n", + "46\n", + "47\n", + "48\n", + "49\n", + "50\n", + "51\n", + "52\n", + "53\n", + "54\n", + "55\n", + "56\n", + "57\n", + "58\n", + "59\n", + "60\n", + "61\n", + "62\n", + "63\n", + "64\n", + "65\n", + "66\n", + "67\n", + "68\n", + "69\n", + "70\n", + "71\n", + "72\n", + "73\n", + "74\n", + "75\n", + "76\n", + "77\n", + "78\n", + "79\n", + "80\n", + "81\n", + "82\n", + "83\n", + "84\n", + "85\n", + "86\n", + "87\n", + "88\n", + "89\n", + "90\n", + "91\n", + "92\n", + "93\n", + "94\n", + "95\n", + "96\n", + "97\n", + "98\n", + "99\n" + ] + } + ], + "source": [ + "# for i in range(100):\n", + "# print(i)\n", + "# g, ws = interesting_grid()\n", + "# p = pad_grid(g)\n", + "# ds = decoys(p, ws, ws_words)\n", + "# with open('wordsearch{:02}.txt'.format(i), 'w') as f:\n", + "# f.write('20x20\\n')\n", + "# f.write(show_grid(p))\n", + "# f.write('\\n')\n", + "# f.write(lcat(sorted(ws + ds)))\n", + "# with open('wordsearch-solution{:02}.txt'.format(i), 'w') as f:\n", + "# f.write('20x20\\n')\n", + "# f.write(show_grid(g))\n", + "# f.write('\\n')\n", + "# f.write(lcat(sorted(ws)) + '\\n\\n')\n", + "# f.write(lcat(sorted(ds)))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.5.2+" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +} diff --git a/04-wordsearch/wordsearch-solution00.txt b/04-word-search/wordsearch-solution00.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution00.txt rename to 04-word-search/wordsearch-solution00.txt diff --git a/04-wordsearch/wordsearch-solution01.txt b/04-word-search/wordsearch-solution01.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution01.txt rename to 04-word-search/wordsearch-solution01.txt diff --git a/04-wordsearch/wordsearch-solution02.txt b/04-word-search/wordsearch-solution02.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution02.txt rename to 04-word-search/wordsearch-solution02.txt diff --git a/04-wordsearch/wordsearch-solution03.txt b/04-word-search/wordsearch-solution03.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution03.txt rename to 04-word-search/wordsearch-solution03.txt diff --git a/04-wordsearch/wordsearch-solution04.txt b/04-word-search/wordsearch-solution04.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution04.txt rename to 04-word-search/wordsearch-solution04.txt diff --git a/04-wordsearch/wordsearch-solution05.txt b/04-word-search/wordsearch-solution05.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution05.txt rename to 04-word-search/wordsearch-solution05.txt diff --git a/04-wordsearch/wordsearch-solution06.txt b/04-word-search/wordsearch-solution06.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution06.txt rename to 04-word-search/wordsearch-solution06.txt diff --git a/04-wordsearch/wordsearch-solution07.txt b/04-word-search/wordsearch-solution07.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution07.txt rename to 04-word-search/wordsearch-solution07.txt diff --git a/04-wordsearch/wordsearch-solution08.txt b/04-word-search/wordsearch-solution08.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution08.txt rename to 04-word-search/wordsearch-solution08.txt diff --git a/04-wordsearch/wordsearch-solution09.txt b/04-word-search/wordsearch-solution09.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution09.txt rename to 04-word-search/wordsearch-solution09.txt diff --git a/04-wordsearch/wordsearch-solution10.txt b/04-word-search/wordsearch-solution10.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution10.txt rename to 04-word-search/wordsearch-solution10.txt diff --git a/04-wordsearch/wordsearch-solution11.txt b/04-word-search/wordsearch-solution11.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution11.txt rename to 04-word-search/wordsearch-solution11.txt diff --git a/04-wordsearch/wordsearch-solution12.txt b/04-word-search/wordsearch-solution12.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution12.txt rename to 04-word-search/wordsearch-solution12.txt diff --git a/04-wordsearch/wordsearch-solution13.txt b/04-word-search/wordsearch-solution13.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution13.txt rename to 04-word-search/wordsearch-solution13.txt diff --git a/04-wordsearch/wordsearch-solution14.txt b/04-word-search/wordsearch-solution14.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution14.txt rename to 04-word-search/wordsearch-solution14.txt diff --git a/04-wordsearch/wordsearch-solution15.txt b/04-word-search/wordsearch-solution15.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution15.txt rename to 04-word-search/wordsearch-solution15.txt diff --git a/04-wordsearch/wordsearch-solution16.txt b/04-word-search/wordsearch-solution16.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution16.txt rename to 04-word-search/wordsearch-solution16.txt diff --git a/04-wordsearch/wordsearch-solution17.txt b/04-word-search/wordsearch-solution17.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution17.txt rename to 04-word-search/wordsearch-solution17.txt diff --git a/04-wordsearch/wordsearch-solution18.txt b/04-word-search/wordsearch-solution18.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution18.txt rename to 04-word-search/wordsearch-solution18.txt diff --git a/04-wordsearch/wordsearch-solution19.txt b/04-word-search/wordsearch-solution19.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution19.txt rename to 04-word-search/wordsearch-solution19.txt diff --git a/04-wordsearch/wordsearch-solution20.txt b/04-word-search/wordsearch-solution20.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution20.txt rename to 04-word-search/wordsearch-solution20.txt diff --git a/04-wordsearch/wordsearch-solution21.txt b/04-word-search/wordsearch-solution21.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution21.txt rename to 04-word-search/wordsearch-solution21.txt diff --git a/04-wordsearch/wordsearch-solution22.txt b/04-word-search/wordsearch-solution22.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution22.txt rename to 04-word-search/wordsearch-solution22.txt diff --git a/04-wordsearch/wordsearch-solution23.txt b/04-word-search/wordsearch-solution23.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution23.txt rename to 04-word-search/wordsearch-solution23.txt diff --git a/04-wordsearch/wordsearch-solution24.txt b/04-word-search/wordsearch-solution24.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution24.txt rename to 04-word-search/wordsearch-solution24.txt diff --git a/04-wordsearch/wordsearch-solution25.txt b/04-word-search/wordsearch-solution25.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution25.txt rename to 04-word-search/wordsearch-solution25.txt diff --git a/04-wordsearch/wordsearch-solution26.txt b/04-word-search/wordsearch-solution26.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution26.txt rename to 04-word-search/wordsearch-solution26.txt diff --git a/04-wordsearch/wordsearch-solution27.txt b/04-word-search/wordsearch-solution27.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution27.txt rename to 04-word-search/wordsearch-solution27.txt diff --git a/04-wordsearch/wordsearch-solution28.txt b/04-word-search/wordsearch-solution28.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution28.txt rename to 04-word-search/wordsearch-solution28.txt diff --git a/04-wordsearch/wordsearch-solution29.txt b/04-word-search/wordsearch-solution29.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution29.txt rename to 04-word-search/wordsearch-solution29.txt diff --git a/04-wordsearch/wordsearch-solution30.txt b/04-word-search/wordsearch-solution30.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution30.txt rename to 04-word-search/wordsearch-solution30.txt diff --git a/04-wordsearch/wordsearch-solution31.txt b/04-word-search/wordsearch-solution31.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution31.txt rename to 04-word-search/wordsearch-solution31.txt diff --git a/04-wordsearch/wordsearch-solution32.txt b/04-word-search/wordsearch-solution32.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution32.txt rename to 04-word-search/wordsearch-solution32.txt diff --git a/04-wordsearch/wordsearch-solution33.txt b/04-word-search/wordsearch-solution33.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution33.txt rename to 04-word-search/wordsearch-solution33.txt diff --git a/04-wordsearch/wordsearch-solution34.txt b/04-word-search/wordsearch-solution34.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution34.txt rename to 04-word-search/wordsearch-solution34.txt diff --git a/04-wordsearch/wordsearch-solution35.txt b/04-word-search/wordsearch-solution35.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution35.txt rename to 04-word-search/wordsearch-solution35.txt diff --git a/04-wordsearch/wordsearch-solution36.txt b/04-word-search/wordsearch-solution36.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution36.txt rename to 04-word-search/wordsearch-solution36.txt diff --git a/04-wordsearch/wordsearch-solution37.txt b/04-word-search/wordsearch-solution37.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution37.txt rename to 04-word-search/wordsearch-solution37.txt diff --git a/04-wordsearch/wordsearch-solution38.txt b/04-word-search/wordsearch-solution38.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution38.txt rename to 04-word-search/wordsearch-solution38.txt diff --git a/04-wordsearch/wordsearch-solution39.txt b/04-word-search/wordsearch-solution39.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution39.txt rename to 04-word-search/wordsearch-solution39.txt diff --git a/04-wordsearch/wordsearch-solution40.txt b/04-word-search/wordsearch-solution40.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution40.txt rename to 04-word-search/wordsearch-solution40.txt diff --git a/04-wordsearch/wordsearch-solution41.txt b/04-word-search/wordsearch-solution41.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution41.txt rename to 04-word-search/wordsearch-solution41.txt diff --git a/04-wordsearch/wordsearch-solution42.txt b/04-word-search/wordsearch-solution42.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution42.txt rename to 04-word-search/wordsearch-solution42.txt diff --git a/04-wordsearch/wordsearch-solution43.txt b/04-word-search/wordsearch-solution43.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution43.txt rename to 04-word-search/wordsearch-solution43.txt diff --git a/04-wordsearch/wordsearch-solution44.txt b/04-word-search/wordsearch-solution44.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution44.txt rename to 04-word-search/wordsearch-solution44.txt diff --git a/04-wordsearch/wordsearch-solution45.txt b/04-word-search/wordsearch-solution45.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution45.txt rename to 04-word-search/wordsearch-solution45.txt diff --git a/04-wordsearch/wordsearch-solution46.txt b/04-word-search/wordsearch-solution46.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution46.txt rename to 04-word-search/wordsearch-solution46.txt diff --git a/04-wordsearch/wordsearch-solution47.txt b/04-word-search/wordsearch-solution47.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution47.txt rename to 04-word-search/wordsearch-solution47.txt diff --git a/04-wordsearch/wordsearch-solution48.txt b/04-word-search/wordsearch-solution48.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution48.txt rename to 04-word-search/wordsearch-solution48.txt diff --git a/04-wordsearch/wordsearch-solution49.txt b/04-word-search/wordsearch-solution49.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution49.txt rename to 04-word-search/wordsearch-solution49.txt diff --git a/04-wordsearch/wordsearch-solution50.txt b/04-word-search/wordsearch-solution50.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution50.txt rename to 04-word-search/wordsearch-solution50.txt diff --git a/04-wordsearch/wordsearch-solution51.txt b/04-word-search/wordsearch-solution51.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution51.txt rename to 04-word-search/wordsearch-solution51.txt diff --git a/04-wordsearch/wordsearch-solution52.txt b/04-word-search/wordsearch-solution52.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution52.txt rename to 04-word-search/wordsearch-solution52.txt diff --git a/04-wordsearch/wordsearch-solution53.txt b/04-word-search/wordsearch-solution53.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution53.txt rename to 04-word-search/wordsearch-solution53.txt diff --git a/04-wordsearch/wordsearch-solution54.txt b/04-word-search/wordsearch-solution54.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution54.txt rename to 04-word-search/wordsearch-solution54.txt diff --git a/04-wordsearch/wordsearch-solution55.txt b/04-word-search/wordsearch-solution55.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution55.txt rename to 04-word-search/wordsearch-solution55.txt diff --git a/04-wordsearch/wordsearch-solution56.txt b/04-word-search/wordsearch-solution56.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution56.txt rename to 04-word-search/wordsearch-solution56.txt diff --git a/04-wordsearch/wordsearch-solution57.txt b/04-word-search/wordsearch-solution57.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution57.txt rename to 04-word-search/wordsearch-solution57.txt diff --git a/04-wordsearch/wordsearch-solution58.txt b/04-word-search/wordsearch-solution58.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution58.txt rename to 04-word-search/wordsearch-solution58.txt diff --git a/04-wordsearch/wordsearch-solution59.txt b/04-word-search/wordsearch-solution59.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution59.txt rename to 04-word-search/wordsearch-solution59.txt diff --git a/04-wordsearch/wordsearch-solution60.txt b/04-word-search/wordsearch-solution60.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution60.txt rename to 04-word-search/wordsearch-solution60.txt diff --git a/04-wordsearch/wordsearch-solution61.txt b/04-word-search/wordsearch-solution61.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution61.txt rename to 04-word-search/wordsearch-solution61.txt diff --git a/04-wordsearch/wordsearch-solution62.txt b/04-word-search/wordsearch-solution62.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution62.txt rename to 04-word-search/wordsearch-solution62.txt diff --git a/04-wordsearch/wordsearch-solution63.txt b/04-word-search/wordsearch-solution63.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution63.txt rename to 04-word-search/wordsearch-solution63.txt diff --git a/04-wordsearch/wordsearch-solution64.txt b/04-word-search/wordsearch-solution64.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution64.txt rename to 04-word-search/wordsearch-solution64.txt diff --git a/04-wordsearch/wordsearch-solution65.txt b/04-word-search/wordsearch-solution65.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution65.txt rename to 04-word-search/wordsearch-solution65.txt diff --git a/04-wordsearch/wordsearch-solution66.txt b/04-word-search/wordsearch-solution66.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution66.txt rename to 04-word-search/wordsearch-solution66.txt diff --git a/04-wordsearch/wordsearch-solution67.txt b/04-word-search/wordsearch-solution67.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution67.txt rename to 04-word-search/wordsearch-solution67.txt diff --git a/04-wordsearch/wordsearch-solution68.txt b/04-word-search/wordsearch-solution68.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution68.txt rename to 04-word-search/wordsearch-solution68.txt diff --git a/04-wordsearch/wordsearch-solution69.txt b/04-word-search/wordsearch-solution69.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution69.txt rename to 04-word-search/wordsearch-solution69.txt diff --git a/04-wordsearch/wordsearch-solution70.txt b/04-word-search/wordsearch-solution70.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution70.txt rename to 04-word-search/wordsearch-solution70.txt diff --git a/04-wordsearch/wordsearch-solution71.txt b/04-word-search/wordsearch-solution71.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution71.txt rename to 04-word-search/wordsearch-solution71.txt diff --git a/04-wordsearch/wordsearch-solution72.txt b/04-word-search/wordsearch-solution72.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution72.txt rename to 04-word-search/wordsearch-solution72.txt diff --git a/04-wordsearch/wordsearch-solution73.txt b/04-word-search/wordsearch-solution73.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution73.txt rename to 04-word-search/wordsearch-solution73.txt diff --git a/04-wordsearch/wordsearch-solution74.txt b/04-word-search/wordsearch-solution74.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution74.txt rename to 04-word-search/wordsearch-solution74.txt diff --git a/04-wordsearch/wordsearch-solution75.txt b/04-word-search/wordsearch-solution75.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution75.txt rename to 04-word-search/wordsearch-solution75.txt diff --git a/04-wordsearch/wordsearch-solution76.txt b/04-word-search/wordsearch-solution76.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution76.txt rename to 04-word-search/wordsearch-solution76.txt diff --git a/04-wordsearch/wordsearch-solution77.txt b/04-word-search/wordsearch-solution77.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution77.txt rename to 04-word-search/wordsearch-solution77.txt diff --git a/04-wordsearch/wordsearch-solution78.txt b/04-word-search/wordsearch-solution78.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution78.txt rename to 04-word-search/wordsearch-solution78.txt diff --git a/04-wordsearch/wordsearch-solution79.txt b/04-word-search/wordsearch-solution79.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution79.txt rename to 04-word-search/wordsearch-solution79.txt diff --git a/04-wordsearch/wordsearch-solution80.txt b/04-word-search/wordsearch-solution80.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution80.txt rename to 04-word-search/wordsearch-solution80.txt diff --git a/04-wordsearch/wordsearch-solution81.txt b/04-word-search/wordsearch-solution81.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution81.txt rename to 04-word-search/wordsearch-solution81.txt diff --git a/04-wordsearch/wordsearch-solution82.txt b/04-word-search/wordsearch-solution82.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution82.txt rename to 04-word-search/wordsearch-solution82.txt diff --git a/04-wordsearch/wordsearch-solution83.txt b/04-word-search/wordsearch-solution83.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution83.txt rename to 04-word-search/wordsearch-solution83.txt diff --git a/04-wordsearch/wordsearch-solution84.txt b/04-word-search/wordsearch-solution84.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution84.txt rename to 04-word-search/wordsearch-solution84.txt diff --git a/04-wordsearch/wordsearch-solution85.txt b/04-word-search/wordsearch-solution85.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution85.txt rename to 04-word-search/wordsearch-solution85.txt diff --git a/04-wordsearch/wordsearch-solution86.txt b/04-word-search/wordsearch-solution86.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution86.txt rename to 04-word-search/wordsearch-solution86.txt diff --git a/04-wordsearch/wordsearch-solution87.txt b/04-word-search/wordsearch-solution87.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution87.txt rename to 04-word-search/wordsearch-solution87.txt diff --git a/04-wordsearch/wordsearch-solution88.txt b/04-word-search/wordsearch-solution88.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution88.txt rename to 04-word-search/wordsearch-solution88.txt diff --git a/04-wordsearch/wordsearch-solution89.txt b/04-word-search/wordsearch-solution89.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution89.txt rename to 04-word-search/wordsearch-solution89.txt diff --git a/04-wordsearch/wordsearch-solution90.txt b/04-word-search/wordsearch-solution90.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution90.txt rename to 04-word-search/wordsearch-solution90.txt diff --git a/04-wordsearch/wordsearch-solution91.txt b/04-word-search/wordsearch-solution91.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution91.txt rename to 04-word-search/wordsearch-solution91.txt diff --git a/04-wordsearch/wordsearch-solution92.txt b/04-word-search/wordsearch-solution92.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution92.txt rename to 04-word-search/wordsearch-solution92.txt diff --git a/04-wordsearch/wordsearch-solution93.txt b/04-word-search/wordsearch-solution93.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution93.txt rename to 04-word-search/wordsearch-solution93.txt diff --git a/04-wordsearch/wordsearch-solution94.txt b/04-word-search/wordsearch-solution94.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution94.txt rename to 04-word-search/wordsearch-solution94.txt diff --git a/04-wordsearch/wordsearch-solution95.txt b/04-word-search/wordsearch-solution95.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution95.txt rename to 04-word-search/wordsearch-solution95.txt diff --git a/04-wordsearch/wordsearch-solution96.txt b/04-word-search/wordsearch-solution96.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution96.txt rename to 04-word-search/wordsearch-solution96.txt diff --git a/04-wordsearch/wordsearch-solution97.txt b/04-word-search/wordsearch-solution97.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution97.txt rename to 04-word-search/wordsearch-solution97.txt diff --git a/04-wordsearch/wordsearch-solution98.txt b/04-word-search/wordsearch-solution98.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution98.txt rename to 04-word-search/wordsearch-solution98.txt diff --git a/04-wordsearch/wordsearch-solution99.txt b/04-word-search/wordsearch-solution99.txt similarity index 100% rename from 04-wordsearch/wordsearch-solution99.txt rename to 04-word-search/wordsearch-solution99.txt diff --git a/04-wordsearch/wordsearch-solving.ipynb b/04-word-search/wordsearch-solving.ipynb similarity index 70% rename from 04-wordsearch/wordsearch-solving.ipynb rename to 04-word-search/wordsearch-solving.ipynb index b2c6c7e..86b1d9c 100644 --- a/04-wordsearch/wordsearch-solving.ipynb +++ b/04-word-search/wordsearch-solving.ipynb @@ -19,12 +19,50 @@ "3. A list of words, one word per line, of arbitrary length. " ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example\n", + "\n", + "\n", + "`...p.mown.\n", + ".sdse..ee.\n", + ".e.elad.cr\n", + "pi.dtir.ah\n", + "rzsiwovspu\n", + "oawh.kieab\n", + "brow.c.rda\n", + "ecnotops.r\n", + "d.kc.d...b\n", + ".staple...`\n", + "\n", + "```\n", + "fhjpamownq\n", + "wsdseuqeev\n", + "ieaeladhcr\n", + "piedtiriah\n", + "rzsiwovspu\n", + "oawhakieab\n", + "browpcfrda\n", + "ecnotopssr\n", + "dikchdnpnb\n", + "bstapleokr\n", + "```\n", + "\n", + "14 words added; 6 directions\n", + "\n", + "Present: apace cowhides crazies dock knows lived mown pears probed rhubarb rioted staple tops wide\n", + "\n", + "Decoys: adapting bombing boor brick cackles carnal casino chaplets chump coaster coccyxes coddle collies creels crumbled cunt curds curled curlier deepen demeanor dicier dowses ensuing faddish fest fickler foaming gambol garoting gliding gristle grunts guts ibex impugns instants kielbasy lanyard loamier lugs market meanly minuend misprint mitts molested moonshot mucking oaks olives orgasmic pastrami perfect proceed puckered quashed refined regards retraces revel ridges ringlet scoff shinier siren solaria sprain sunder sunup tamped tapes thirds throw tiller times trains tranquil transfix typesets uric wariness welts whimsy winced winced\n", + "\n", + "Directions: [('probed', '`(True, 3, 0, )`'), ('staple', '`(True, 9, 1, )`'), ('rioted', '`(True, 6, 7, )`'), ('cowhides', '`(True, 8, 3, )`'), ('tops', '`(True, 7, 4, )`'), ('knows', '`(True, 8, 2, )`'), ('lived', '`(True, 2, 4, )`'), ('rhubarb', '`(True, 2, 9, )`'), ('crazies', '`(True, 7, 1, )`'), ('dock', '`(True, 8, 5, )`'), ('apace', '`(True, 5, 8, )`'), ('mown', '`(True, 0, 5, )`'), ('pears', '`(True, 0, 3, )`'), ('wide', '`(True, 4, 4, )`')]" + ] + }, { "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": false - }, + "execution_count": 6, + "metadata": {}, "outputs": [], "source": [ "import string\n", @@ -48,7 +86,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 7, "metadata": { "collapsed": true }, @@ -60,7 +98,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 8, "metadata": { "collapsed": true }, @@ -72,7 +110,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 9, "metadata": { "collapsed": true }, @@ -92,7 +130,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 10, "metadata": { "collapsed": true }, @@ -104,7 +142,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 11, "metadata": { "collapsed": true }, @@ -118,7 +156,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 12, "metadata": { "collapsed": true }, @@ -137,10 +175,8 @@ }, { "cell_type": "code", - "execution_count": 22, - "metadata": { - "collapsed": false - }, + "execution_count": 13, + "metadata": {}, "outputs": [], "source": [ "def read_wordsearch(fn):\n", @@ -153,9 +189,8 @@ }, { "cell_type": "code", - "execution_count": 50, + "execution_count": 14, "metadata": { - "collapsed": false, "scrolled": true }, "outputs": [ @@ -284,7 +319,7 @@ " 'zings'])" ] }, - "execution_count": 50, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -296,9 +331,8 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 15, "metadata": { - "collapsed": false, "scrolled": true }, "outputs": [ @@ -423,9 +457,8 @@ }, { "cell_type": "code", - "execution_count": 52, + "execution_count": 16, "metadata": { - "collapsed": false, "scrolled": true }, "outputs": [ @@ -492,7 +525,7 @@ " 'zings']" ] }, - "execution_count": 52, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -510,10 +543,8 @@ }, { "cell_type": "code", - "execution_count": 53, - "metadata": { - "collapsed": false - }, + "execution_count": 17, + "metadata": {}, "outputs": [ { "data": { @@ -521,7 +552,7 @@ "'fortification'" ] }, - "execution_count": 53, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -539,10 +570,8 @@ }, { "cell_type": "code", - "execution_count": 54, - "metadata": { - "collapsed": false - }, + "execution_count": 18, + "metadata": {}, "outputs": [ { "data": { @@ -550,7 +579,7 @@ "'justification'" ] }, - "execution_count": 54, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } @@ -568,10 +597,8 @@ }, { "cell_type": "code", - "execution_count": 55, - "metadata": { - "collapsed": false - }, + "execution_count": 19, + "metadata": {}, "outputs": [ { "data": { @@ -579,7 +606,7 @@ "57" ] }, - "execution_count": 55, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } @@ -602,9 +629,8 @@ }, { "cell_type": "code", - "execution_count": 56, + "execution_count": 20, "metadata": { - "collapsed": false, "scrolled": true }, "outputs": [ @@ -633,7 +659,7 @@ " 'z': 1})" ] }, - "execution_count": 56, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } @@ -647,9 +673,8 @@ }, { "cell_type": "code", - "execution_count": 57, + "execution_count": 21, "metadata": { - "collapsed": false, "scrolled": true }, "outputs": [ @@ -700,7 +725,7 @@ " 'wardrobes']" ] }, - "execution_count": 57, + "execution_count": 21, "metadata": {}, "output_type": "execute_result" } @@ -712,9 +737,8 @@ }, { "cell_type": "code", - "execution_count": 59, + "execution_count": 22, "metadata": { - "collapsed": false, "scrolled": true }, "outputs": [ @@ -722,48 +746,48 @@ "name": "stdout", "output_type": "stream", "text": [ - "ancestor Counter({'c': 1, 'a': 1, 's': 1, 't': 1, 'n': 1, 'r': 1, 'o': 1, 'e': 1})\n", - "baritone Counter({'a': 1, 'i': 1, 'r': 1, 't': 1, 'b': 1, 'n': 1, 'o': 1, 'e': 1})\n", - "bemusing Counter({'g': 1, 'u': 1, 'i': 1, 's': 1, 'n': 1, 'm': 1, 'b': 1, 'e': 1})\n", - "blonds Counter({'s': 1, 'd': 1, 'n': 1, 'b': 1, 'o': 1, 'l': 1})\n", + "ancestor Counter({'c': 1, 'a': 1, 't': 1, 's': 1, 'r': 1, 'n': 1, 'e': 1, 'o': 1})\n", + "baritone Counter({'a': 1, 'r': 1, 'i': 1, 'b': 1, 't': 1, 'e': 1, 'o': 1, 'n': 1})\n", + "bemusing Counter({'g': 1, 'i': 1, 's': 1, 'u': 1, 'b': 1, 'm': 1, 'n': 1, 'e': 1})\n", + "blonds Counter({'d': 1, 's': 1, 'b': 1, 'n': 1, 'l': 1, 'o': 1})\n", "conciseness Counter({'s': 3, 'c': 2, 'n': 2, 'e': 2, 'i': 1, 'o': 1})\n", - "consequent Counter({'n': 2, 'e': 2, 'u': 1, 'c': 1, 's': 1, 't': 1, 'q': 1, 'o': 1})\n", - "cuddle Counter({'d': 2, 'u': 1, 'e': 1, 'c': 1, 'l': 1})\n", - "dashboards Counter({'a': 2, 's': 2, 'd': 2, 'o': 1, 'r': 1, 'b': 1, 'h': 1})\n", - "*despairing Counter({'i': 2, 'g': 1, 'a': 1, 's': 1, 'r': 1, 'd': 1, 'n': 1, 'p': 1, 'e': 1})\n", - "dint Counter({'d': 1, 'n': 1, 'i': 1, 't': 1})\n", - "employer Counter({'e': 2, 'y': 1, 'r': 1, 'm': 1, 'p': 1, 'o': 1, 'l': 1})\n", - "freakish Counter({'k': 1, 'a': 1, 'i': 1, 'r': 1, 'f': 1, 's': 1, 'h': 1, 'e': 1})\n", + "consequent Counter({'n': 2, 'e': 2, 'c': 1, 't': 1, 's': 1, 'u': 1, 'q': 1, 'o': 1})\n", + "cuddle Counter({'d': 2, 'c': 1, 'e': 1, 'l': 1, 'u': 1})\n", + "dashboards Counter({'a': 2, 's': 2, 'd': 2, 'r': 1, 'h': 1, 'b': 1, 'o': 1})\n", + "*despairing Counter({'i': 2, 'g': 1, 'a': 1, 'r': 1, 's': 1, 'p': 1, 'd': 1, 'e': 1, 'n': 1})\n", + "dint Counter({'d': 1, 'i': 1, 't': 1, 'n': 1})\n", + "employer Counter({'e': 2, 'r': 1, 'm': 1, 'p': 1, 'l': 1, 'y': 1, 'o': 1})\n", + "freakish Counter({'s': 1, 'a': 1, 'i': 1, 'r': 1, 'k': 1, 'h': 1, 'f': 1, 'e': 1})\n", "*gall Counter({'l': 2, 'g': 1, 'a': 1})\n", - "hopelessness Counter({'s': 4, 'e': 3, 'h': 1, 'n': 1, 'p': 1, 'o': 1, 'l': 1})\n", - "*impales Counter({'s': 1, 'a': 1, 'i': 1, 'm': 1, 'e': 1, 'p': 1, 'l': 1})\n", + "hopelessness Counter({'s': 4, 'e': 3, 'h': 1, 'p': 1, 'n': 1, 'l': 1, 'o': 1})\n", + "*impales Counter({'s': 1, 'a': 1, 'm': 1, 'p': 1, 'i': 1, 'l': 1, 'e': 1})\n", "infix Counter({'i': 2, 'f': 1, 'n': 1, 'x': 1})\n", - "inflow Counter({'i': 1, 'w': 1, 'f': 1, 'n': 1, 'o': 1, 'l': 1})\n", - "innumerable Counter({'n': 2, 'e': 2, 'u': 1, 'l': 1, 'a': 1, 'i': 1, 'r': 1, 'm': 1, 'b': 1})\n", - "intentional Counter({'n': 3, 'i': 2, 't': 2, 'a': 1, 'l': 1, 'o': 1, 'e': 1})\n", - "*jerkin Counter({'k': 1, 'i': 1, 'r': 1, 'n': 1, 'j': 1, 'e': 1})\n", - "justification Counter({'i': 3, 't': 2, 'u': 1, 'c': 1, 's': 1, 'n': 1, 'f': 1, 'j': 1, 'o': 1, 'a': 1})\n", - "leaving Counter({'g': 1, 'l': 1, 'a': 1, 'i': 1, 'n': 1, 'v': 1, 'e': 1})\n", - "locoweeds Counter({'o': 2, 'e': 2, 'c': 1, 's': 1, 'd': 1, 'w': 1, 'l': 1})\n", - "monickers Counter({'k': 1, 'c': 1, 's': 1, 'i': 1, 'r': 1, 'n': 1, 'm': 1, 'o': 1, 'e': 1})\n", - "originality Counter({'i': 3, 'g': 1, 'a': 1, 'r': 1, 't': 1, 'n': 1, 'y': 1, 'o': 1, 'l': 1})\n", - "outings Counter({'g': 1, 'u': 1, 's': 1, 'i': 1, 't': 1, 'n': 1, 'o': 1})\n", - "pendulous Counter({'u': 2, 's': 1, 'd': 1, 'n': 1, 'l': 1, 'p': 1, 'o': 1, 'e': 1})\n", - "pithier Counter({'i': 2, 'r': 1, 't': 1, 'p': 1, 'h': 1, 'e': 1})\n", - "randomness Counter({'s': 2, 'n': 2, 'a': 1, 'r': 1, 'd': 1, 'm': 1, 'o': 1, 'e': 1})\n", - "rectors Counter({'r': 2, 'c': 1, 's': 1, 't': 1, 'o': 1, 'e': 1})\n", - "redrew Counter({'e': 2, 'r': 2, 'd': 1, 'w': 1})\n", - "reformulated Counter({'r': 2, 'e': 2, 'u': 1, 'a': 1, 'f': 1, 't': 1, 'm': 1, 'l': 1, 'd': 1, 'o': 1})\n", - "remoteness Counter({'e': 3, 's': 2, 'r': 1, 't': 1, 'm': 1, 'n': 1, 'o': 1})\n", - "rethink Counter({'k': 1, 'i': 1, 'r': 1, 't': 1, 'n': 1, 'h': 1, 'e': 1})\n", - "scowls Counter({'s': 2, 'w': 1, 'c': 1, 'o': 1, 'l': 1})\n", - "sequencers Counter({'e': 3, 's': 2, 'u': 1, 'c': 1, 'r': 1, 'n': 1, 'q': 1})\n", - "serf Counter({'f': 1, 'r': 1, 's': 1, 'e': 1})\n", - "shook Counter({'o': 2, 'k': 1, 'h': 1, 's': 1})\n", - "spottiest Counter({'t': 3, 's': 2, 'i': 1, 'p': 1, 'o': 1, 'e': 1})\n", - "stood Counter({'o': 2, 'd': 1, 't': 1, 's': 1})\n", - "surtaxing Counter({'i': 1, 'u': 1, 'x': 1, 'g': 1, 'a': 1, 's': 1, 'r': 1, 't': 1, 'n': 1})\n", - "wardrobes Counter({'r': 2, 'a': 1, 's': 1, 'd': 1, 'w': 1, 'b': 1, 'o': 1, 'e': 1})\n" + "inflow Counter({'i': 1, 'w': 1, 'l': 1, 'n': 1, 'f': 1, 'o': 1})\n", + "innumerable Counter({'n': 2, 'e': 2, 'a': 1, 'l': 1, 'r': 1, 'm': 1, 'u': 1, 'b': 1, 'i': 1})\n", + "intentional Counter({'n': 3, 't': 2, 'i': 2, 'a': 1, 'l': 1, 'e': 1, 'o': 1})\n", + "*jerkin Counter({'r': 1, 'i': 1, 'j': 1, 'n': 1, 'e': 1, 'k': 1})\n", + "justification Counter({'i': 3, 't': 2, 'c': 1, 'a': 1, 'j': 1, 's': 1, 'u': 1, 'f': 1, 'o': 1, 'n': 1})\n", + "leaving Counter({'g': 1, 'a': 1, 'v': 1, 'i': 1, 'l': 1, 'n': 1, 'e': 1})\n", + "locoweeds Counter({'e': 2, 'o': 2, 'c': 1, 's': 1, 'w': 1, 'l': 1, 'd': 1})\n", + "monickers Counter({'c': 1, 'r': 1, 'i': 1, 's': 1, 'm': 1, 'n': 1, 'e': 1, 'o': 1, 'k': 1})\n", + "originality Counter({'i': 3, 'g': 1, 'a': 1, 'r': 1, 't': 1, 'n': 1, 'l': 1, 'y': 1, 'o': 1})\n", + "outings Counter({'g': 1, 'n': 1, 'i': 1, 'u': 1, 's': 1, 't': 1, 'o': 1})\n", + "pendulous Counter({'u': 2, 'd': 1, 's': 1, 'p': 1, 'l': 1, 'n': 1, 'e': 1, 'o': 1})\n", + "pithier Counter({'i': 2, 'r': 1, 'h': 1, 'p': 1, 't': 1, 'e': 1})\n", + "randomness Counter({'s': 2, 'n': 2, 'a': 1, 'r': 1, 'm': 1, 'd': 1, 'e': 1, 'o': 1})\n", + "rectors Counter({'r': 2, 'c': 1, 's': 1, 't': 1, 'e': 1, 'o': 1})\n", + "redrew Counter({'r': 2, 'e': 2, 'd': 1, 'w': 1})\n", + "reformulated Counter({'r': 2, 'e': 2, 'a': 1, 'l': 1, 'm': 1, 'u': 1, 't': 1, 'f': 1, 'd': 1, 'o': 1})\n", + "remoteness Counter({'e': 3, 's': 2, 'r': 1, 'm': 1, 't': 1, 'o': 1, 'n': 1})\n", + "rethink Counter({'r': 1, 'i': 1, 'h': 1, 'k': 1, 't': 1, 'e': 1, 'n': 1})\n", + "scowls Counter({'s': 2, 'c': 1, 'l': 1, 'o': 1, 'w': 1})\n", + "sequencers Counter({'e': 3, 's': 2, 'c': 1, 'r': 1, 'u': 1, 'q': 1, 'n': 1})\n", + "serf Counter({'e': 1, 'f': 1, 'r': 1, 's': 1})\n", + "shook Counter({'o': 2, 'k': 1, 's': 1, 'h': 1})\n", + "spottiest Counter({'t': 3, 's': 2, 'i': 1, 'p': 1, 'e': 1, 'o': 1})\n", + "stood Counter({'o': 2, 't': 1, 's': 1, 'd': 1})\n", + "surtaxing Counter({'g': 1, 'a': 1, 'i': 1, 'r': 1, 's': 1, 'u': 1, 'x': 1, 't': 1, 'n': 1})\n", + "wardrobes Counter({'r': 2, 'a': 1, 'b': 1, 's': 1, 'w': 1, 'd': 1, 'e': 1, 'o': 1})\n" ] } ], @@ -779,10 +803,8 @@ }, { "cell_type": "code", - "execution_count": 48, - "metadata": { - "collapsed": false - }, + "execution_count": 23, + "metadata": {}, "outputs": [ { "data": { @@ -790,7 +812,7 @@ "10" ] }, - "execution_count": 48, + "execution_count": 23, "metadata": {}, "output_type": "execute_result" } @@ -801,10 +823,8 @@ }, { "cell_type": "code", - "execution_count": 49, - "metadata": { - "collapsed": false - }, + "execution_count": 24, + "metadata": {}, "outputs": [ { "data": { @@ -812,7 +832,7 @@ "'despairing'" ] }, - "execution_count": 49, + "execution_count": 24, "metadata": {}, "output_type": "execute_result" } @@ -823,10 +843,8 @@ }, { "cell_type": "code", - "execution_count": 74, - "metadata": { - "collapsed": false - }, + "execution_count": 25, + "metadata": {}, "outputs": [], "source": [ "def do_wordsearch_tasks(fn, show_anyway=False):\n", @@ -863,10 +881,8 @@ }, { "cell_type": "code", - "execution_count": 75, - "metadata": { - "collapsed": false - }, + "execution_count": 26, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -888,10 +904,8 @@ }, { "cell_type": "code", - "execution_count": 70, - "metadata": { - "collapsed": false - }, + "execution_count": 27, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -913,9 +927,8 @@ }, { "cell_type": "code", - "execution_count": 76, + "execution_count": 28, "metadata": { - "collapsed": false, "scrolled": true }, "outputs": [ @@ -983,9 +996,9 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 29, "metadata": { - "collapsed": false + "scrolled": true }, "outputs": [ { @@ -1101,6 +1114,243 @@ " print(w, present(grid, w))" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example for question text" + ] + }, + { + "cell_type": "code", + "execution_count": 59, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "import copy\n", + "grid = [['.', '.', '.', 'p', '.', 'm', 'o', 'w', 'n', '.'], ['.', 's', 'd', 's', 'e', '.', '.', 'e', 'e', '.'], ['.', 'e', '.', 'e', 'l', 'a', 'd', '.', 'c', 'r'], ['p', 'i', '.', 'd', 't', 'i', 'r', '.', 'a', 'h'], ['r', 'z', 's', 'i', 'w', 'o', 'v', 's', 'p', 'u'], ['o', 'a', 'w', 'h', '.', 'k', 'i', 'e', 'a', 'b'], ['b', 'r', 'o', 'w', '.', 'c', '.', 'r', 'd', 'a'], ['e', 'c', 'n', 'o', 't', 'o', 'p', 's', '.', 'r'], ['d', '.', 'k', 'c', '.', 'd', '.', '.', '.', 'b'], ['.', 's', 't', 'a', 'p', 'l', 'e', '.', '.', '.']]\n", + "padded_grid = [['f', 'h', 'j', 'p', 'a', 'm', 'o', 'w', 'n', 'q'], ['w', 's', 'd', 's', 'e', 'u', 'q', 'e', 'e', 'v'], ['i', 'e', 'a', 'e', 'l', 'a', 'd', 'h', 'c', 'r'], ['p', 'i', 'e', 'd', 't', 'i', 'r', 'i', 'a', 'h'], ['r', 'z', 's', 'i', 'w', 'o', 'v', 's', 'p', 'u'], ['o', 'a', 'w', 'h', 'a', 'k', 'i', 'e', 'a', 'b'], ['b', 'r', 'o', 'w', 'p', 'c', 'f', 'r', 'd', 'a'], ['e', 'c', 'n', 'o', 't', 'o', 'p', 's', 's', 'r'], ['d', 'i', 'k', 'c', 'h', 'd', 'n', 'p', 'n', 'b'], ['b', 's', 't', 'a', 'p', 'l', 'e', 'o', 'k', 'r']]\n", + "present_words = ['probed', 'staple', 'rioted', 'cowhides', 'tops', 'knows', 'lived', 'rhubarb', 'crazies', 'dock', 'apace', 'mown', 'pears', 'wide']\n", + "decoy_words = ['fickler', 'adapting', 'chump', 'foaming', 'molested', 'carnal', 'crumbled', 'guts', 'minuend', 'bombing', 'winced', 'coccyxes', 'solaria', 'shinier', 'cackles']" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "probed 3 0 6 Direction.down [(3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0)]\n", + "staple 9 1 6 Direction.right [(9, 1), (9, 2), (9, 3), (9, 4), (9, 5), (9, 6)]\n", + "rioted 6 7 6 Direction.upleft [(6, 7), (5, 6), (4, 5), (3, 4), (2, 3), (1, 2)]\n", + "cowhides 8 3 8 Direction.up [(8, 3), (7, 3), (6, 3), (5, 3), (4, 3), (3, 3), (2, 3), (1, 3)]\n", + "tops 7 4 4 Direction.right [(7, 4), (7, 5), (7, 6), (7, 7)]\n", + "knows 8 2 5 Direction.up [(8, 2), (7, 2), (6, 2), (5, 2), (4, 2)]\n", + "lived 2 4 5 Direction.downright [(2, 4), (3, 5), (4, 6), (5, 7), (6, 8)]\n", + "rhubarb 2 9 7 Direction.down [(2, 9), (3, 9), (4, 9), (5, 9), (6, 9), (7, 9), (8, 9)]\n", + "crazies 7 1 7 Direction.up [(7, 1), (6, 1), (5, 1), (4, 1), (3, 1), (2, 1), (1, 1)]\n", + "dock 8 5 4 Direction.up [(8, 5), (7, 5), (6, 5), (5, 5)]\n", + "apace 5 8 5 Direction.up [(5, 8), (4, 8), (3, 8), (2, 8), (1, 8)]\n", + "mown 0 5 4 Direction.right [(0, 5), (0, 6), (0, 7), (0, 8)]\n", + "pears 0 3 5 Direction.downright [(0, 3), (1, 4), (2, 5), (3, 6), (4, 7)]\n", + "wide 4 4 4 Direction.upright [(4, 4), (3, 5), (2, 6), (1, 7)]\n" + ] + }, + { + "data": { + "text/plain": [ + "[(7, 5), (2, 3), (3, 5)]" + ] + }, + "execution_count": 41, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cts = collections.Counter()\n", + "for w in present_words:\n", + " _, r, c, d = present(grid, w)\n", + " inds = indices(grid, r, c, len(w), d)\n", + " for i in inds:\n", + " cts[i] += 1\n", + " print(w, r, c, len(w), d, inds)\n", + "[i for i in cts if cts[i] > 1]" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "example-wordsearch.txt\n", + "14 words present\n", + "Longest word present: cowhides, 8 letters (['cowhides'])\n", + "Longest word absent: molested, 8 letters (['adapting', 'coccyxes', 'crumbled', 'molested'])\n", + "27 unused letters\n", + "Longest makeable word: shinier, 7 (['shinier'])\n" + ] + } + ], + "source": [ + "do_wordsearch_tasks('example-wordsearch.txt', show_anyway=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "..........\n", + "..........\n", + "....l.....\n", + ".....i....\n", + "......v...\n", + ".......e..\n", + "........d.\n", + "..........\n", + "..........\n", + "..........\n" + ] + } + ], + "source": [ + "g = empty_grid(10, 10)\n", + "set_grid(g, 2, 4, Direction.downright, 'lived')\n", + "print(show_grid(g))" + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "..........\n", + ".......e..\n", + "....l.d...\n", + ".....i....\n", + "....w.v...\n", + ".......e..\n", + "........d.\n", + "..........\n", + "..........\n", + ".staple...\n" + ] + } + ], + "source": [ + "g = empty_grid(10, 10)\n", + "set_grid(g, 2, 4, Direction.downright, 'lived')\n", + "set_grid(g, 4, 4, Direction.upright, 'wide')\n", + "set_grid(g, 9, 1, Direction.right, 'staple')\n", + "print(show_grid(g))" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "..........\n", + "...s......\n", + "...e......\n", + "...d......\n", + "...i......\n", + "...h......\n", + "...w......\n", + "...o......\n", + "...c......\n", + "..........\n" + ] + } + ], + "source": [ + "g = empty_grid(10, 10)\n", + "set_grid(g, 8, 3, Direction.up, 'cowhides')\n", + "print(show_grid(g))" + ] + }, + { + "cell_type": "code", + "execution_count": 64, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "..........\n", + "..........\n", + "..........\n", + "..........\n", + "..........\n", + "..........\n", + "brow......\n", + "..........\n", + "..........\n", + "..........\n" + ] + } + ], + "source": [ + "# Example of word in grid that is English but isn't in the words listed in the puzzle.\n", + "g = empty_grid(10, 10)\n", + "set_grid(g, 6, 0, Direction.right, 'brow')\n", + "print(show_grid(g))" + ] + }, + { + "cell_type": "code", + "execution_count": 65, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "fhj.a....q\n", + "w....uq..v\n", + "i.a....h..\n", + "..e....i..\n", + "..........\n", + "....a.....\n", + "....p.f...\n", + "........s.\n", + ".i..h.npn.\n", + "b......okr\n" + ] + } + ], + "source": [ + "unused_grid = copy.deepcopy(padded_grid)\n", + "for w in present_words:\n", + " _, r, c, d = present(grid, w)\n", + " set_grid(unused_grid, r, c, d, '.' * len(w))\n", + "print(show_grid(unused_grid))" + ] + }, { "cell_type": "code", "execution_count": null, @@ -1127,9 +1377,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.2" + "version": "3.5.2+" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/04-wordsearch/wordsearch-words b/04-word-search/wordsearch-words similarity index 100% rename from 04-wordsearch/wordsearch-words rename to 04-word-search/wordsearch-words diff --git a/04-wordsearch/wordsearch00.txt b/04-word-search/wordsearch00.txt similarity index 100% rename from 04-wordsearch/wordsearch00.txt rename to 04-word-search/wordsearch00.txt diff --git a/04-wordsearch/wordsearch01.txt b/04-word-search/wordsearch01.txt similarity index 100% rename from 04-wordsearch/wordsearch01.txt rename to 04-word-search/wordsearch01.txt diff --git a/04-wordsearch/wordsearch02.txt b/04-word-search/wordsearch02.txt similarity index 100% rename from 04-wordsearch/wordsearch02.txt rename to 04-word-search/wordsearch02.txt diff --git a/04-wordsearch/wordsearch03.txt b/04-word-search/wordsearch03.txt similarity index 100% rename from 04-wordsearch/wordsearch03.txt rename to 04-word-search/wordsearch03.txt diff --git a/04-wordsearch/wordsearch04.txt b/04-word-search/wordsearch04.txt similarity index 100% rename from 04-wordsearch/wordsearch04.txt rename to 04-word-search/wordsearch04.txt diff --git a/04-wordsearch/wordsearch05.txt b/04-word-search/wordsearch05.txt similarity index 100% rename from 04-wordsearch/wordsearch05.txt rename to 04-word-search/wordsearch05.txt diff --git a/04-wordsearch/wordsearch06.txt b/04-word-search/wordsearch06.txt similarity index 100% rename from 04-wordsearch/wordsearch06.txt rename to 04-word-search/wordsearch06.txt diff --git a/04-wordsearch/wordsearch07.txt b/04-word-search/wordsearch07.txt similarity index 100% rename from 04-wordsearch/wordsearch07.txt rename to 04-word-search/wordsearch07.txt diff --git a/04-wordsearch/wordsearch08.txt b/04-word-search/wordsearch08.txt similarity index 100% rename from 04-wordsearch/wordsearch08.txt rename to 04-word-search/wordsearch08.txt diff --git a/04-wordsearch/wordsearch09.txt b/04-word-search/wordsearch09.txt similarity index 100% rename from 04-wordsearch/wordsearch09.txt rename to 04-word-search/wordsearch09.txt diff --git a/04-wordsearch/wordsearch10.txt b/04-word-search/wordsearch10.txt similarity index 100% rename from 04-wordsearch/wordsearch10.txt rename to 04-word-search/wordsearch10.txt diff --git a/04-wordsearch/wordsearch11.txt b/04-word-search/wordsearch11.txt similarity index 100% rename from 04-wordsearch/wordsearch11.txt rename to 04-word-search/wordsearch11.txt diff --git a/04-wordsearch/wordsearch12.txt b/04-word-search/wordsearch12.txt similarity index 100% rename from 04-wordsearch/wordsearch12.txt rename to 04-word-search/wordsearch12.txt diff --git a/04-wordsearch/wordsearch13.txt b/04-word-search/wordsearch13.txt similarity index 100% rename from 04-wordsearch/wordsearch13.txt rename to 04-word-search/wordsearch13.txt diff --git a/04-wordsearch/wordsearch14.txt b/04-word-search/wordsearch14.txt similarity index 100% rename from 04-wordsearch/wordsearch14.txt rename to 04-word-search/wordsearch14.txt diff --git a/04-wordsearch/wordsearch15.txt b/04-word-search/wordsearch15.txt similarity index 100% rename from 04-wordsearch/wordsearch15.txt rename to 04-word-search/wordsearch15.txt diff --git a/04-wordsearch/wordsearch16.txt b/04-word-search/wordsearch16.txt similarity index 100% rename from 04-wordsearch/wordsearch16.txt rename to 04-word-search/wordsearch16.txt diff --git a/04-wordsearch/wordsearch17.txt b/04-word-search/wordsearch17.txt similarity index 100% rename from 04-wordsearch/wordsearch17.txt rename to 04-word-search/wordsearch17.txt diff --git a/04-wordsearch/wordsearch18.txt b/04-word-search/wordsearch18.txt similarity index 100% rename from 04-wordsearch/wordsearch18.txt rename to 04-word-search/wordsearch18.txt diff --git a/04-wordsearch/wordsearch19.txt b/04-word-search/wordsearch19.txt similarity index 100% rename from 04-wordsearch/wordsearch19.txt rename to 04-word-search/wordsearch19.txt diff --git a/04-wordsearch/wordsearch20.txt b/04-word-search/wordsearch20.txt similarity index 100% rename from 04-wordsearch/wordsearch20.txt rename to 04-word-search/wordsearch20.txt diff --git a/04-wordsearch/wordsearch21.txt b/04-word-search/wordsearch21.txt similarity index 100% rename from 04-wordsearch/wordsearch21.txt rename to 04-word-search/wordsearch21.txt diff --git a/04-wordsearch/wordsearch22.txt b/04-word-search/wordsearch22.txt similarity index 100% rename from 04-wordsearch/wordsearch22.txt rename to 04-word-search/wordsearch22.txt diff --git a/04-wordsearch/wordsearch23.txt b/04-word-search/wordsearch23.txt similarity index 100% rename from 04-wordsearch/wordsearch23.txt rename to 04-word-search/wordsearch23.txt diff --git a/04-wordsearch/wordsearch24.txt b/04-word-search/wordsearch24.txt similarity index 100% rename from 04-wordsearch/wordsearch24.txt rename to 04-word-search/wordsearch24.txt diff --git a/04-wordsearch/wordsearch25.txt b/04-word-search/wordsearch25.txt similarity index 100% rename from 04-wordsearch/wordsearch25.txt rename to 04-word-search/wordsearch25.txt diff --git a/04-wordsearch/wordsearch26.txt b/04-word-search/wordsearch26.txt similarity index 100% rename from 04-wordsearch/wordsearch26.txt rename to 04-word-search/wordsearch26.txt diff --git a/04-wordsearch/wordsearch27.txt b/04-word-search/wordsearch27.txt similarity index 100% rename from 04-wordsearch/wordsearch27.txt rename to 04-word-search/wordsearch27.txt diff --git a/04-wordsearch/wordsearch28.txt b/04-word-search/wordsearch28.txt similarity index 100% rename from 04-wordsearch/wordsearch28.txt rename to 04-word-search/wordsearch28.txt diff --git a/04-wordsearch/wordsearch29.txt b/04-word-search/wordsearch29.txt similarity index 100% rename from 04-wordsearch/wordsearch29.txt rename to 04-word-search/wordsearch29.txt diff --git a/04-wordsearch/wordsearch30.txt b/04-word-search/wordsearch30.txt similarity index 100% rename from 04-wordsearch/wordsearch30.txt rename to 04-word-search/wordsearch30.txt diff --git a/04-wordsearch/wordsearch31.txt b/04-word-search/wordsearch31.txt similarity index 100% rename from 04-wordsearch/wordsearch31.txt rename to 04-word-search/wordsearch31.txt diff --git a/04-wordsearch/wordsearch32.txt b/04-word-search/wordsearch32.txt similarity index 100% rename from 04-wordsearch/wordsearch32.txt rename to 04-word-search/wordsearch32.txt diff --git a/04-wordsearch/wordsearch33.txt b/04-word-search/wordsearch33.txt similarity index 100% rename from 04-wordsearch/wordsearch33.txt rename to 04-word-search/wordsearch33.txt diff --git a/04-wordsearch/wordsearch34.txt b/04-word-search/wordsearch34.txt similarity index 100% rename from 04-wordsearch/wordsearch34.txt rename to 04-word-search/wordsearch34.txt diff --git a/04-wordsearch/wordsearch35.txt b/04-word-search/wordsearch35.txt similarity index 100% rename from 04-wordsearch/wordsearch35.txt rename to 04-word-search/wordsearch35.txt diff --git a/04-wordsearch/wordsearch36.txt b/04-word-search/wordsearch36.txt similarity index 100% rename from 04-wordsearch/wordsearch36.txt rename to 04-word-search/wordsearch36.txt diff --git a/04-wordsearch/wordsearch37.txt b/04-word-search/wordsearch37.txt similarity index 100% rename from 04-wordsearch/wordsearch37.txt rename to 04-word-search/wordsearch37.txt diff --git a/04-wordsearch/wordsearch38.txt b/04-word-search/wordsearch38.txt similarity index 100% rename from 04-wordsearch/wordsearch38.txt rename to 04-word-search/wordsearch38.txt diff --git a/04-wordsearch/wordsearch39.txt b/04-word-search/wordsearch39.txt similarity index 100% rename from 04-wordsearch/wordsearch39.txt rename to 04-word-search/wordsearch39.txt diff --git a/04-wordsearch/wordsearch40.txt b/04-word-search/wordsearch40.txt similarity index 100% rename from 04-wordsearch/wordsearch40.txt rename to 04-word-search/wordsearch40.txt diff --git a/04-wordsearch/wordsearch41.txt b/04-word-search/wordsearch41.txt similarity index 100% rename from 04-wordsearch/wordsearch41.txt rename to 04-word-search/wordsearch41.txt diff --git a/04-wordsearch/wordsearch42.txt b/04-word-search/wordsearch42.txt similarity index 100% rename from 04-wordsearch/wordsearch42.txt rename to 04-word-search/wordsearch42.txt diff --git a/04-wordsearch/wordsearch43.txt b/04-word-search/wordsearch43.txt similarity index 100% rename from 04-wordsearch/wordsearch43.txt rename to 04-word-search/wordsearch43.txt diff --git a/04-wordsearch/wordsearch44.txt b/04-word-search/wordsearch44.txt similarity index 100% rename from 04-wordsearch/wordsearch44.txt rename to 04-word-search/wordsearch44.txt diff --git a/04-wordsearch/wordsearch45.txt b/04-word-search/wordsearch45.txt similarity index 100% rename from 04-wordsearch/wordsearch45.txt rename to 04-word-search/wordsearch45.txt diff --git a/04-wordsearch/wordsearch46.txt b/04-word-search/wordsearch46.txt similarity index 100% rename from 04-wordsearch/wordsearch46.txt rename to 04-word-search/wordsearch46.txt diff --git a/04-wordsearch/wordsearch47.txt b/04-word-search/wordsearch47.txt similarity index 100% rename from 04-wordsearch/wordsearch47.txt rename to 04-word-search/wordsearch47.txt diff --git a/04-wordsearch/wordsearch48.txt b/04-word-search/wordsearch48.txt similarity index 100% rename from 04-wordsearch/wordsearch48.txt rename to 04-word-search/wordsearch48.txt diff --git a/04-wordsearch/wordsearch49.txt b/04-word-search/wordsearch49.txt similarity index 100% rename from 04-wordsearch/wordsearch49.txt rename to 04-word-search/wordsearch49.txt diff --git a/04-wordsearch/wordsearch50.txt b/04-word-search/wordsearch50.txt similarity index 100% rename from 04-wordsearch/wordsearch50.txt rename to 04-word-search/wordsearch50.txt diff --git a/04-wordsearch/wordsearch51.txt b/04-word-search/wordsearch51.txt similarity index 100% rename from 04-wordsearch/wordsearch51.txt rename to 04-word-search/wordsearch51.txt diff --git a/04-wordsearch/wordsearch52.txt b/04-word-search/wordsearch52.txt similarity index 100% rename from 04-wordsearch/wordsearch52.txt rename to 04-word-search/wordsearch52.txt diff --git a/04-wordsearch/wordsearch53.txt b/04-word-search/wordsearch53.txt similarity index 100% rename from 04-wordsearch/wordsearch53.txt rename to 04-word-search/wordsearch53.txt diff --git a/04-wordsearch/wordsearch54.txt b/04-word-search/wordsearch54.txt similarity index 100% rename from 04-wordsearch/wordsearch54.txt rename to 04-word-search/wordsearch54.txt diff --git a/04-wordsearch/wordsearch55.txt b/04-word-search/wordsearch55.txt similarity index 100% rename from 04-wordsearch/wordsearch55.txt rename to 04-word-search/wordsearch55.txt diff --git a/04-wordsearch/wordsearch56.txt b/04-word-search/wordsearch56.txt similarity index 100% rename from 04-wordsearch/wordsearch56.txt rename to 04-word-search/wordsearch56.txt diff --git a/04-wordsearch/wordsearch57.txt b/04-word-search/wordsearch57.txt similarity index 100% rename from 04-wordsearch/wordsearch57.txt rename to 04-word-search/wordsearch57.txt diff --git a/04-wordsearch/wordsearch58.txt b/04-word-search/wordsearch58.txt similarity index 100% rename from 04-wordsearch/wordsearch58.txt rename to 04-word-search/wordsearch58.txt diff --git a/04-wordsearch/wordsearch59.txt b/04-word-search/wordsearch59.txt similarity index 100% rename from 04-wordsearch/wordsearch59.txt rename to 04-word-search/wordsearch59.txt diff --git a/04-wordsearch/wordsearch60.txt b/04-word-search/wordsearch60.txt similarity index 100% rename from 04-wordsearch/wordsearch60.txt rename to 04-word-search/wordsearch60.txt diff --git a/04-wordsearch/wordsearch61.txt b/04-word-search/wordsearch61.txt similarity index 100% rename from 04-wordsearch/wordsearch61.txt rename to 04-word-search/wordsearch61.txt diff --git a/04-wordsearch/wordsearch62.txt b/04-word-search/wordsearch62.txt similarity index 100% rename from 04-wordsearch/wordsearch62.txt rename to 04-word-search/wordsearch62.txt diff --git a/04-wordsearch/wordsearch63.txt b/04-word-search/wordsearch63.txt similarity index 100% rename from 04-wordsearch/wordsearch63.txt rename to 04-word-search/wordsearch63.txt diff --git a/04-wordsearch/wordsearch64.txt b/04-word-search/wordsearch64.txt similarity index 100% rename from 04-wordsearch/wordsearch64.txt rename to 04-word-search/wordsearch64.txt diff --git a/04-wordsearch/wordsearch65.txt b/04-word-search/wordsearch65.txt similarity index 100% rename from 04-wordsearch/wordsearch65.txt rename to 04-word-search/wordsearch65.txt diff --git a/04-wordsearch/wordsearch66.txt b/04-word-search/wordsearch66.txt similarity index 100% rename from 04-wordsearch/wordsearch66.txt rename to 04-word-search/wordsearch66.txt diff --git a/04-wordsearch/wordsearch67.txt b/04-word-search/wordsearch67.txt similarity index 100% rename from 04-wordsearch/wordsearch67.txt rename to 04-word-search/wordsearch67.txt diff --git a/04-wordsearch/wordsearch68.txt b/04-word-search/wordsearch68.txt similarity index 100% rename from 04-wordsearch/wordsearch68.txt rename to 04-word-search/wordsearch68.txt diff --git a/04-wordsearch/wordsearch69.txt b/04-word-search/wordsearch69.txt similarity index 100% rename from 04-wordsearch/wordsearch69.txt rename to 04-word-search/wordsearch69.txt diff --git a/04-wordsearch/wordsearch70.txt b/04-word-search/wordsearch70.txt similarity index 100% rename from 04-wordsearch/wordsearch70.txt rename to 04-word-search/wordsearch70.txt diff --git a/04-wordsearch/wordsearch71.txt b/04-word-search/wordsearch71.txt similarity index 100% rename from 04-wordsearch/wordsearch71.txt rename to 04-word-search/wordsearch71.txt diff --git a/04-wordsearch/wordsearch72.txt b/04-word-search/wordsearch72.txt similarity index 100% rename from 04-wordsearch/wordsearch72.txt rename to 04-word-search/wordsearch72.txt diff --git a/04-wordsearch/wordsearch73.txt b/04-word-search/wordsearch73.txt similarity index 100% rename from 04-wordsearch/wordsearch73.txt rename to 04-word-search/wordsearch73.txt diff --git a/04-wordsearch/wordsearch74.txt b/04-word-search/wordsearch74.txt similarity index 100% rename from 04-wordsearch/wordsearch74.txt rename to 04-word-search/wordsearch74.txt diff --git a/04-wordsearch/wordsearch75.txt b/04-word-search/wordsearch75.txt similarity index 100% rename from 04-wordsearch/wordsearch75.txt rename to 04-word-search/wordsearch75.txt diff --git a/04-wordsearch/wordsearch76.txt b/04-word-search/wordsearch76.txt similarity index 100% rename from 04-wordsearch/wordsearch76.txt rename to 04-word-search/wordsearch76.txt diff --git a/04-wordsearch/wordsearch77.txt b/04-word-search/wordsearch77.txt similarity index 100% rename from 04-wordsearch/wordsearch77.txt rename to 04-word-search/wordsearch77.txt diff --git a/04-wordsearch/wordsearch78.txt b/04-word-search/wordsearch78.txt similarity index 100% rename from 04-wordsearch/wordsearch78.txt rename to 04-word-search/wordsearch78.txt diff --git a/04-wordsearch/wordsearch79.txt b/04-word-search/wordsearch79.txt similarity index 100% rename from 04-wordsearch/wordsearch79.txt rename to 04-word-search/wordsearch79.txt diff --git a/04-wordsearch/wordsearch80.txt b/04-word-search/wordsearch80.txt similarity index 100% rename from 04-wordsearch/wordsearch80.txt rename to 04-word-search/wordsearch80.txt diff --git a/04-wordsearch/wordsearch81.txt b/04-word-search/wordsearch81.txt similarity index 100% rename from 04-wordsearch/wordsearch81.txt rename to 04-word-search/wordsearch81.txt diff --git a/04-wordsearch/wordsearch82.txt b/04-word-search/wordsearch82.txt similarity index 100% rename from 04-wordsearch/wordsearch82.txt rename to 04-word-search/wordsearch82.txt diff --git a/04-wordsearch/wordsearch83.txt b/04-word-search/wordsearch83.txt similarity index 100% rename from 04-wordsearch/wordsearch83.txt rename to 04-word-search/wordsearch83.txt diff --git a/04-wordsearch/wordsearch84.txt b/04-word-search/wordsearch84.txt similarity index 100% rename from 04-wordsearch/wordsearch84.txt rename to 04-word-search/wordsearch84.txt diff --git a/04-wordsearch/wordsearch85.txt b/04-word-search/wordsearch85.txt similarity index 100% rename from 04-wordsearch/wordsearch85.txt rename to 04-word-search/wordsearch85.txt diff --git a/04-wordsearch/wordsearch86.txt b/04-word-search/wordsearch86.txt similarity index 100% rename from 04-wordsearch/wordsearch86.txt rename to 04-word-search/wordsearch86.txt diff --git a/04-wordsearch/wordsearch87.txt b/04-word-search/wordsearch87.txt similarity index 100% rename from 04-wordsearch/wordsearch87.txt rename to 04-word-search/wordsearch87.txt diff --git a/04-wordsearch/wordsearch88.txt b/04-word-search/wordsearch88.txt similarity index 100% rename from 04-wordsearch/wordsearch88.txt rename to 04-word-search/wordsearch88.txt diff --git a/04-wordsearch/wordsearch89.txt b/04-word-search/wordsearch89.txt similarity index 100% rename from 04-wordsearch/wordsearch89.txt rename to 04-word-search/wordsearch89.txt diff --git a/04-wordsearch/wordsearch90.txt b/04-word-search/wordsearch90.txt similarity index 100% rename from 04-wordsearch/wordsearch90.txt rename to 04-word-search/wordsearch90.txt diff --git a/04-wordsearch/wordsearch91.txt b/04-word-search/wordsearch91.txt similarity index 100% rename from 04-wordsearch/wordsearch91.txt rename to 04-word-search/wordsearch91.txt diff --git a/04-wordsearch/wordsearch92.txt b/04-word-search/wordsearch92.txt similarity index 100% rename from 04-wordsearch/wordsearch92.txt rename to 04-word-search/wordsearch92.txt diff --git a/04-wordsearch/wordsearch93.txt b/04-word-search/wordsearch93.txt similarity index 100% rename from 04-wordsearch/wordsearch93.txt rename to 04-word-search/wordsearch93.txt diff --git a/04-wordsearch/wordsearch94.txt b/04-word-search/wordsearch94.txt similarity index 100% rename from 04-wordsearch/wordsearch94.txt rename to 04-word-search/wordsearch94.txt diff --git a/04-wordsearch/wordsearch95.txt b/04-word-search/wordsearch95.txt similarity index 100% rename from 04-wordsearch/wordsearch95.txt rename to 04-word-search/wordsearch95.txt diff --git a/04-wordsearch/wordsearch96.txt b/04-word-search/wordsearch96.txt similarity index 100% rename from 04-wordsearch/wordsearch96.txt rename to 04-word-search/wordsearch96.txt diff --git a/04-wordsearch/wordsearch97.txt b/04-word-search/wordsearch97.txt similarity index 100% rename from 04-wordsearch/wordsearch97.txt rename to 04-word-search/wordsearch97.txt diff --git a/04-wordsearch/wordsearch98.txt b/04-word-search/wordsearch98.txt similarity index 100% rename from 04-wordsearch/wordsearch98.txt rename to 04-word-search/wordsearch98.txt diff --git a/04-wordsearch/wordsearch99.txt b/04-word-search/wordsearch99.txt similarity index 100% rename from 04-wordsearch/wordsearch99.txt rename to 04-word-search/wordsearch99.txt diff --git a/04-wordsearch/wordsearch-creation.ipynb b/04-wordsearch/wordsearch-creation.ipynb deleted file mode 100644 index 8a81e74..0000000 --- a/04-wordsearch/wordsearch-creation.ipynb +++ /dev/null @@ -1,1345 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 65, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "import string\n", - "import re\n", - "import random\n", - "import collections\n", - "import copy\n", - "\n", - "from enum import Enum\n", - "Direction = Enum('Direction', 'left right up down upleft upright downleft downright')\n", - " \n", - "delta = {Direction.left: (0, -1),Direction.right: (0, 1), \n", - " Direction.up: (-1, 0), Direction.down: (1, 0), \n", - " Direction.upleft: (-1, -1), Direction.upright: (-1, 1), \n", - " Direction.downleft: (1, -1), Direction.downright: (1, 1)}\n", - "\n", - "cat = ''.join\n", - "wcat = ' '.join\n", - "lcat = '\\n'.join" - ] - }, - { - "cell_type": "code", - "execution_count": 66, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "# all_words = [w.strip() for w in open('/usr/share/dict/british-english').readlines()\n", - "# if all(c in string.ascii_lowercase for c in w.strip())]\n", - "# words = [w for w in all_words\n", - "# if not any(w in w2 for w2 in all_words if w != w2)]\n", - "# open('wordsearch-words', 'w').write(lcat(words))" - ] - }, - { - "cell_type": "code", - "execution_count": 67, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "# ws_words = [w.strip() for w in open('wordsearch-words').readlines()\n", - "# if all(c in string.ascii_lowercase for c in w.strip())]\n", - "# ws_words[:10]" - ] - }, - { - "cell_type": "code", - "execution_count": 68, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "ws_words = [w.strip() for w in open('/usr/share/dict/british-english').readlines()\n", - " if all(c in string.ascii_lowercase for c in w.strip())]" - ] - }, - { - "cell_type": "code", - "execution_count": 69, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "def empty_grid(w, h):\n", - " return [['.' for c in range(w)] for r in range(h)]" - ] - }, - { - "cell_type": "code", - "execution_count": 70, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "def show_grid(grid):\n", - " return lcat(cat(r) for r in grid)" - ] - }, - { - "cell_type": "code", - "execution_count": 71, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "..........\n", - "..........\n", - "..........\n", - "..........\n", - "..........\n", - "..........\n", - "..........\n", - "..........\n", - "..........\n", - "..........\n" - ] - } - ], - "source": [ - "grid = empty_grid(10, 10)\n", - "print(show_grid(grid))" - ] - }, - { - "cell_type": "code", - "execution_count": 72, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "def indices(grid, r, c, l, d):\n", - " dr, dc = delta[d]\n", - " w = len(grid[0])\n", - " h = len(grid)\n", - " inds = [(r + i * dr, c + i * dc) for i in range(l)]\n", - " return [(i, j) for i, j in inds\n", - " if i >= 0\n", - " if j >= 0\n", - " if i < h\n", - " if j < w]" - ] - }, - { - "cell_type": "code", - "execution_count": 73, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "def gslice(grid, r, c, l, d):\n", - " return [grid[i][j] for i, j in indices(grid, r, c, l, d)]" - ] - }, - { - "cell_type": "code", - "execution_count": 74, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "def set_grid(grid, r, c, d, word):\n", - " for (i, j), l in zip(indices(grid, r, c, len(word), d), word):\n", - " grid[i][j] = l\n", - " return grid" - ] - }, - { - "cell_type": "code", - "execution_count": 75, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "..........\n", - "..........\n", - "...t......\n", - "....e.....\n", - ".....s....\n", - "......t...\n", - ".......w..\n", - "........o.\n", - ".........r\n", - "..........\n" - ] - } - ], - "source": [ - "set_grid(grid, 2, 3, Direction.downright, 'testword')\n", - "print(show_grid(grid))" - ] - }, - { - "cell_type": "code", - "execution_count": 76, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "'..e.....'" - ] - }, - "execution_count": 76, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "cat(gslice(grid, 3, 2, 15, Direction.right))" - ] - }, - { - "cell_type": "code", - "execution_count": 77, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "<_sre.SRE_Match object; span=(0, 4), match='keen'>" - ] - }, - "execution_count": 77, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "re.match(cat(gslice(grid, 3, 2, 4, Direction.right)), 'keen')" - ] - }, - { - "cell_type": "code", - "execution_count": 78, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "<_sre.SRE_Match object; span=(0, 3), match='kee'>" - ] - }, - "execution_count": 78, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "re.match(cat(gslice(grid, 3, 2, 3, Direction.right)), 'keen')" - ] - }, - { - "cell_type": "code", - "execution_count": 79, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "re.fullmatch(cat(gslice(grid, 3, 2, 3, Direction.right)), 'keen')" - ] - }, - { - "cell_type": "code", - "execution_count": 80, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "re.match(cat(gslice(grid, 3, 2, 4, Direction.right)), 'kine')" - ] - }, - { - "cell_type": "code", - "execution_count": 81, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "def could_add(grid, r, c, d, word):\n", - " s = gslice(grid, r, c, len(word), d)\n", - " return re.fullmatch(cat(s), word)" - ] - }, - { - "cell_type": "code", - "execution_count": 82, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "<_sre.SRE_Match object; span=(0, 4), match='keen'>" - ] - }, - "execution_count": 82, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "could_add(grid, 3, 2, Direction.right, 'keen')" - ] - }, - { - "cell_type": "code", - "execution_count": 83, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "could_add(grid, 3, 2, Direction.right, 'kine')" - ] - }, - { - "cell_type": "code", - "execution_count": 84, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 84, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "random.choice(list(Direction))" - ] - }, - { - "cell_type": "code", - "execution_count": 129, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "def fill_grid(grid, words, word_count, max_attempts=10000):\n", - " attempts = 0\n", - " added_words = []\n", - " w = len(grid[0])\n", - " h = len(grid)\n", - " while len(added_words) < word_count and attempts < max_attempts:\n", - " attempts += 1\n", - " r = random.randrange(w)\n", - " c = random.randrange(h)\n", - " word = random.choice(words)\n", - " d = random.choice(list(Direction))\n", - " if len(word) >=4 and not any(word in w2 for w2 in added_words) and could_add(grid, r, c, d, word):\n", - " set_grid(grid, r, c, d, word)\n", - " added_words += [word]\n", - " attempts = 0\n", - " return grid, added_words" - ] - }, - { - "cell_type": "code", - "execution_count": 86, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "40" - ] - }, - "execution_count": 86, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "g = empty_grid(20, 20)\n", - "g, ws = fill_grid(g, ws_words, 40)\n", - "len(ws)" - ] - }, - { - "cell_type": "code", - "execution_count": 87, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "l.fiestasrsnorffas..\n", - "a....s..e.a.cawing..\n", - "c..gt.dv.re.strongly\n", - "i..n..aecmbp....y...\n", - "m.eo.uthzoa.of..l.s.\n", - "od.lq.esozslhhlyo.k.\n", - "ns.e.r.se.ureanoh.r.\n", - "o.wby.t.aw.foin.u.u.\n", - "ca.o....i.a.to.d.rms\n", - "en..l...lerrs.d.i.sk\n", - "no...l..i.snalgarn.n\n", - "un....a.crappiest.gi\n", - ".y.....mdepraved..dw\n", - ".mgniggolricochet.ey\n", - ".o..pensivelyibmozil\n", - ".u.......curd.....fd\n", - ".sseitudlevehsid..id\n", - "...litchis..romut.ri\n", - ".understands......et\n", - "....nagilooh......v.\n", - "40 words added\n", - "understands crappiest archery mallows depraved cawing rawest curd tiny tiddlywinks fiestas zombi duties ricochet uneconomical hope litchis strongly verified logging handing anonymous quaver flours boost holy saffrons errs hooligan male belong tumor dishevel fuzzed raglans pensively murks dents cilia doors\n" - ] - } - ], - "source": [ - "print(show_grid(g))\n", - "print(len(ws), 'words added')\n", - "print(wcat(ws))" - ] - }, - { - "cell_type": "code", - "execution_count": 88, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "def present(grid, word):\n", - " w = len(grid[0])\n", - " h = len(grid)\n", - " for r in range(h):\n", - " for c in range(w):\n", - " for d in Direction:\n", - " if cat(gslice(grid, r, c, len(word), d)) == word:\n", - " return True, r, c, d\n", - " return False, 0, 0, list(Direction)[0]" - ] - }, - { - "cell_type": "code", - "execution_count": 89, - "metadata": { - "collapsed": false, - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "understands (True, 18, 1, )\n", - "crappiest (True, 11, 8, )\n", - "archery (True, 1, 10, )\n", - "mallows (True, 12, 7, )\n", - "depraved (True, 12, 8, )\n", - "cawing (True, 1, 12, )\n", - "rawest (True, 9, 11, )\n", - "curd (True, 15, 9, )\n", - "tiny (True, 8, 12, )\n", - "tiddlywinks (True, 18, 19, )\n", - "fiestas (True, 0, 2, )\n", - "zombi (True, 14, 17, )\n", - "duties (True, 16, 7, )\n", - "ricochet (True, 13, 9, )\n", - "uneconomical (True, 11, 0, )\n", - "hope (True, 5, 13, )\n", - "litchis (True, 17, 3, )\n", - "strongly (True, 2, 12, )\n", - "verified (True, 19, 18, )\n", - "logging (True, 13, 8, )\n", - "handing (True, 5, 12, )\n", - "anonymous (True, 8, 1, )\n", - "quaver (True, 5, 4, )\n", - "flours (True, 4, 13, )\n", - "boost (True, 3, 10, )\n", - "holy (True, 6, 16, )\n", - "saffrons (True, 0, 17, )\n", - "errs (True, 9, 9, )\n", - "hooligan (True, 19, 11, )\n", - "male (True, 3, 9, )\n", - "belong (True, 7, 3, )\n", - "tumor (True, 17, 16, )\n", - "dishevel (True, 16, 15, )\n", - "fuzzed (True, 7, 11, )\n", - "raglans (True, 10, 16, )\n", - "pensively (True, 14, 4, )\n", - "murks (True, 8, 18, )\n", - "dents (True, 5, 1, )\n", - "cilia (True, 11, 8, )\n", - "doors (True, 9, 14, )\n" - ] - } - ], - "source": [ - "for w in ws:\n", - " print(w, present(g, w))" - ] - }, - { - "cell_type": "code", - "execution_count": 125, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "def interesting(grid, words):\n", - " dirs = set(present(grid, w)[3] for w in words)\n", - " return len(words) > 40 and len(dirs) + 1 >= len(delta)" - ] - }, - { - "cell_type": "code", - "execution_count": 126, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "False" - ] - }, - "execution_count": 126, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "interesting(g, ws)" - ] - }, - { - "cell_type": "code", - "execution_count": 131, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "def interesting_grid():\n", - " boring = True\n", - " while boring:\n", - " grid = empty_grid(20, 20)\n", - " grid, words = fill_grid(grid, ws_words, 80)\n", - " boring = not interesting(grid, words)\n", - " return grid, words" - ] - }, - { - "cell_type": "code", - "execution_count": 132, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "....gnixof...keem...\n", - "feihc.spollawvase..s\n", - "p.h.shs..snetsafnun.\n", - "aeiy.adt..plehdowned\n", - "rmcfmzhennaturali.h.\n", - "abkake.pteebyelawsay\n", - "dlcweln.lnmvrdrawllr\n", - "ealnes.s.aeeieslaroe\n", - ".zaelreffidclwl...gs\n", - ".omtisadeelbst.bg.ei\n", - ".noantr...tunet.o.nm\n", - "serigamchamoixbemnsb\n", - "sd.tnuu..lleterls..e\n", - "e.dounf..dekcalsu..s\n", - "gyegtcfknobetatser.t\n", - "rlkeshskcelf..ploptr\n", - "alon.l..sriahdawnsgi\n", - "lac..y..gnittilps.od\n", - ".eyeball..denedragse\n", - ".r..ygnamsecstirg.hs\n", - "57 words added; 7 directions\n", - "chamoix staunchly keeling wive inns restate settlements byelaws blurt help foxing flecks orals differ unfastens mangy hymens wallops negotiate bestrides largess dawns nobler chief eyeball splitting bleed halogens clamor parade emblazoned hairs meek earmuff slacked retell scented gardened natural grits misery drawl gosh smog stung coked knob tune really secs plop alphas vase downed hazels hick fawn\n" - ] - } - ], - "source": [ - "g, ws = interesting_grid()\n", - "print(show_grid(g))\n", - "print(len(ws), 'words added; ', len(set(present(g, w)[3] for w in ws)), 'directions')\n", - "print(wcat(ws))" - ] - }, - { - "cell_type": "code", - "execution_count": 94, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "def datafile(name, sep='\\t'):\n", - " \"\"\"Read key,value pairs from file.\n", - " \"\"\"\n", - " with open(name) as f:\n", - " for line in f:\n", - " splits = line.split(sep)\n", - " yield [splits[0], int(splits[1])]" - ] - }, - { - "cell_type": "code", - "execution_count": 95, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "def normalise(frequencies):\n", - " \"\"\"Scale a set of frequencies so they sum to one\n", - " \n", - " >>> sorted(normalise({1: 1, 2: 0}).items())\n", - " [(1, 1.0), (2, 0.0)]\n", - " >>> sorted(normalise({1: 1, 2: 1}).items())\n", - " [(1, 0.5), (2, 0.5)]\n", - " >>> sorted(normalise({1: 1, 2: 1, 3: 1}).items()) # doctest: +ELLIPSIS\n", - " [(1, 0.333...), (2, 0.333...), (3, 0.333...)]\n", - " >>> sorted(normalise({1: 1, 2: 2, 3: 1}).items())\n", - " [(1, 0.25), (2, 0.5), (3, 0.25)]\n", - " \"\"\"\n", - " length = sum(f for f in frequencies.values())\n", - " return collections.defaultdict(int, ((k, v / length) \n", - " for (k, v) in frequencies.items()))\n" - ] - }, - { - "cell_type": "code", - "execution_count": 96, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "english_counts = collections.Counter(dict(datafile('count_1l.txt')))\n", - "normalised_english_counts = normalise(english_counts)" - ] - }, - { - "cell_type": "code", - "execution_count": 97, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "wordsearch_counts = collections.Counter(cat(ws_words))\n", - "normalised_wordsearch_counts = normalise(wordsearch_counts)" - ] - }, - { - "cell_type": "code", - "execution_count": 118, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "normalised_wordsearch_counts = normalise(collections.Counter(normalised_wordsearch_counts) + collections.Counter({l: 0.05 for l in string.ascii_lowercase}))" - ] - }, - { - "cell_type": "code", - "execution_count": 98, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "def weighted_choice(d):\n", - " \"\"\"Generate random item from a dictionary of item counts\n", - " \"\"\"\n", - " target = random.uniform(0, sum(d.values()))\n", - " cuml = 0.0\n", - " for (l, p) in d.items():\n", - " cuml += p\n", - " if cuml > target:\n", - " return l\n", - " return None\n", - "\n", - "def random_english_letter():\n", - " \"\"\"Generate a random letter based on English letter counts\n", - " \"\"\"\n", - " return weighted_choice(normalised_english_counts)\n", - "\n", - "def random_wordsearch_letter():\n", - " \"\"\"Generate a random letter based on wordsearch letter counts\n", - " \"\"\"\n", - " return weighted_choice(normalised_wordsearch_counts)" - ] - }, - { - "cell_type": "code", - "execution_count": 99, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "'aaaaaaaaaabcdddeeeeeeeeeeeefffffgghhhhhhhhhiiiiiiikllmnnnnnnnooooooooprrrrssssssssssssttttttuuvwwwww'" - ] - }, - "execution_count": 99, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "cat(sorted(random_english_letter() for i in range(100)))" - ] - }, - { - "cell_type": "code", - "execution_count": 100, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "'aaaaaaccccdddeeeeeeeeeeeeeeeeeeeffgghhiiiiikkklllmmmnnnnnnooooooppprrrrrrrrssssssssttttttuuuuuuvwyyy'" - ] - }, - "execution_count": 100, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "cat(sorted(random_wordsearch_letter() for i in range(100)))" - ] - }, - { - "cell_type": "code", - "execution_count": 101, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "'e'" - ] - }, - "execution_count": 101, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "random_wordsearch_letter()" - ] - }, - { - "cell_type": "code", - "execution_count": 102, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "def pad_grid(g0):\n", - " grid = copy.deepcopy(g0)\n", - " w = len(grid[0])\n", - " h = len(grid)\n", - " for r in range(h):\n", - " for c in range(w):\n", - " if grid[r][c] == '.':\n", - " grid[r][c] = random_wordsearch_letter()\n", - " return grid" - ] - }, - { - "cell_type": "code", - "execution_count": 103, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "nwtautoimmuneeyinsdl\n", - "majorlyerasescmcider\n", - "edthrallednxlcawoeaa\n", - "gnizeensbnahwwgpsksr\n", - "rmisrksiosgiitndtaep\n", - "rioigoeopeglbnegsesu\n", - "esurnrbdifecihtniust\n", - "eeauuieimddlgiiigqan\n", - "srcplooscrlufestosve\n", - "pdcasmhemaonrgialcel\n", - "lguvrepkcrekennronru\n", - "ensesmtiesrtiogocwcr\n", - "niadpnetulasgpdfeesi\n", - "dgthgreoonavhsorinyv\n", - "inilpehmnrnntuaeeoae\n", - "dioesnmnocstennpolcm\n", - "etniwvredwtidnmfdshm\n", - "sgsoaarunyyoslurstts\n", - "tetoyisimdmaderetlaf\n", - "ettflightasnlclquasi\n" - ] - } - ], - "source": [ - "padded = pad_grid(g)\n", - "print(show_grid(padded))" - ] - }, - { - "cell_type": "code", - "execution_count": 104, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "...autoimmune.......\n", - "majorlyerases.m..d..\n", - "..thralledn...a..e..\n", - "gnizeens..a..wg.sk..\n", - ".m.s..si..g.i.ndtae.\n", - ".i.ig.eo..gl..egses.\n", - ".s.rnrbd..ec.htniust\n", - ".eauuiei.ddlg.iigqan\n", - "srcploos..lufestosve\n", - "p.casmhe.aonrgial.el\n", - "lguv.ep.crekennro.ru\n", - "ense.m.i.s..iogoc.cr\n", - "niad.netulasgp.fee.i\n", - "dgt..reo....hs.r.nyv\n", - "ini..ehm....t.ae.oa.\n", - "dio..nm.o...en.p.lc.\n", - "etn.w..e.w..d.....h.\n", - "s.so....n.yoslurs.t.\n", - "t.t......dmaderetlaf\n", - "...flight.s.l..quasi\n" - ] - } - ], - "source": [ - "print(show_grid(g))" - ] - }, - { - "cell_type": "code", - "execution_count": 105, - "metadata": { - "collapsed": false, - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "thralled (True, 2, 2, )\n", - "slung (True, 9, 4, )\n", - "freighted (True, 8, 12, )\n", - "townhouse (True, 18, 2, )\n", - "salute (True, 12, 11, )\n", - "phoebes (True, 10, 6, )\n", - "faltered (True, 18, 19, )\n", - "laywomen (True, 19, 12, )\n", - "squeaked (True, 8, 17, )\n", - "perforating (True, 15, 15, )\n", - "iodise (True, 4, 7, )\n", - "lacier (True, 8, 10, )\n", - "autoimmune (True, 0, 3, )\n", - "tinging (True, 16, 1, )\n", - "snagged (True, 1, 10, )\n", - "splendidest (True, 8, 0, )\n", - "roughed (True, 10, 9, )\n", - "crevasse (True, 11, 18, )\n", - "lone (True, 15, 17, )\n", - "ecologists (True, 12, 16, )\n", - "sponge (True, 13, 13, )\n", - "magnetising (True, 1, 14, )\n", - "sneezing (True, 3, 7, )\n", - "virulent (True, 13, 19, )\n", - "flight (True, 19, 3, )\n", - "sirup (True, 4, 3, )\n", - "yacht (True, 13, 18, )\n", - "random (True, 13, 15, )\n", - "accusations (True, 7, 2, )\n", - "wiled (True, 3, 13, )\n", - "paved (True, 8, 3, )\n", - "majorly (True, 1, 0, )\n", - "miser (True, 4, 1, )\n", - "memoir (True, 11, 5, )\n", - "emends (True, 14, 5, )\n", - "slurs (True, 17, 12, )\n", - "clunk (True, 6, 11, )\n", - "erases (True, 1, 7, )\n", - "quasi (True, 19, 15, )\n" - ] - } - ], - "source": [ - "for w in ws:\n", - " print(w, present(padded, w))" - ] - }, - { - "cell_type": "code", - "execution_count": 141, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "def decoys(grid, words, all_words, limit=100):\n", - " decoy_words = []\n", - " dlen_limit = max(len(w) for w in words)\n", - " while len(words) + len(decoy_words) < limit:\n", - " d = random.choice(all_words)\n", - " if d not in words and len(d) >= 4 and len(d) <= dlen_limit and not present(grid, d)[0]:\n", - " decoy_words += [d]\n", - " return decoy_words" - ] - }, - { - "cell_type": "code", - "execution_count": 135, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "['incisor',\n", - " 'steeled',\n", - " 'immobility',\n", - " 'undertakings',\n", - " 'exhorts',\n", - " 'hairnet',\n", - " 'placarded',\n", - " 'sackful',\n", - " 'covenanting',\n", - " 'invoking',\n", - " 'deltas',\n", - " 'nonplus',\n", - " 'exactest',\n", - " 'eggs',\n", - " 'tercentenary',\n", - " 'angelic',\n", - " 'relearning',\n", - " 'ardors',\n", - " 'imprints',\n", - " 'chamoix',\n", - " 'governance',\n", - " 'rampart',\n", - " 'estuary',\n", - " 'poltroons',\n", - " 'expect',\n", - " 'restaurant',\n", - " 'ashrams',\n", - " 'illuminates',\n", - " 'reprises',\n", - " 'seismology',\n", - " 'announce',\n", - " 'tomorrows',\n", - " 'carcinogenics',\n", - " 'duplex',\n", - " 'transmitters',\n", - " 'prosier',\n", - " 'anther',\n", - " 'masticates',\n", - " 'raunchy',\n", - " 'briefs',\n", - " 'poniard',\n", - " 'daunted',\n", - " 'topmasts',\n", - " 'mynas']" - ] - }, - "execution_count": 135, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "ds = decoys(padded, ws, ws_words)\n", - "ds" - ] - }, - { - "cell_type": "code", - "execution_count": 108, - "metadata": { - "collapsed": false, - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "thralled (True, 2, 2, )\n", - "slung (True, 9, 4, )\n", - "freighted (True, 8, 12, )\n", - "townhouse (True, 18, 2, )\n", - "salute (True, 12, 11, )\n", - "phoebes (True, 10, 6, )\n", - "faltered (True, 18, 19, )\n", - "laywomen (True, 19, 12, )\n", - "squeaked (True, 8, 17, )\n", - "perforating (True, 15, 15, )\n", - "iodise (True, 4, 7, )\n", - "lacier (True, 8, 10, )\n", - "autoimmune (True, 0, 3, )\n", - "tinging (True, 16, 1, )\n", - "snagged (True, 1, 10, )\n", - "splendidest (True, 8, 0, )\n", - "roughed (True, 10, 9, )\n", - "crevasse (True, 11, 18, )\n", - "lone (True, 15, 17, )\n", - "ecologists (True, 12, 16, )\n", - "sponge (True, 13, 13, )\n", - "magnetising (True, 1, 14, )\n", - "sneezing (True, 3, 7, )\n", - "virulent (True, 13, 19, )\n", - "flight (True, 19, 3, )\n", - "sirup (True, 4, 3, )\n", - "yacht (True, 13, 18, )\n", - "random (True, 13, 15, )\n", - "accusations (True, 7, 2, )\n", - "wiled (True, 3, 13, )\n", - "paved (True, 8, 3, )\n", - "majorly (True, 1, 0, )\n", - "miser (True, 4, 1, )\n", - "memoir (True, 11, 5, )\n", - "emends (True, 14, 5, )\n", - "slurs (True, 17, 12, )\n", - "clunk (True, 6, 11, )\n", - "erases (True, 1, 7, )\n", - "quasi (True, 19, 15, )\n", - "leakiest (False, 0, 0, )\n", - "lumpiest (False, 0, 0, )\n", - "bastion (False, 0, 0, )\n", - "steamier (False, 0, 0, )\n", - "elegant (False, 0, 0, )\n", - "slogging (False, 0, 0, )\n", - "rejects (False, 0, 0, )\n", - "gaze (False, 0, 0, )\n", - "swopping (False, 0, 0, )\n", - "resonances (False, 0, 0, )\n", - "treasonous (False, 0, 0, )\n", - "corm (False, 0, 0, )\n", - "abuses (False, 0, 0, )\n", - "toga (False, 0, 0, )\n", - "upcountry (False, 0, 0, )\n", - "scrawled (False, 0, 0, )\n", - "cellar (False, 0, 0, )\n", - "skinflint (False, 0, 0, )\n", - "wasteland (False, 0, 0, )\n", - "madman (False, 0, 0, )\n", - "lash (False, 0, 0, )\n" - ] - } - ], - "source": [ - "for w in ws + ds:\n", - " print(w, present(padded, w))" - ] - }, - { - "cell_type": "code", - "execution_count": 142, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - ".strigger.essegassum\n", - "acselacs.tapri..pgcr\n", - "moeclienterr.em.uaie\n", - "apisearsclmo.kvpmntp\n", - "lebpg..ohlucfaeaespe\n", - "ifbi.ev.aafeesr.urol\n", - "riae.el.iwfse.o.oqss\n", - "evcsr...n..sd.dv..r.\n", - "pestdewels..e.aw.ut.\n", - "mrlimmersionrl.ob.e.\n", - "iyllatnemadnufwls.nl\n", - "..sdboomovulesivl.ri\n", - ".eiepsreggij.tdeljif\n", - "dkwn.atread..oereiat\n", - "uais..efile..pnihlhi\n", - "rhkripelyt.illsnst.n\n", - "iweekendunotablete.g\n", - "nfondlyrytsenohsuo..\n", - "g.mriffa....naysnp..\n", - ".meatspoodle.within.\n", - "cstriggerpessegassum\n", - "acselacsytapriijpgcr\n", - "moeclienterrtemnuaie\n", - "apisearsclmookvpmntp\n", - "lebpgatohlucfaeaespe\n", - "ifbisevxaafeesrlurol\n", - "riaehelciwfseioioqss\n", - "evcsrkuynpasdfdvetrq\n", - "pestdewelsniegawkutd\n", - "mrlimmersionrloobuel\n", - "iyllatnemadnufwlsanl\n", - "dwsdboomovulesivlyri\n", - "oeiepsreggijntdeljif\n", - "dkwnkatreadvnoereiat\n", - "uaiscuefilehapnihlhi\n", - "rhkripelytqillsnsten\n", - "iweekendunotabletetg\n", - "nfondlyrytsenohsuocc\n", - "gemriffanternaysnpef\n", - "bmeatspoodleswithing\n", - "62 words added; 8 directions\n", - "Present: adore affirm ages boom burs chain client dens during earmuff feeder file fiver fondly fundamentally hairnet hake honesty ills immersion imperil jiggers jilt kiwis lama leap legs lifting meat muss nays notable nutshells optic oval overtly ovule pies poet poodle process quavers repels ripely sake scabbiest scale scope sears simpers slewed snag spume stop tread trigger turfs wallet weekend widen within wolverines\n", - "Decoys: chitchats colloquium conveyances convulsively debates dieting dudes dumpster dwarfed experienced feasibility festooning groupie grunted highfalutin humanise incubuses infiltrate ingratiated jotting linearly lotus masculines meanders nucleuses plunks ponderously prerecording riskiest scavenging splashier sportsmanship strawberry twirler unjustified wariness wavy yeast\n" - ] - } - ], - "source": [ - "g, ws = interesting_grid()\n", - "p = pad_grid(g)\n", - "ds = decoys(p, ws, ws_words)\n", - "print(show_grid(g))\n", - "print(show_grid(p))\n", - "print(len(ws), 'words added; ', len(set(present(g, w)[3] for w in ws)), 'directions')\n", - "print('Present:', wcat(sorted(ws)))\n", - "print('Decoys:', wcat(sorted(ds)))" - ] - }, - { - "cell_type": "code", - "execution_count": 143, - "metadata": { - "collapsed": false, - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0\n", - "1\n", - "2\n", - "3\n", - "4\n", - "5\n", - "6\n", - "7\n", - "8\n", - "9\n", - "10\n", - "11\n", - "12\n", - "13\n", - "14\n", - "15\n", - "16\n", - "17\n", - "18\n", - "19\n", - "20\n", - "21\n", - "22\n", - "23\n", - "24\n", - "25\n", - "26\n", - "27\n", - "28\n", - "29\n", - "30\n", - "31\n", - "32\n", - "33\n", - "34\n", - "35\n", - "36\n", - "37\n", - "38\n", - "39\n", - "40\n", - "41\n", - "42\n", - "43\n", - "44\n", - "45\n", - "46\n", - "47\n", - "48\n", - "49\n", - "50\n", - "51\n", - "52\n", - "53\n", - "54\n", - "55\n", - "56\n", - "57\n", - "58\n", - "59\n", - "60\n", - "61\n", - "62\n", - "63\n", - "64\n", - "65\n", - "66\n", - "67\n", - "68\n", - "69\n", - "70\n", - "71\n", - "72\n", - "73\n", - "74\n", - "75\n", - "76\n", - "77\n", - "78\n", - "79\n", - "80\n", - "81\n", - "82\n", - "83\n", - "84\n", - "85\n", - "86\n", - "87\n", - "88\n", - "89\n", - "90\n", - "91\n", - "92\n", - "93\n", - "94\n", - "95\n", - "96\n", - "97\n", - "98\n", - "99\n" - ] - } - ], - "source": [ - "for i in range(100):\n", - " print(i)\n", - " g, ws = interesting_grid()\n", - " p = pad_grid(g)\n", - " ds = decoys(p, ws, ws_words)\n", - " with open('wordsearch{:02}.txt'.format(i), 'w') as f:\n", - " f.write('20x20\\n')\n", - " f.write(show_grid(p))\n", - " f.write('\\n')\n", - " f.write(lcat(sorted(ws + ds)))\n", - " with open('wordsearch-solution{:02}.txt'.format(i), 'w') as f:\n", - " f.write('20x20\\n')\n", - " f.write(show_grid(g))\n", - " f.write('\\n')\n", - " f.write(lcat(sorted(ws)) + '\\n\\n')\n", - " f.write(lcat(sorted(ds)))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.5.2" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/05-display-board/display-board-solution.ipynb b/05-display-board/display-board-solution.ipynb index 1ea9fc0..cf34334 100644 --- a/05-display-board/display-board-solution.ipynb +++ b/05-display-board/display-board-solution.ipynb @@ -81,7 +81,7 @@ "metadata": {}, "source": [ "## Part 1\n", - "You're standing in front of gate 9¾. You have [the instructions](03-pixels.txt). How many pixels would be lit on the board, if it was working?" + "You're standing in front of gate 9¾. You have [the instructions](05-pixels.txt). How many pixels would be lit on the board, if it was working?" ] }, { diff --git a/problem-ideas.ipynb b/problem-ideas.ipynb index 4d6b240..48113df 100644 --- a/problem-ideas.ipynb +++ b/problem-ideas.ipynb @@ -20,7 +20,7 @@ "3. [Door codes](03-door-codes)\n", "4. [Word search](04-word-search)\n", "5. [Display board](05-display-board)\n", - "6. ?\n", + "6. [Activity network](06-activity-network)\n", "7. [Word chains](07-word-chains)\n", "8. [Suitcase packing](08-suitacase-packing)\n", "9. ?\n", -- 2.34.1