Repository navigation
Expand file tree
/
Copy pathbatch_generate.py
More file actions
1553 lines (1463 loc) · 52.6 KB
/
Copy pathbatch_generate.py
File metadata and controls
1553 lines (1463 loc) · 52.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
"""
AxiomCode — Batch Generate & Test 100 Programs
================================================
Generates formal Lean 4 specifications for 100 algorithms,
validates each one, and produces a comprehensive test report.
UTF-8 encoding is enforced throughout.
"""
import os
os.environ["PYTHONUTF8"] = "1"
import json
import sys
import time
from dataclasses import dataclass, field
from pathlib import Path
# Ensure UTF-8 for stdout/stderr
if sys.stdout.encoding != "utf-8":
_reconfigure = getattr(sys.stdout, "reconfigure", None)
if _reconfigure is not None:
_reconfigure(encoding="utf-8")
if sys.stderr.encoding != "utf-8":
_reconfigure = getattr(sys.stderr, "reconfigure", None)
if _reconfigure is not None:
_reconfigure(encoding="utf-8")
# Add parent directory to path for imports
sys.path.insert(0, str(Path(__file__).parent))
from cli import (
LeanSpec,
_parse_spec,
)
# ─── 100 Algorithm Definitions ──────────────────────────────────────────────
ALGORITHMS = [
# ─── Sorting (1-12) ──────────────────────────────────────────────
{
"id": 1,
"name": "binary_search",
"category": "Searching",
"description": (
"implement binary search on a sorted array that returns the index of the target element or -1 if not "
"found, prove it always returns the correct index when the element exists"
),
"difficulty": "Easy",
"proof_complexity": "Medium",
},
{
"id": 2,
"name": "insertion_sort",
"category": "Sorting",
"description": (
"implement insertion sort that sorts a list of natural numbers, prove the output is sorted and is a "
"permutation of the input"
),
"difficulty": "Easy",
"proof_complexity": "Medium",
},
{
"id": 3,
"name": "selection_sort",
"category": "Sorting",
"description": (
"implement selection sort that repeatedly finds the minimum element and places it at the beginning, "
"prove the result is sorted and preserves all elements"
),
"difficulty": "Easy",
"proof_complexity": "Medium",
},
{
"id": 4,
"name": "bubble_sort",
"category": "Sorting",
"description": (
"implement bubble sort that repeatedly swaps adjacent elements if they are in wrong order, prove it "
"terminates and produces a sorted list"
),
"difficulty": "Easy",
"proof_complexity": "Medium",
},
{
"id": 5,
"name": "merge_sort",
"category": "Sorting",
"description": (
"implement merge sort using divide and conquer, prove it produces a sorted list that is a permutation "
"of the input, prove O(n log n) time complexity bound"
),
"difficulty": "Medium",
"proof_complexity": "High",
},
{
"id": 6,
"name": "quick_sort",
"category": "Sorting",
"description": (
"implement quicksort with a pivot selection strategy, prove the output is sorted and contains exactly "
"the same elements as the input"
),
"difficulty": "Medium",
"proof_complexity": "High",
},
{
"id": 7,
"name": "heap_sort",
"category": "Sorting",
"description": (
"implement heap sort using a max-heap data structure, prove it correctly sorts any list of natural numbers"
),
"difficulty": "Medium",
"proof_complexity": "High",
},
{
"id": 8,
"name": "counting_sort",
"category": "Sorting",
"description": (
"implement counting sort for integers in a known range, prove it produces a stable sorted output"
),
"difficulty": "Medium",
"proof_complexity": "Medium",
},
{
"id": 9,
"name": "radix_sort",
"category": "Sorting",
"description": (
"implement radix sort using counting sort as a subroutine for each digit, prove it correctly sorts "
"non-negative integers"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
{
"id": 10,
"name": "shell_sort",
"category": "Sorting",
"description": "implement shell sort with diminishing gap sequence, prove the final array is sorted",
"difficulty": "Hard",
"proof_complexity": "High",
},
{
"id": 11,
"name": "tim_sort",
"category": "Sorting",
"description": "implement a simplified timsort that merges sorted runs, prove the output is sorted and stable",
"difficulty": "Hard",
"proof_complexity": "High",
},
{
"id": 12,
"name": "intro_sort",
"category": "Sorting",
"description": (
"implement introsort that switches from quicksort to heapsort when recursion depth exceeds a limit, "
"prove it always terminates with a sorted array"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
# ─── Searching (13-20) ───────────────────────────────────────────
{
"id": 13,
"name": "linear_search",
"category": "Searching",
"description": (
"implement linear search that finds the first occurrence of an element in a list, prove it returns the "
"correct index or indicates absence"
),
"difficulty": "Easy",
"proof_complexity": "Low",
},
{
"id": 14,
"name": "ternary_search",
"category": "Searching",
"description": (
"implement ternary search on a sorted array that divides the search space into three parts, prove "
"correctness and termination"
),
"difficulty": "Medium",
"proof_complexity": "Medium",
},
{
"id": 15,
"name": "jump_search",
"category": "Searching",
"description": (
"implement jump search that checks elements at fixed intervals then does linear search in the "
"identified block, prove it finds the element if present"
),
"difficulty": "Medium",
"proof_complexity": "Medium",
},
{
"id": 16,
"name": "exponential_search",
"category": "Searching",
"description": (
"implement exponential search that finds the range where element may be present by doubling indices "
"then binary search, prove correctness"
),
"difficulty": "Medium",
"proof_complexity": "Medium",
},
{
"id": 17,
"name": "interpolation_search",
"category": "Searching",
"description": (
"implement interpolation search that probes positions based on value distribution, prove it finds the "
"element in uniformly distributed sorted arrays"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
{
"id": 18,
"name": "fibonacci_search",
"category": "Searching",
"description": (
"implement fibonacci search using fibonacci numbers to divide the search range, prove it correctly "
"finds elements in sorted arrays"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
{
"id": 19,
"name": "hash_table_lookup",
"category": "Searching",
"description": (
"implement a hash table with chaining for collision resolution, prove lookup returns the correct value "
"for any inserted key"
),
"difficulty": "Medium",
"proof_complexity": "Medium",
},
{
"id": 20,
"name": "bloom_filter",
"category": "Searching",
"description": (
"implement a bloom filter with multiple hash functions, prove it never produces false negatives and has "
"bounded false positive rate"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
# ─── Number Theory (21-32) ───────────────────────────────────────
{
"id": 21,
"name": "euclidean_gcd",
"category": "Number Theory",
"description": (
"implement the Euclidean algorithm for greatest common divisor, prove it always terminates and returns "
"the correct GCD of two natural numbers"
),
"difficulty": "Easy",
"proof_complexity": "Low",
},
{
"id": 22,
"name": "extended_euclidean",
"category": "Number Theory",
"description": (
"implement the extended Euclidean algorithm that finds GCD and Bézout coefficients, prove that a*x + "
"b*y = gcd(a,b)"
),
"difficulty": "Medium",
"proof_complexity": "Medium",
},
{
"id": 23,
"name": "sieve_of_eratosthenes",
"category": "Number Theory",
"description": (
"implement the Sieve of Eratosthenes to find all primes up to n, prove every number marked as prime is "
"actually prime and all composites are marked"
),
"difficulty": "Medium",
"proof_complexity": "Medium",
},
{
"id": 24,
"name": "prime_factorization",
"category": "Number Theory",
"description": (
"implement trial division prime factorization, prove the product of returned prime factors equals the "
"original number"
),
"difficulty": "Medium",
"proof_complexity": "Medium",
},
{
"id": 25,
"name": "modular_exponentiation",
"category": "Number Theory",
"description": (
"implement modular exponentiation using square-and-multiply, prove it correctly computes (base^exp) mod m"
),
"difficulty": "Medium",
"proof_complexity": "Medium",
},
{
"id": 26,
"name": "fermats_little_theorem",
"category": "Number Theory",
"description": (
"implement a primality test based on Fermat's little theorem, prove that if a^(p-1) ≡ 1 (mod p) then p "
"is probably prime"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
{
"id": 27,
"name": "miller_rabin_primality",
"category": "Number Theory",
"description": (
"implement the Miller-Rabin primality test with k witnesses, prove it correctly identifies composites "
"and has bounded error probability"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
{
"id": 28,
"name": "lcm_computation",
"category": "Number Theory",
"description": (
"implement least common multiple computation using the relationship lcm(a,b) = |a*b|/gcd(a,b), prove "
"the result is the smallest positive integer divisible by both"
),
"difficulty": "Easy",
"proof_complexity": "Low",
},
{
"id": 29,
"name": "chinese_remainder_theorem",
"category": "Number Theory",
"description": (
"implement the Chinese Remainder Theorem solver for coprime moduli, prove the solution satisfies all "
"congruences and is unique modulo the product"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
{
"id": 30,
"name": "euler_totient",
"category": "Number Theory",
"description": (
"implement Euler's totient function that counts integers coprime to n, prove the result equals the "
"count of numbers less than n that are coprime to n"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
{
"id": 31,
"name": "integer_square_root",
"category": "Number Theory",
"description": (
"implement integer square root using Newton's method, prove the result is the largest integer whose "
"square is at most n"
),
"difficulty": "Medium",
"proof_complexity": "Medium",
},
{
"id": 32,
"name": "perfect_number_check",
"category": "Number Theory",
"description": (
"implement a function that checks if a number is perfect (sum of proper divisors equals the number), "
"prove correctness for all inputs"
),
"difficulty": "Easy",
"proof_complexity": "Low",
},
# ─── Data Structures (33-48) ─────────────────────────────────────
{
"id": 33,
"name": "linked_list_reverse",
"category": "Data Structures",
"description": (
"implement an in-place singly linked list reversal, prove the reversed list has the same elements in "
"reverse order and the same length"
),
"difficulty": "Medium",
"proof_complexity": "High",
},
{
"id": 34,
"name": "linked_list_merge",
"category": "Data Structures",
"description": (
"implement merging of two sorted linked lists into one sorted linked list, prove the result is sorted "
"and contains all elements from both lists"
),
"difficulty": "Medium",
"proof_complexity": "Medium",
},
{
"id": 35,
"name": "stack_with_max",
"category": "Data Structures",
"description": (
"implement a stack that supports push, pop, and get-max in O(1) time, prove all operations maintain the "
"stack invariant and max is correct"
),
"difficulty": "Medium",
"proof_complexity": "Medium",
},
{
"id": 36,
"name": "queue_from_stacks",
"category": "Data Structures",
"description": (
"implement a FIFO queue using two stacks, prove enqueue and dequeue operations maintain FIFO ordering"
),
"difficulty": "Medium",
"proof_complexity": "Medium",
},
{
"id": 37,
"name": "circular_buffer",
"category": "Data Structures",
"description": (
"implement a circular buffer with fixed capacity, prove it correctly wraps around and never overflows "
"beyond capacity"
),
"difficulty": "Medium",
"proof_complexity": "Medium",
},
{
"id": 38,
"name": "binary_search_tree_insert",
"category": "Data Structures",
"description": (
"implement insertion into a binary search tree, prove the BST property is maintained after insertion"
),
"difficulty": "Medium",
"proof_complexity": "High",
},
{
"id": 39,
"name": "binary_search_tree_search",
"category": "Data Structures",
"description": (
"implement search in a binary search tree, prove it returns the node if present and None if not, with "
"correctness of BST ordering"
),
"difficulty": "Easy",
"proof_complexity": "Medium",
},
{
"id": 40,
"name": "avl_tree_rotation",
"category": "Data Structures",
"description": (
"implement AVL tree left and right rotations, prove rotations preserve the BST property and restore the "
"balance factor invariant"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
{
"id": 41,
"name": "heap_insert_extract",
"category": "Data Structures",
"description": (
"implement binary heap insert and extract-min operations, prove the heap property is maintained after "
"each operation"
),
"difficulty": "Medium",
"proof_complexity": "High",
},
{
"id": 42,
"name": "trie_insert_search",
"category": "Data Structures",
"description": (
"implement a trie (prefix tree) with insert and search operations, prove search returns true if and "
"only if the key was inserted"
),
"difficulty": "Medium",
"proof_complexity": "Medium",
},
{
"id": 43,
"name": "hash_map_put_get",
"category": "Data Structures",
"description": (
"implement a hash map with put and get operations using open addressing, prove get returns the most "
"recently put value for any key"
),
"difficulty": "Medium",
"proof_complexity": "Medium",
},
{
"id": 44,
"name": "doubly_linked_list",
"category": "Data Structures",
"description": (
"implement a doubly linked list with insert, delete, and traverse operations, prove the forward and "
"backward traversals produce reverse sequences"
),
"difficulty": "Medium",
"proof_complexity": "High",
},
{
"id": 45,
"name": "skip_list_search",
"category": "Data Structures",
"description": (
"implement search in a skip list data structure, prove it correctly finds elements with O(log n) "
"expected time"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
{
"id": 46,
"name": "segment_tree_build",
"category": "Data Structures",
"description": (
"build a segment tree for range sum queries, prove each node correctly stores the sum of its range"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
{
"id": 47,
"name": "disjoint_set_union",
"category": "Data Structures",
"description": (
"implement disjoint set union with path compression and union by rank, prove find returns the correct "
"representative for each element"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
{
"id": 48,
"name": "lru_cache",
"category": "Data Structures",
"description": (
"implement an LRU cache with get and put operations in O(1) time, prove the least recently used item is "
"evicted when capacity is exceeded"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
# ─── Graph Algorithms (49-62) ────────────────────────────────────
{
"id": 49,
"name": "bfs_shortest_path",
"category": "Graph",
"description": (
"implement breadth-first search to find shortest path in an unweighted graph, prove the distance to "
"each reachable node is minimal"
),
"difficulty": "Medium",
"proof_complexity": "High",
},
{
"id": 50,
"name": "dfs_cycle_detection",
"category": "Graph",
"description": (
"implement depth-first search to detect cycles in a directed graph, prove it correctly identifies all "
"cyclic graphs"
),
"difficulty": "Medium",
"proof_complexity": "High",
},
{
"id": 51,
"name": "dijkstra_shortest_path",
"category": "Graph",
"description": (
"implement Dijkstra's algorithm for single-source shortest paths with non-negative weights, prove it "
"computes the correct shortest distance to every vertex"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
{
"id": 52,
"name": "bellman_ford",
"category": "Graph",
"description": (
"implement Bellman-Ford algorithm for shortest paths that handles negative edge weights, prove it "
"detects negative cycles and computes correct distances otherwise"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
{
"id": 53,
"name": "floyd_warshall",
"category": "Graph",
"description": (
"implement Floyd-Warshall all-pairs shortest path algorithm, prove after completion dist[i][j] equals "
"the shortest path distance between i and j"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
{
"id": 54,
"name": "kruskal_mst",
"category": "Graph",
"description": (
"implement Kruskal's minimum spanning tree algorithm using union-find, prove the result is a spanning "
"tree with minimum total weight"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
{
"id": 55,
"name": "prim_mst",
"category": "Graph",
"description": (
"implement Prim's minimum spanning tree algorithm, prove the result connects all vertices with minimum "
"total edge weight"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
{
"id": 56,
"name": "topological_sort",
"category": "Graph",
"description": (
"implement topological sort using Kahn's algorithm, prove the output ordering respects all edges (if "
"u→v then u appears before v)"
),
"difficulty": "Medium",
"proof_complexity": "High",
},
{
"id": 57,
"name": "kosaraju_scc",
"category": "Graph",
"description": (
"implement Kosaraju's algorithm for finding strongly connected components, prove each component is "
"maximal and strongly connected"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
{
"id": 58,
"name": "tarjan_scc",
"category": "Graph",
"description": (
"implement Tarjan's algorithm for strongly connected components using a single DFS, prove correctness "
"of component identification"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
{
"id": 59,
"name": "ford_fulkerson_max_flow",
"category": "Graph",
"description": (
"implement Ford-Fulkerson maximum flow algorithm using augmenting paths, prove the result equals the "
"minimum cut capacity"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
{
"id": 60,
"name": "graph_bipartite_check",
"category": "Graph",
"description": (
"implement a bipartite graph checker using two-coloring, prove a graph is bipartite if and only if it "
"is 2-colorable"
),
"difficulty": "Medium",
"proof_complexity": "Medium",
},
{
"id": 61,
"name": "graph_connectivity",
"category": "Graph",
"description": (
"implement connected component counting using BFS, prove the count equals the number of connected "
"components in the graph"
),
"difficulty": "Medium",
"proof_complexity": "Medium",
},
{
"id": 62,
"name": "a_star_pathfinding",
"category": "Graph",
"description": (
"implement A* pathfinding with an admissible heuristic, prove it finds the optimal path when the "
"heuristic is admissible"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
# ─── Dynamic Programming (63-74) ─────────────────────────────────
{
"id": 63,
"name": "fibonacci_dp",
"category": "Dynamic Programming",
"description": (
"implement Fibonacci number computation using dynamic programming, prove fib(n) = fib(n-1) + fib(n-2) "
"with correct base cases"
),
"difficulty": "Easy",
"proof_complexity": "Low",
},
{
"id": 64,
"name": "knapsack_01",
"category": "Dynamic Programming",
"description": (
"implement the 0/1 knapsack problem using dynamic programming, prove the solution maximizes total value "
"without exceeding capacity"
),
"difficulty": "Medium",
"proof_complexity": "High",
},
{
"id": 65,
"name": "longest_common_subsequence",
"category": "Dynamic Programming",
"description": (
"implement longest common subsequence using dynamic programming, prove the result is a subsequence of "
"both inputs and is of maximum length"
),
"difficulty": "Medium",
"proof_complexity": "High",
},
{
"id": 66,
"name": "longest_increasing_subsequence",
"category": "Dynamic Programming",
"description": (
"implement longest increasing subsequence using dynamic programming, prove the result is strictly "
"increasing and of maximum length"
),
"difficulty": "Medium",
"proof_complexity": "High",
},
{
"id": 67,
"name": "matrix_chain_multiplication",
"category": "Dynamic Programming",
"description": (
"implement optimal matrix chain multiplication ordering, prove the parenthesization minimizes the total "
"number of scalar multiplications"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
{
"id": 68,
"name": "edit_distance",
"category": "Dynamic Programming",
"description": (
"implement Levenshtein edit distance using dynamic programming, prove the result is the minimum number "
"of insertions, deletions, and substitutions to transform one string to another"
),
"difficulty": "Medium",
"proof_complexity": "High",
},
{
"id": 69,
"name": "coin_change",
"category": "Dynamic Programming",
"description": (
"implement the coin change problem to find minimum coins needed for a target amount, prove the result "
"uses the minimum number of coins or reports impossibility"
),
"difficulty": "Medium",
"proof_complexity": "Medium",
},
{
"id": 70,
"name": "subset_sum",
"category": "Dynamic Programming",
"description": (
"implement the subset sum problem using dynamic programming, prove it correctly determines whether a "
"subset with the target sum exists"
),
"difficulty": "Medium",
"proof_complexity": "Medium",
},
{
"id": 71,
"name": "rod_cutting",
"category": "Dynamic Programming",
"description": (
"implement the rod cutting problem to maximize revenue, prove the solution finds the optimal way to cut "
"a rod of length n"
),
"difficulty": "Medium",
"proof_complexity": "Medium",
},
{
"id": 72,
"name": "palindrome_partitioning",
"category": "Dynamic Programming",
"description": (
"implement minimum palindrome partitioning of a string, prove the result partitions the string into the "
"minimum number of palindromic substrings"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
{
"id": 73,
"name": "wildcard_matching",
"category": "Dynamic Programming",
"description": (
"implement wildcard pattern matching with '?' and '*' using dynamic programming, prove it correctly "
"matches patterns against text"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
{
"id": 74,
"name": "optimal_bst",
"category": "Dynamic Programming",
"description": (
"implement optimal binary search tree construction given key frequencies, prove the resulting tree "
"minimizes expected search cost"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
# ─── String Algorithms (75-84) ───────────────────────────────────
{
"id": 75,
"name": "kmp_pattern_matching",
"category": "String",
"description": (
"implement the Knuth-Morris-Pratt string matching algorithm, prove it finds all occurrences of a "
"pattern in text with O(n+m) time"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
{
"id": 76,
"name": "rabin_karp_matching",
"category": "String",
"description": (
"implement Rabin-Karp string matching using rolling hash, prove it correctly identifies all pattern "
"occurrences"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
{
"id": 77,
"name": "z_algorithm",
"category": "String",
"description": (
"implement the Z-algorithm for string matching, prove the Z-array correctly stores the length of the "
"longest common prefix with the string itself"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
{
"id": 78,
"name": "boyer_moore_search",
"category": "String",
"description": (
"implement the Boyer-Moore string search algorithm with bad character rule, prove it correctly finds "
"all pattern occurrences"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
{
"id": 79,
"name": "string_reversal",
"category": "String",
"description": (
"implement in-place string reversal, prove the output is the reverse of the input with the same length"
),
"difficulty": "Easy",
"proof_complexity": "Low",
},
{
"id": 80,
"name": "palindrome_check",
"category": "String",
"description": (
"implement palindrome checking that determines if a string reads the same forwards and backwards, prove "
"correctness for all inputs"
),
"difficulty": "Easy",
"proof_complexity": "Low",
},
{
"id": 81,
"name": "longest_palindrome_substring",
"category": "String",
"description": (
"implement finding the longest palindromic substring using expand around center, prove the result is a "
"palindrome and is of maximum length"
),
"difficulty": "Medium",
"proof_complexity": "Medium",
},
{
"id": 82,
"name": "anagram_check",
"category": "String",
"description": (
"implement anagram checking that determines if two strings are permutations of each other, prove "
"correctness for all inputs"
),
"difficulty": "Easy",
"proof_complexity": "Low",
},
{
"id": 83,
"name": "run_length_encoding",
"category": "String",
"description": (
"implement run-length encoding compression, prove decoding the encoded string produces the original string"
),
"difficulty": "Easy",
"proof_complexity": "Low",
},
{
"id": 84,
"name": "suffix_array_build",
"category": "String",
"description": (
"implement suffix array construction, prove the array contains all suffixes sorted in lexicographic order"
),
"difficulty": "Hard",
"proof_complexity": "High",
},
# ─── Mathematical (85-92) ────────────────────────────────────────
{
"id": 85,
"name": "factorial",
"category": "Mathematical",
"description": (
"implement factorial computation, prove n! = n * (n-1)! with base case 0! = 1 for all natural numbers"
),
"difficulty": "Easy",
"proof_complexity": "Low",
},
{
"id": 86,
"name": "power_function",
"category": "Mathematical",
"description": (
"implement exponentiation by squaring, prove it correctly computes x^n for all natural number exponents "
"in O(log n) time"
),
"difficulty": "Easy",
"proof_complexity": "Low",
},
{
"id": 87,
"name": "newton_raphson_sqrt",
"category": "Mathematical",
"description": (
"implement square root computation using Newton-Raphson method, prove convergence to the correct square "
"root within epsilon"
),
"difficulty": "Medium",
"proof_complexity": "Medium",
},
{
"id": 88,
"name": "matrix_multiplication",
"category": "Mathematical",
"description": (
"implement matrix multiplication for n×n matrices, prove the result satisfies the mathematical "
"definition of matrix product"
),
"difficulty": "Medium",