@@ -34,7 +34,7 @@ def load_user_data():
34
34
return load_json ('user.json' )
35
35
36
36
def pick_problems (user_data , problems , topic_list , k = 5 , problem_type = ProblemType .Random ):
37
- selected_topics = set (itertools .chain (* [topics [ topic ] for topic in topic_list ]))
37
+ selected_topics = set (itertools .chain (* [topics . get ( topic ,[]) for topic in topic_list ]))
38
38
39
39
skip_set = set (load_completed_list (user_data ))
40
40
for maybe_skip in ['hard' , 'revisit' , 'refresh' ]:
@@ -100,6 +100,13 @@ def mark_problem(user_data, mark_type, leetcode_id):
100
100
problems = pick_problems (user_data , problems = problem_set , topic_list = args .topic_list , k = args .num_problems )
101
101
problem_set -= set (problems )
102
102
103
+ if len (problems ) == 0 :
104
+ print ("You have completed all the problems in the selected set. Re-picking from the entire problem set" )
105
+ problems = pick_problems (user_data , problems = set (range (1 ,1700 )), topic_list = args .topic_list , k = args .num_problems )
106
+ if len (problems ) == 0 :
107
+ print ("Your --topic_list is either invalid or all completed. Repicking from all topics." )
108
+ problems = pick_problems (user_data , problems = problem_set , topic_list = topics .keys (), k = args .num_problems )
109
+
103
110
valid_inputs = ["info" , "hint" , "easy" , "hard" , "quit" , "pause" , "break" ]
104
111
print (f"Other valid inputs: { ', ' .join (valid_inputs )} " )
105
112
0 commit comments