Skip to content

Commit 8234d67

Browse files
committed
Added compression.py, games.py, lattices.py, and number_theory.py problems.
1 parent 91e2280 commit 8234d67

15 files changed

+456211
-41
lines changed

problems/README.md

+1,170-1
Large diffs are not rendered by default.

problems/classic_puzzles.json

+75,887
Large diffs are not rendered by default.

problems/compression.json

+21,002
Large diffs are not rendered by default.

problems/conways_game_of_life.json

+10,008
Large diffs are not rendered by default.

problems/games.json

+7,044
Large diffs are not rendered by default.

problems/lattices.json

+13,156
Large diffs are not rendered by default.

problems/number_theory.json

+68,448
Large diffs are not rendered by default.

problems/probability.json

+35,002
Large diffs are not rendered by default.

problems/study.json

+213
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
[
2+
{
3+
"name": "Study_1_0",
4+
"sat": "def sat(s: str):\n assert type(s) is str, 's must be of type str'\n return s.count('o') == 1000 and s.count('oo') == 0",
5+
"sols": [
6+
"def sol():\n return ('h' + 'o') * 1000"
7+
]
8+
},
9+
{
10+
"name": "Study_2_0",
11+
"sat": "def sat(s: str):\n assert type(s) is str, 's must be of type str'\n return s.count('o') == 1000 and s.count('oo') == 100 and s.count('ho') == 801",
12+
"sols": [
13+
"def sol():\n return 'ho' * (800 + 1) + 'o' * (100 * 2 - 1)"
14+
]
15+
},
16+
{
17+
"name": "Study_3_0",
18+
"sat": "def sat(li: List[int]):\n assert type(li) is list and all(type(a) is int for a in li), 'li must be of type List[int]'\n return sorted(li) == list(range(999)) and all(li[i] != i for i in range(len(li)))",
19+
"sols": [
20+
"def sol():\n return [((i + 1) % 999) for i in range(999)]"
21+
]
22+
},
23+
{
24+
"name": "Study_4_0",
25+
"sat": "def sat(li: List[int]):\n assert type(li) is list and all(type(a) is int for a in li), 'li must be of type List[int]'\n return len(li) == 10 and li.count(li[3]) == 2",
26+
"sols": [
27+
"def sol():\n return list(range(10 // 2)) * 2"
28+
]
29+
},
30+
{
31+
"name": "Study_5_0",
32+
"sat": "def sat(li: List[int]):\n assert type(li) is list and all(type(a) is int for a in li), 'li must be of type List[int]'\n return all([li.count(i) == i for i in range(10)])",
33+
"sols": [
34+
"def sol():\n return [i for i in range(10) for j in range(i)]"
35+
]
36+
},
37+
{
38+
"name": "Study_6_0",
39+
"sat": "def sat(i: int):\n assert type(i) is int, 'i must be of type int'\n return i % 123 == 4 and i > 10 ** 10",
40+
"sols": [
41+
"def sol():\n return 4 + 10 ** 10 + 123 - 10 ** 10 % 123"
42+
]
43+
},
44+
{
45+
"name": "Study_7_0",
46+
"sat": "def sat(s: str):\n assert type(s) is str, 's must be of type str'\n return str(8 ** 2888).count(s) > 8 and len(s) == 3",
47+
"sols": [
48+
"def sol():\n s = str(8 ** 2888)\n return max({s[i: i + 3] for i in range(len(s) - 2)}, key=lambda t: s.count(t))"
49+
]
50+
},
51+
{
52+
"name": "Study_8_0",
53+
"sat": "def sat(ls: List[str]):\n assert type(ls) is list and all(type(a) is str for a in ls), 'ls must be of type List[str]'\n return ls[1234] in ls[1235] and ls[1234] != ls[1235]",
54+
"sols": [
55+
"def sol():\n return [''] * 1235 + ['a']"
56+
]
57+
},
58+
{
59+
"name": "Study_9_0",
60+
"sat": "def sat(li: List[int]):\n assert type(li) is list and all(type(a) is int for a in li), 'li must be of type List[int]'\n return [\"The quick brown fox jumps over the lazy dog\"[i] for i in li] == list(\n \"The five boxing wizards jump quickly\")",
61+
"sols": [
62+
"def sol():\n return ['The quick brown fox jumps over the lazy dog'.index(t) for t in 'The five boxing wizards jump quickly']"
63+
]
64+
},
65+
{
66+
"name": "Study_10_0",
67+
"sat": "def sat(s: str):\n assert type(s) is str, 's must be of type str'\n return s in str(8 ** 1818) and s == s[::-1] and len(s) > 11",
68+
"sols": [
69+
"def sol():\n s = str(8 ** 1818)\n return next(s[i: i + le]\n for le in range(12, len(s) + 1)\n for i in range(len(s) - le + 1)\n if s[i: i + le] == s[i: i + le][::-1]\n )"
70+
]
71+
},
72+
{
73+
"name": "Study_11_0",
74+
"sat": "def sat(ls: List[str]):\n assert type(ls) is list and all(type(a) is str for a in ls), 'ls must be of type List[str]'\n return min(ls) == max(ls) == str(len(ls))",
75+
"sols": [
76+
"def sol():\n return ['1']"
77+
]
78+
},
79+
{
80+
"name": "Study_12_0",
81+
"sat": "def sat(li: List[int]):\n assert type(li) is list and all(type(a) is int for a in li), 'li must be of type List[int]'\n return all(i + j == 9 for i, j in zip([4] + li, li)) and len(li) == 1000",
82+
"sols": [
83+
"def sol():\n return [9 - 4, 4] * (1000 // 2)"
84+
]
85+
},
86+
{
87+
"name": "Study_13_0",
88+
"sat": "def sat(x: float):\n assert type(x) is float, 'x must be of type float'\n return str(x - 3.1415).startswith(\"123.456\")",
89+
"sols": [
90+
"def sol():\n return 123.456 + 3.1415"
91+
]
92+
},
93+
{
94+
"name": "Study_14_0",
95+
"sat": "def sat(li: List[int]):\n assert type(li) is list and all(type(a) is int for a in li), 'li must be of type List[int]'\n return all([sum(li[:i]) == i for i in range(20)])",
96+
"sols": [
97+
"def sol():\n return [1] * 20"
98+
]
99+
},
100+
{
101+
"name": "Study_15_0",
102+
"sat": "def sat(li: List[int]):\n assert type(li) is list and all(type(a) is int for a in li), 'li must be of type List[int]'\n return all(sum(li[:i]) == 2 ** i - 1 for i in range(20))",
103+
"sols": [
104+
"def sol():\n return [(2 ** i) for i in range(20)]"
105+
]
106+
},
107+
{
108+
"name": "Study_16_0",
109+
"sat": "def sat(s: str):\n assert type(s) is str, 's must be of type str'\n return float(s) + len(s) == 4.5",
110+
"sols": [
111+
"def sol():\n return str(4.5 - len(str(4.5)))"
112+
]
113+
},
114+
{
115+
"name": "Study_17_0",
116+
"sat": "def sat(i: int):\n assert type(i) is int, 'i must be of type int'\n return len(str(i + 1000)) > len(str(i + 1001))",
117+
"sols": [
118+
"def sol():\n return -1001"
119+
]
120+
},
121+
{
122+
"name": "Study_18_0",
123+
"sat": "def sat(ls: List[str]):\n assert type(ls) is list and all(type(a) is str for a in ls), 'ls must be of type List[str]'\n return [s + t for s in ls for t in ls if s != t] == 'berlin berger linber linger gerber gerlin'.split()",
124+
"sols": [
125+
"def sol():\n seen = set()\n ans = []\n for s in 'berlin berger linber linger gerber gerlin'.split():\n t = s[:3]\n if t not in seen:\n ans.append(t)\n seen.add(t)\n return ans"
126+
]
127+
},
128+
{
129+
"name": "Study_19_0",
130+
"sat": "def sat(si: Set[int]):\n assert type(si) is set and all(type(a) is int for a in si), 'si must be of type Set[int]'\n return {i + j for i in si for j in si} == {0, 1, 2, 3, 4, 5, 6, 17, 18, 19, 20, 34}",
131+
"sols": [
132+
"def sol():\n return {0, 1, 2, 3, 17}"
133+
]
134+
},
135+
{
136+
"name": "Study_20_0",
137+
"sat": "def sat(li: List[int]):\n assert type(li) is list and all(type(a) is int for a in li), 'li must be of type List[int]'\n return all(j in {i - 1, i + 1, 3 * i} for i, j in zip([0] + li, li + [128]))",
138+
"sols": [
139+
"def sol():\n return [1, 3, 4, 12, 13, 14, 42, 126, 127]"
140+
]
141+
},
142+
{
143+
"name": "Study_21_0",
144+
"sat": "def sat(li: List[int]):\n assert type(li) is list and all(type(a) is int for a in li), 'li must be of type List[int]'\n return all([li[i] != li[i + 1] for i in range(10)]) and len(set(li)) == 3",
145+
"sols": [
146+
"def sol():\n return list(range(3)) * 10"
147+
]
148+
},
149+
{
150+
"name": "Study_22_0",
151+
"sat": "def sat(s: str):\n assert type(s) is str, 's must be of type str'\n return s[::2] in s and len(set(s)) == 5",
152+
"sols": [
153+
"def sol():\n return \"\"\"abacadaeaaaaaaaaaa\"\"\""
154+
]
155+
},
156+
{
157+
"name": "Study_23_0",
158+
"sat": "def sat(ls: List[str]):\n assert type(ls) is list and all(type(a) is str for a in ls), 'ls must be of type List[str]'\n return tuple(ls) in zip('dee', 'doo', 'dah!')",
159+
"sols": [
160+
"def sol():\n return list(next(zip('dee', 'doo', 'dah!')))"
161+
]
162+
},
163+
{
164+
"name": "Study_24_0",
165+
"sat": "def sat(li: List[int]):\n assert type(li) is list and all(type(a) is int for a in li), 'li must be of type List[int]'\n return li.count(17) == 3 and li.count(3) >= 2",
166+
"sols": [
167+
"def sol():\n return [17] * 3 + [3] * 2"
168+
]
169+
},
170+
{
171+
"name": "Study_25_0",
172+
"sat": "def sat(s: str):\n assert type(s) is str, 's must be of type str'\n return sorted(s) == sorted('Permute me true') and s == s[::-1]",
173+
"sols": [
174+
"def sol():\n return \"\"\"\"\"\".join(sorted('Permute me true'[1:])[::2] + ['P'] + sorted('Permute me true'[1:])[::2][::-1])"
175+
]
176+
},
177+
{
178+
"name": "Study_26_0",
179+
"sat": "def sat(ls: List[str]):\n assert type(ls) is list and all(type(a) is str for a in ls), 'ls must be of type List[str]'\n return \"\".join(ls) == str(8 ** 88) and all(len(s) == 8 for s in ls)",
180+
"sols": [
181+
"def sol():\n return [str(8 ** 88)[i:i + 8] for i in range(0, len(str(8 ** 88)), 8)]"
182+
]
183+
},
184+
{
185+
"name": "Study_27_0",
186+
"sat": "def sat(li: List[int]):\n assert type(li) is list and all(type(a) is int for a in li), 'li must be of type List[int]'\n return li[li[0]] != li[li[1]] and li[li[li[0]]] == li[li[li[1]]]",
187+
"sols": [
188+
"def sol():\n return [1, 2, 3, 3]"
189+
]
190+
},
191+
{
192+
"name": "Study_28_0",
193+
"sat": "def sat(si: Set[int]):\n assert type(si) is set and all(type(a) is int for a in si), 'si must be of type Set[int]'\n return all(i in range(1000) and abs(i - j) >= 10 for i in si for j in si if i != j) and len(si) == 100",
194+
"sols": [
195+
"def sol():\n return set(range(0, 1000, 10))"
196+
]
197+
},
198+
{
199+
"name": "Study_29_0",
200+
"sat": "def sat(si: Set[int]):\n assert type(si) is set and all(type(a) is int for a in si), 'si must be of type Set[int]'\n return all(i in range(1000) and abs(i * i - j * j) >= 10 for i in si for j in si if i != j) and len(si) > 995",
201+
"sols": [
202+
"def sol():\n return set(range(6, 1000)).union({0, 4})"
203+
]
204+
},
205+
{
206+
"name": "Study_30_0",
207+
"sat": "def sat(li: List[int]):\n assert type(li) is list and all(type(a) is int for a in li), 'li must be of type List[int]'\n return all([123 * li[i] % 1000 < 123 * li[i + 1] % 1000 and li[i] in range(1000) for i in range(20)])",
208+
"sols": [
209+
"def sol():\n return sorted(range(1000), key=lambda n: 123*n % 1000)[:21]",
210+
"def sol():\n return list(range(1000))[::8][::-1]"
211+
]
212+
}
213+
]

0 commit comments

Comments
 (0)