@@ -35,9 +35,9 @@ def test_basic_example(self):
3535 def test_simple_cases (self ):
3636 """Test simple discrete log cases with known answers."""
3737 test_cases = [
38- (2 , 8 , 17 ), # 2^3 ≡ 8 (mod 17)
39- (5 , 3 , 7 ), # 5^5 ≡ 3 (mod 7)
40- (3 , 9 , 11 ), # 3^2 ≡ 9 (mod 11)
38+ (2 , 8 , 17 ), # 2^3 ≡ 8 (mod 17)
39+ (5 , 3 , 7 ), # 5^5 ≡ 3 (mod 7)
40+ (3 , 9 , 11 ), # 3^2 ≡ 9 (mod 11)
4141 ]
4242
4343 for g , h , p in test_cases :
@@ -53,8 +53,7 @@ def test_no_solution_case(self):
5353 """Test case where no solution exists."""
5454 # 3^x ≡ 7 (mod 11) has no solution (verified by brute force)
5555 # The algorithm should return None or fail to find a solution
56- result = pollards_rho_discrete_log (3 , 7 , 11 )
57- if result is not None :
56+ if (result := pollards_rho_discrete_log (3 , 7 , 11 )) is not None :
5857 # If it returns a result, it must be wrong since no solution exists
5958 assert pow (3 , result , 11 ) != 7
6059
@@ -73,10 +72,10 @@ def test_edge_cases(self):
7372 def test_small_primes (self ):
7473 """Test with small prime moduli."""
7574 test_cases = [
76- (2 , 4 , 5 ), # 2^2 ≡ 4 (mod 5)
77- (2 , 3 , 5 ), # 2^? ≡ 3 (mod 5)
78- (2 , 1 , 3 ), # 2^2 ≡ 1 (mod 3)
79- (3 , 2 , 5 ), # 3^3 ≡ 2 (mod 5)
75+ (2 , 4 , 5 ), # 2^2 ≡ 4 (mod 5)
76+ (2 , 3 , 5 ), # 2^? ≡ 3 (mod 5)
77+ (2 , 1 , 3 ), # 2^2 ≡ 1 (mod 3)
78+ (3 , 2 , 5 ), # 3^3 ≡ 2 (mod 5)
8079 ]
8180
8281 for g , h , p in test_cases :
@@ -89,9 +88,9 @@ def test_larger_examples(self):
8988 """Test with larger numbers to ensure algorithm scales."""
9089 # Test cases with larger primes
9190 test_cases = [
92- (2 , 15 , 31 ), # Find x where 2^x ≡ 15 (mod 31)
93- (3 , 10 , 37 ), # Find x where 3^x ≡ 10 (mod 37)
94- (5 , 17 , 41 ), # Find x where 5^x ≡ 17 (mod 41)
91+ (2 , 15 , 31 ), # Find x where 2^x ≡ 15 (mod 31)
92+ (3 , 10 , 37 ), # Find x where 3^x ≡ 10 (mod 37)
93+ (5 , 17 , 41 ), # Find x where 5^x ≡ 17 (mod 41)
9594 ]
9695
9796 for g , h , p in test_cases :
0 commit comments