11"""Problems testing basic knowledge -- easy to solve if you understand what is being asked"""
22
3- from puzzle_generator import PuzzleGenerator
3+ from puzzle_generator import PuzzleGenerator , Tags
44from typing import List
55
66
77# See https://github.com/microsoft/PythonProgrammingPuzzles/wiki/How-to-add-a-puzzle to learn about adding puzzles
88
99class SumOfDigits (PuzzleGenerator ):
10+
11+ tags = [Tags .math ]
12+
1013 @staticmethod
1114 def sat (x : str , s = 679 ):
1215 """Find a number that its digits sum to a specific value."""
@@ -22,6 +25,9 @@ def gen_random(self):
2225
2326
2427class FloatWithDecimalValue (PuzzleGenerator ):
28+
29+ tags = [Tags .math ]
30+
2531 @staticmethod
2632 def sat (z : float , v = 9 , d = 0.0001 ):
2733 """Create a float with a specific decimal."""
@@ -44,6 +50,9 @@ def gen_random(self):
4450
4551
4652class ArithmeticSequence (PuzzleGenerator ):
53+
54+ tags = [Tags .math ]
55+
4756 @staticmethod
4857 def sat (x : List [int ], a = 7 , s = 5 , e = 200 ):
4958 """Create a list that is a subrange of an arithmetic sequence."""
@@ -61,6 +70,9 @@ def gen_random(self):
6170
6271
6372class GeometricSequence (PuzzleGenerator ):
73+
74+ tags = [Tags .math ]
75+
6476 @staticmethod
6577 def sat (x : List [int ], a = 8 , r = 2 , l = 50 ):
6678 """Create a list that is a subrange of an gemoetric sequence."""
@@ -78,6 +90,9 @@ def gen_random(self):
7890
7991
8092class LineIntersection (PuzzleGenerator ):
93+
94+ tags = [Tags .math ]
95+
8196 @staticmethod
8297 def sat (e : List [int ], a = 2 , b = - 1 , c = 1 , d = 2021 ):
8398 """
@@ -103,6 +118,9 @@ def gen_random(self):
103118
104119
105120class IfProblem (PuzzleGenerator ):
121+
122+ tags = [Tags .trivial ]
123+
106124 @staticmethod
107125 def sat (x : int , a = 324554 , b = 1345345 ):
108126 """Satisfy a simple if statement"""
@@ -125,6 +143,9 @@ def gen_random(self):
125143
126144
127145class IfProblemWithAnd (PuzzleGenerator ):
146+
147+ tags = [Tags .trivial ]
148+
128149 @staticmethod
129150 def sat (x : int , a = 9384594 , b = 1343663 ):
130151 """Satisfy a simple if statement with an and clause"""
@@ -148,6 +169,8 @@ def gen_random(self):
148169
149170class IfProblemWithOr (PuzzleGenerator ):
150171
172+ tags = [Tags .trivial ]
173+
151174 @staticmethod
152175 def sat (x : int , a = 253532 , b = 1230200 ):
153176 """Satisfy a simple if statement with an or clause"""
@@ -171,6 +194,8 @@ def gen_random(self):
171194
172195class IfCases (PuzzleGenerator ):
173196
197+ tags = [Tags .trivial ]
198+
174199 @staticmethod
175200 def sat (x : int , a = 4 , b = 54368639 ):
176201 """Satisfy a simple if statement with multiple cases"""
@@ -198,6 +223,9 @@ def gen_random(self):
198223
199224
200225class ListPosSum (PuzzleGenerator ):
226+
227+ tags = [Tags .trivial ]
228+
201229 @staticmethod
202230 def sat (x : List [int ], n = 5 , s = 19 ):
203231 """Find a list of n non-negative integers that sum up to s"""
@@ -216,6 +244,9 @@ def gen_random(self):
216244
217245
218246class ListDistinctSum (PuzzleGenerator ):
247+
248+ tags = [Tags .math ]
249+
219250 @staticmethod
220251 def sat (x : List [int ], n = 4 , s = 2021 ):
221252 """Construct a list of n distinct integers that sum up to s"""
@@ -244,6 +275,9 @@ def gen_random(self):
244275
245276
246277class ConcatStrings (PuzzleGenerator ):
278+
279+ tags = [Tags .trivial , Tags .strings ]
280+
247281 @staticmethod
248282 def sat (x : str , s = ["a" , "b" , "c" , "d" , "e" , "f" ], n = 4 ):
249283 """Concatenate the list of characters in s"""
@@ -262,6 +296,8 @@ def gen_random(self):
262296
263297class SublistSum (PuzzleGenerator ):
264298
299+ tags = [Tags .math ]
300+
265301 @staticmethod
266302 def sat (x : List [int ], t = 677 , a = 43 , e = 125 , s = 10 ):
267303 """Sum values of sublist by range specifications"""
@@ -292,6 +328,8 @@ def gen_random(self):
292328
293329class CumulativeSum (PuzzleGenerator ):
294330
331+ tags = [Tags .math , Tags .trivial ]
332+
295333 @staticmethod
296334 def sat (x : List [int ], t = 50 , n = 10 ):
297335 """Find how many values have cumulative sum less than target"""
@@ -316,6 +354,9 @@ def gen_random(self):
316354
317355
318356class BasicStrCounts (PuzzleGenerator ):
357+
358+ tags = [Tags .strings ]
359+
319360 @staticmethod
320361 def sat (s : str , s1 = 'a' , s2 = 'b' , count1 = 50 , count2 = 30 ):
321362 """
@@ -347,6 +388,9 @@ def gen_random(self):
347388
348389
349390class ZipStr (PuzzleGenerator ):
391+
392+ tags = [Tags .strings , Tags .trivial ]
393+
350394 @staticmethod
351395 def sat (s : str , substrings = ["foo" , "bar" , "baz" , "oddball" ]):
352396 """
@@ -365,6 +409,9 @@ def gen_random(self):
365409
366410
367411class ReverseCat (PuzzleGenerator ):
412+
413+ tags = [Tags .trivial , Tags .strings ]
414+
368415 @staticmethod
369416 def sat (s : str , substrings = ["foo" , "bar" , "baz" ]):
370417 """
@@ -382,6 +429,9 @@ def gen_random(self):
382429
383430
384431class EngineerNumbers (PuzzleGenerator ):
432+
433+ tags = [Tags .trivial , Tags .strings ]
434+
385435 @staticmethod
386436 def sat (ls : List [str ], n = 100 , a = 'bar' , b = 'foo' ):
387437 """
@@ -401,6 +451,9 @@ def gen_random(self):
401451
402452
403453class PenultimateString (PuzzleGenerator ):
454+
455+ tags = [Tags .trivial , Tags .strings ]
456+
404457 @staticmethod
405458 def sat (s : str , strings = ["cat" , "dog" , "bird" , "fly" , "moose" ]):
406459 """Find the alphabetically second to last last string in a list."""
@@ -417,6 +470,9 @@ def gen_random(self):
417470
418471
419472class PenultimateRevString (PuzzleGenerator ):
473+
474+ tags = [Tags .trivial , Tags .strings ]
475+
420476 @staticmethod
421477 def sat (s : str , strings = ["cat" , "dog" , "bird" , "fly" , "moose" ]):
422478 """Find the reversed version of the alphabetically second string in a list."""
@@ -433,6 +489,9 @@ def gen_random(self):
433489
434490
435491class CenteredString (PuzzleGenerator ):
492+
493+ tags = [Tags .trivial , Tags .strings ]
494+
436495 @staticmethod
437496 def sat (s : str , target = "foobarbazwow" , length = 6 ):
438497 """Find a substring of the given length centered within the target string."""
@@ -449,6 +508,9 @@ def gen_random(self):
449508
450509
451510class SubstrCount (PuzzleGenerator ):
511+
512+ tags = [Tags .brute_force , Tags .strings ]
513+
452514 @staticmethod
453515 def sat (substring : str , string = "moooboooofasd" , count = 2 ):
454516 """Find a substring with a certain count in a given string"""
@@ -478,6 +540,9 @@ def gen_random(self):
478540
479541
480542class CompleteParens (PuzzleGenerator ):
543+
544+ tags = []
545+
481546 @staticmethod
482547 def sat (t : str , s = "))(Add)some))parens()to()(balance(()(()(me!)((((" ):
483548 """Add parentheses to the beginning and end of s to make all parentheses balanced"""
0 commit comments