Done challenge 3
[cipher-challenge.git] / 2020 / challenge3-clue.ipynb
1 {
2 "cells": [
3 {
4 "cell_type": "code",
5 "execution_count": 1,
6 "metadata": {},
7 "outputs": [],
8 "source": [
9 "from szyfrow.support.language_models import *\n",
10 "from szyfrow.support.utilities import *\n",
11 "import collections"
12 ]
13 },
14 {
15 "cell_type": "code",
16 "execution_count": 2,
17 "metadata": {},
18 "outputs": [
19 {
20 "data": {
21 "text/plain": [
22 "14843"
23 ]
24 },
25 "execution_count": 2,
26 "metadata": {},
27 "output_type": "execute_result"
28 }
29 ],
30 "source": [
31 "words8 = [w for w in keywords if len(w) == 8]\n",
32 "len(words8)"
33 ]
34 },
35 {
36 "cell_type": "code",
37 "execution_count": 4,
38 "metadata": {},
39 "outputs": [],
40 "source": [
41 "anags8 = collections.defaultdict(list)\n",
42 "for w in words8:\n",
43 " anags8[cat(sorted(w))] += [w]"
44 ]
45 },
46 {
47 "cell_type": "code",
48 "execution_count": 5,
49 "metadata": {},
50 "outputs": [
51 {
52 "data": {
53 "text/plain": [
54 "['aegilnrt', 'aeginrst', 'deeinrst', 'ceeprsst', 'aeinrrst']"
55 ]
56 },
57 "execution_count": 5,
58 "metadata": {},
59 "output_type": "execute_result"
60 }
61 ],
62 "source": [
63 "cands = [w for w in anags8 if len(anags8[w]) >= 5]\n",
64 "cands"
65 ]
66 },
67 {
68 "cell_type": "code",
69 "execution_count": 6,
70 "metadata": {},
71 "outputs": [
72 {
73 "name": "stdout",
74 "output_type": "stream",
75 "text": [
76 "aegilnrt ['alerting', 'altering', 'integral', 'relating', 'triangle']\n",
77 "aeginrst ['angriest', 'gantries', 'granites', 'ingrates', 'rangiest', 'tangiers']\n",
78 "deeinrst ['dniester', 'inserted', 'nerdiest', 'resident', 'trendies']\n",
79 "ceeprsst ['respects', 'scepters', 'sceptres', 'specters', 'spectres']\n",
80 "aeinrrst ['restrain', 'retrains', 'strainer', 'terrains', 'trainers']\n"
81 ]
82 }
83 ],
84 "source": [
85 "for c in cands:\n",
86 " print(c, anags8[c])"
87 ]
88 },
89 {
90 "cell_type": "code",
91 "execution_count": null,
92 "metadata": {},
93 "outputs": [],
94 "source": []
95 }
96 ],
97 "metadata": {
98 "kernelspec": {
99 "display_name": "Python 3",
100 "language": "python",
101 "name": "python3"
102 },
103 "language_info": {
104 "codemirror_mode": {
105 "name": "ipython",
106 "version": 3
107 },
108 "file_extension": ".py",
109 "mimetype": "text/x-python",
110 "name": "python",
111 "nbconvert_exporter": "python",
112 "pygments_lexer": "ipython3",
113 "version": "3.7.4"
114 }
115 },
116 "nbformat": 4,
117 "nbformat_minor": 4
118 }