@@ -1694,11 +1694,10 @@ def sol(capacities=[8, 5, 3], init=[8, 0, 0], goal=[4, 4, 0]):
16941694([ classic_puzzles] ( #classic_puzzles ) 21/22)
16951695
16961696** Description:**
1697- Find a substitution of digits for characters to make the numbers add up, like this:
1697+ Find a substitution of digits for characters to make the numbers add up in a sum like this:
16981698SEND + MORE = MONEY
1699- 9567 + 1085 = 10652
17001699
1701- The first digit in any cannot be 0.
1700+ The first digit in any number cannot be 0.
17021701See [ Wikipedia article] ( https://en.wikipedia.org/wiki/Verbal_arithmetic )
17031702
17041703** Problem:**
@@ -1787,9 +1786,22 @@ def sol(words=['SEND', 'MORE', 'MONEY']):
17871786** Description:**
17881787[ Sliding puzzle] ( https://en.wikipedia.org/wiki/15_puzzle )
17891788
1790- Classic example of A* search. NP-hard but the puzzles can all be solved with A* and an efficient representation
1789+ The 3-, 8-, and 15-sliding puzzles are classic examples of A* search. In this puzzle, you are given a board like:
1790+ 1 2 5
1791+ 3 4 0
1792+ 6 7 8
17911793
1792- 3-, 8-, and 15-sliding puzzles
1794+ and your goal is to transform it to:
1795+ 0 1 2
1796+ 3 4 5
1797+ 6 7 8
1798+
1799+ by a sequence of swaps with the 0 square (0 indicates blank). The starting configuration is given by a 2d list of
1800+ lists and the answer is represented by a list of integers indicating which number you swap with 0. In the above
1801+ example, the answer would be ` [1, 2, 5] `
1802+
1803+
1804+ The problem is NP-hard but the puzzles can all be solved with A* and an efficient representation.
17931805
17941806** Problem:**
17951807
@@ -1948,21 +1960,16 @@ def sol(word="antidisestablishmentarianism", max_len=10):
19481960([ codeforces] ( #codeforces ) 3/24)
19491961
19501962** Description:**
1951- Find a minimal list of corner locations for a×a tiles that covers [ 0, m] × [ 0, n]
1952- and does not double-cover squares.
1963+ Find a minimal list of corner locations for a×a tiles that covers [ 0, m] × [ 0, n] and does not double-cover
1964+ squares.
19531965
19541966Sample Input:
1955-
19561967m = 10
1957-
19581968n = 9
1959-
19601969a = 5
1961-
19621970target = 4
19631971
19641972Sample Output:
1965-
19661973[[ 0, 0] , [ 0, 5] , [ 5, 0] , [ 5, 5]]
19671974
19681975Inspired by [ Codeforces Problem 1 A] ( https://codeforces.com/problemset/problem/1/A )
@@ -1989,8 +1996,8 @@ def sol(m=10, n=9, a=5, target=4):
19891996([ codeforces] ( #codeforces ) 4/24)
19901997
19911998** Description:**
1992- Given a list of lists of triples of integers, return True for each list with a total of at least 2 and False
1993- for each other list.
1999+ Given a list of lists of triples of integers, return True for each list with a total of at least 2 and False for
2000+ each other list.
19942001
19952002Inspired by [ Codeforces Problem 231 A] ( https://codeforces.com/problemset/problem/231/A )
19962003
@@ -2042,8 +2049,8 @@ def sol(scores=[100, 95, 80, 70, 65, 9, 9, 9, 4, 2, 1], k=6):
20422049([ codeforces] ( #codeforces ) 6/24)
20432050
20442051** Description:**
2045- Tile an m x n checkerboard with 2 x 1 tiles. The solution is a list of fourtuples [ i1, j1, i2, j2]
2046- with i2 == i1 and j2 == j1 + 1 or i2 == i1 + 1 and j2 == j1 with no overlap.
2052+ Tile an m x n checkerboard with 2 x 1 tiles. The solution is a list of fourtuples [ i1, j1, i2, j2] with i2 == i1
2053+ and j2 == j1 + 1 or i2 == i1 + 1 and j2 == j1 with no overlap.
20472054
20482055Inspired by [ Codeforces Problem 50 A] ( https://codeforces.com/problemset/problem/50/A )
20492056
@@ -2079,17 +2086,14 @@ def sol(m=10, n=5, target=50):
20792086
20802087** Description:**
20812088This straightforward problem is a little harder than the Codeforces one.
2082- Given a sequence of operations "++x",
2083- "x++", "--x", "x--", and a target value, find initial value so that the final value is the target value.
2089+ Given a sequence of operations "++x", "x++", "--x", "x--", and a target value, find initial value so that the
2090+ final value is the target value.
20842091
20852092Sample Input:
2086-
20872093ops = [ "x++", "--x", "--x"]
2088-
20892094target = 12
20902095
20912096Sample Output:
2092-
2093209713
20942098
20952099Inspired by [ Codeforces Problem 282 A] ( https://codeforces.com/problemset/problem/282/A )
@@ -2157,13 +2161,9 @@ def sol(s="aaAab", t="aAaaB"):
21572161We are given a 5x5 bimatrix with a single 1 like:
21582162
215921630 0 0 0 0
2160-
216121640 0 0 0 1
2162-
216321650 0 0 0 0
2164-
216521660 0 0 0 0
2166-
216721670 0 0 0 0
21682168
21692169Find a (minimal) sequence of row and column swaps to move the 1 to the center. A move is a string
@@ -2270,8 +2270,8 @@ def sol(word="konjac"):
22702270([ codeforces] ( #codeforces ) 12/24)
22712271
22722272** Description:**
2273- You are given a string consisting of a's, b's and c's, find any longest substring containing no
2274- repeated consecutive characters.
2273+ You are given a string consisting of a's, b's and c's, find any longest substring containing no repeated
2274+ consecutive characters.
22752275
22762276Sample Input:
22772277` "abbbc" `
@@ -2310,13 +2310,10 @@ You are given a string consisting of 0's and 1's. Find an index after which the
23102310all 0's or all 1's.
23112311
23122312Sample Input:
2313-
23142313s = 0000111111100000, k = 5
23152314
23162315Sample Output:
2317-
231823164
2319-
23202317(or 5 or 6 or 11)
23212318
23222319Inspired by [ Codeforces Problem 96 A] ( https://codeforces.com/problemset/problem/96/A )
@@ -2390,13 +2387,10 @@ def sol(n=7):
23902387Shortest Combination Lock Path
23912388
23922389Given a starting a final lock position, find the (minimal) intermediate states, where each transition
2393- involves increasing or decreasing a single digit (mod 10)
2394- e.g.
2390+ involves increasing or decreasing a single digit (mod 10), e.g.
23952391
23962392start = "012"
2397-
23982393combo = "329"
2399-
24002394output: [ '112', '212', '312', '322', '321', '320']
24012395
24022396Inspired by [ Codeforces Problem 540 A] ( https://codeforces.com/problemset/problem/540/A )
@@ -4926,8 +4920,6 @@ The problem is *unsolved* in the sense that no known polynomial-time algorithm h
49264920
49274921We include McCurley's discrete log challenge from
49284922[ Weber D., Denny T. (1998) "The solution of McCurley's discrete log challenge."] ( https://link.springer.com/content/pdf/10.1007/BFb0055747.pdf )
4929- whose answer is
4930- ` n = 325923617918270562238615985978623709128341338833721058543950813521768156295091638348030637920237175638117352442299234041658748471079911977497864301995972638266781162575370644813703762423329783129621567127479417280687495231463348812 `
49314923
49324924** Problem:**
49334925
0 commit comments