trackler 2.0.8.27 → 2.0.8.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/common/exercises/simple-cipher/description.md +1 -1
- data/common/exercises/triangle/description.md +12 -23
- data/lib/trackler/version.rb +1 -1
- data/tracks/kotlin/config.json +5 -0
- data/tracks/kotlin/exercises/bank-account/build.gradle +32 -0
- data/tracks/kotlin/exercises/bank-account/src/example/kotlin/BankAccount.kt +27 -0
- data/tracks/kotlin/exercises/bank-account/src/main/kotlin/.keep +0 -0
- data/tracks/kotlin/exercises/bank-account/src/test/kotlin/BankAccountTest.kt +73 -0
- data/tracks/kotlin/exercises/settings.gradle +1 -0
- data/tracks/python/config.json +11 -11
- data/tracks/python/exercises/accumulate/accumulate_test.py +16 -14
- data/tracks/python/exercises/acronym/acronym_test.py +8 -7
- data/tracks/python/exercises/allergies/allergies_test.py +5 -6
- data/tracks/python/exercises/atbash-cipher/atbash_cipher_test.py +16 -22
- data/tracks/python/exercises/binary-search/binary_search_test.py +12 -10
- data/tracks/python/exercises/binary/binary_test.py +7 -8
- data/tracks/python/exercises/circular-buffer/circular_buffer_test.py +16 -17
- data/tracks/python/exercises/clock/clock_test.py +35 -35
- data/tracks/python/exercises/crypto-square/crypto_square_test.py +5 -6
- data/tracks/python/exercises/diamond/diamond_test.py +3 -4
- data/tracks/python/exercises/etl/etl_test.py +4 -4
- data/tracks/python/exercises/gigasecond/gigasecond_test.py +11 -19
- data/tracks/python/exercises/grade-school/grade_school_test.py +17 -19
- data/tracks/python/exercises/grains/grains_test.py +14 -14
- data/tracks/python/exercises/grep/grep_test.py +51 -64
- data/tracks/python/exercises/hamming/hamming_test.py +13 -13
- data/tracks/python/exercises/hello-world/hello_world_test.py +1 -2
- data/tracks/python/exercises/hexadecimal/hexadecimal_test.py +9 -10
- data/tracks/python/exercises/house/house_test.py +6 -6
- data/tracks/python/exercises/kindergarten-garden/kindergarten_garden_test.py +22 -19
- data/tracks/python/exercises/largest-series-product/largest_series_product_test.py +29 -28
- data/tracks/python/exercises/linked-list/linked_list_test.py +18 -19
- data/tracks/python/exercises/list-ops/list_ops_test.py +44 -39
- data/tracks/python/exercises/matrix/matrix_test.py +6 -6
- data/tracks/python/exercises/meetup/meetup_test.py +27 -27
- data/tracks/python/exercises/minesweeper/example.py +4 -2
- data/tracks/python/exercises/minesweeper/minesweeper_test.py +9 -9
- data/tracks/python/exercises/nucleotide-count/nucleotide_count_test.py +6 -6
- data/tracks/python/exercises/ocr-numbers/ocr_numbers_test.py +63 -49
- data/tracks/python/exercises/octal/octal_test.py +7 -7
- data/tracks/python/exercises/palindrome-products/palindrome_products_test.py +9 -9
- data/tracks/python/exercises/pascals-triangle/pascals_triangle_test.py +7 -7
- data/tracks/python/exercises/phone-number/phone_number_test.py +8 -8
- data/tracks/python/exercises/pig-latin/pig_latin_test.py +15 -15
- data/tracks/python/exercises/point-mutations/point_mutations_test.py +11 -11
- data/tracks/python/exercises/poker/poker_test.py +32 -30
- data/tracks/python/exercises/prime-factors/prime_factors_test.py +11 -11
- data/tracks/python/exercises/proverb/proverb_test.py +16 -9
- data/tracks/python/exercises/pythagorean-triplet/pythagorean_triplet_test.py +14 -12
- data/tracks/python/exercises/queen-attack/queen_attack_test.py +10 -10
- data/tracks/python/exercises/rail-fence-cipher/example.py +2 -1
- data/tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py +14 -13
- data/tracks/python/exercises/raindrops/raindrops_test.py +16 -16
- data/tracks/python/exercises/rectangles/rectangles_test.py +9 -9
- data/tracks/python/exercises/rna-transcription/rna_transcription_test.py +8 -8
- data/tracks/python/exercises/robot-name/robot_name_test.py +1 -1
- data/tracks/python/exercises/robot-simulator/robot_simulator_test.py +18 -19
- data/tracks/python/exercises/roman-numerals/roman_numerals_test.py +1 -1
- data/tracks/python/exercises/run-length-encoding/run_length_encoding_test.py +15 -16
- data/tracks/python/exercises/saddle-points/saddle_points_test.py +4 -4
- data/tracks/python/exercises/say/say_test.py +21 -23
- data/tracks/python/exercises/scrabble-score/scrabble_score_test.py +9 -9
- data/tracks/python/exercises/secret-handshake/secret_handshake_test.py +14 -13
- data/tracks/python/exercises/series/example.py +3 -3
- data/tracks/python/exercises/series/series_test.py +16 -12
- data/tracks/python/exercises/simple-cipher/simple_cipher_test.py +21 -19
- data/tracks/python/exercises/space-age/space_age_test.py +16 -16
- data/tracks/python/exercises/strain/strain_test.py +9 -8
- data/tracks/python/exercises/sublist/sublist_test.py +19 -20
- data/tracks/python/exercises/sum-of-multiples/example.py +1 -4
- data/tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py +31 -26
- data/tracks/python/exercises/triangle/triangle_test.py +15 -30
- data/tracks/python/exercises/trinary/trinary_test.py +7 -7
- data/tracks/python/exercises/twelve-days/twelve_days_test.py +13 -14
- data/tracks/python/exercises/word-count/example.py +1 -9
- data/tracks/python/exercises/word-count/word_count_test.py +0 -15
- data/tracks/python/exercises/wordy/wordy_test.py +17 -18
- data/tracks/python/exercises/zebra-puzzle/example.py +20 -23
- data/tracks/python/exercises/zebra-puzzle/zebra_puzzle_test.py +3 -3
- data/tracks/python/test/check-exercises.py +1 -1
- metadata +6 -2
@@ -6,35 +6,35 @@ from phone_number import Phone
|
|
6
6
|
class PhoneTest(unittest.TestCase):
|
7
7
|
def test_cleans_number(self):
|
8
8
|
number = Phone("(123) 456-7890").number
|
9
|
-
self.assertEqual("1234567890"
|
9
|
+
self.assertEqual(number, "1234567890")
|
10
10
|
|
11
11
|
def test_cleans_number_with_dots(self):
|
12
12
|
number = Phone("123.456.7890").number
|
13
|
-
self.assertEqual("1234567890"
|
13
|
+
self.assertEqual(number, "1234567890")
|
14
14
|
|
15
15
|
def test_valid_when_11_digits_and_first_is_1(self):
|
16
16
|
number = Phone("11234567890").number
|
17
|
-
self.assertEqual("1234567890"
|
17
|
+
self.assertEqual(number, "1234567890")
|
18
18
|
|
19
19
|
def test_invalid_when_11_digits(self):
|
20
20
|
number = Phone("21234567890").number
|
21
|
-
self.assertEqual("0000000000"
|
21
|
+
self.assertEqual(number, "0000000000")
|
22
22
|
|
23
23
|
def test_invalid_when_9_digits(self):
|
24
24
|
number = Phone("123456789").number
|
25
|
-
self.assertEqual("0000000000"
|
25
|
+
self.assertEqual(number, "0000000000")
|
26
26
|
|
27
27
|
def test_area_code(self):
|
28
28
|
number = Phone("1234567890")
|
29
|
-
self.assertEqual(
|
29
|
+
self.assertEqual(number.area_code(), "123")
|
30
30
|
|
31
31
|
def test_pretty_print(self):
|
32
32
|
number = Phone("1234567890")
|
33
|
-
self.assertEqual("(123) 456-7890"
|
33
|
+
self.assertEqual(number.pretty(), "(123) 456-7890")
|
34
34
|
|
35
35
|
def test_pretty_print_with_full_us_phone_number(self):
|
36
36
|
number = Phone("11234567890")
|
37
|
-
self.assertEqual("(123) 456-7890"
|
37
|
+
self.assertEqual(number.pretty(), "(123) 456-7890")
|
38
38
|
|
39
39
|
|
40
40
|
if __name__ == '__main__':
|
@@ -5,49 +5,49 @@ from pig_latin import translate
|
|
5
5
|
|
6
6
|
class PigLatinTests(unittest.TestCase):
|
7
7
|
def test_word_beginning_with_a(self):
|
8
|
-
self.assertEqual("
|
8
|
+
self.assertEqual(translate("apple"), "appleay")
|
9
9
|
|
10
10
|
def test_word_beginning_with_e(self):
|
11
|
-
self.assertEqual("
|
11
|
+
self.assertEqual(translate("ear"), "earay")
|
12
12
|
|
13
13
|
def test_word_beginning_with_p(self):
|
14
|
-
self.assertEqual("
|
14
|
+
self.assertEqual(translate("pig"), "igpay")
|
15
15
|
|
16
16
|
def test_word_beginning_with_k(self):
|
17
|
-
self.assertEqual("
|
17
|
+
self.assertEqual(translate("koala"), "oalakay")
|
18
18
|
|
19
19
|
def test_word_beginning_with_ch(self):
|
20
|
-
self.assertEqual("
|
20
|
+
self.assertEqual(translate("chair"), "airchay")
|
21
21
|
|
22
22
|
def test_word_beginning_with_qu(self):
|
23
|
-
self.assertEqual("
|
23
|
+
self.assertEqual(translate("queen"), "eenquay")
|
24
24
|
|
25
25
|
def test_word_beginning_with_squ(self):
|
26
|
-
self.assertEqual("
|
26
|
+
self.assertEqual(translate("square"), "aresquay")
|
27
27
|
|
28
28
|
def test_word_beginning_with_th(self):
|
29
|
-
self.assertEqual("
|
29
|
+
self.assertEqual(translate("therapy"), "erapythay")
|
30
30
|
|
31
31
|
def test_word_beginning_with_thr(self):
|
32
|
-
self.assertEqual("
|
32
|
+
self.assertEqual(translate("thrush"), "ushthray")
|
33
33
|
|
34
34
|
def test_word_beginning_with_sch(self):
|
35
|
-
self.assertEqual("
|
35
|
+
self.assertEqual(translate("school"), "oolschay")
|
36
36
|
|
37
37
|
def test_translates_phrase(self):
|
38
|
-
self.assertEqual("
|
38
|
+
self.assertEqual(translate("quick fast run"), "ickquay astfay unray")
|
39
39
|
|
40
40
|
def test_word_beginning_with_ye(self):
|
41
|
-
self.assertEqual("
|
41
|
+
self.assertEqual(translate("yellow"), "ellowyay")
|
42
42
|
|
43
43
|
def test_word_beginning_with_yt(self):
|
44
|
-
self.assertEqual("
|
44
|
+
self.assertEqual(translate("yttria"), "yttriaay")
|
45
45
|
|
46
46
|
def test_word_beginning_with_xe(self):
|
47
|
-
self.assertEqual("
|
47
|
+
self.assertEqual(translate("xenon"), "enonxay")
|
48
48
|
|
49
49
|
def test_word_beginning_with_xr(self):
|
50
|
-
self.assertEqual("
|
50
|
+
self.assertEqual(translate("xray"), "xrayay")
|
51
51
|
|
52
52
|
|
53
53
|
if __name__ == '__main__':
|
@@ -5,31 +5,31 @@ from point_mutations import hamming_distance
|
|
5
5
|
|
6
6
|
class DNATest(unittest.TestCase):
|
7
7
|
def test_no_difference_between_empty_strands(self):
|
8
|
-
self.assertEqual(
|
8
|
+
self.assertEqual(hamming_distance('', ''), 0)
|
9
9
|
|
10
10
|
def test_no_difference_between_identical_strands(self):
|
11
|
-
self.assertEqual(
|
11
|
+
self.assertEqual(hamming_distance('GGACTGA', 'GGACTGA'), 0)
|
12
12
|
|
13
13
|
def test_complete_hamming_distance_in_small_strand(self):
|
14
|
-
self.assertEqual(
|
14
|
+
self.assertEqual(hamming_distance('ACT', 'GGA'), 3)
|
15
15
|
|
16
16
|
def test_hamming_distance_in_off_by_one_strand(self):
|
17
|
-
self.assertEqual(
|
18
|
-
|
19
|
-
|
17
|
+
self.assertEqual(
|
18
|
+
hamming_distance('GGACGGATTCTGACCTGGACTAATTTTGGGG',
|
19
|
+
'AGGACGGATTCTGACCTGGACTAATTTTGGGG'), 19)
|
20
20
|
|
21
21
|
def test_small_hamming_distance_in_middle_somewhere(self):
|
22
|
-
self.assertEqual(
|
22
|
+
self.assertEqual(hamming_distance('GGACG', 'GGTCG'), 1)
|
23
23
|
|
24
24
|
def test_larger_distance(self):
|
25
|
-
self.assertEqual(
|
25
|
+
self.assertEqual(hamming_distance('ACCAGGG', 'ACTATGG'), 2)
|
26
26
|
|
27
27
|
def test_ignores_extra_length_on_other_strand_when_longer(self):
|
28
|
-
self.assertEqual(
|
28
|
+
self.assertEqual(hamming_distance('AAACTAGGGG', 'AGGCTAGCGGTAGGAC'), 3)
|
29
29
|
|
30
30
|
def test_ignores_extra_length_on_original_strand_when_longer(self):
|
31
|
-
self.assertEqual(
|
32
|
-
|
31
|
+
self.assertEqual(
|
32
|
+
hamming_distance('GACTACGGACAGGGTAGGGAAT', 'GACATCGCACACC'), 5)
|
33
33
|
|
34
34
|
|
35
35
|
if __name__ == '__main__':
|
@@ -6,112 +6,114 @@ from poker import poker
|
|
6
6
|
class PokerTest(unittest.TestCase):
|
7
7
|
def test_one_hand(self):
|
8
8
|
hand = '4S 5S 7H 8D JC'.split()
|
9
|
-
self.assertEqual([hand],
|
9
|
+
self.assertEqual(poker([hand]), [hand])
|
10
10
|
|
11
11
|
def test_nothing_vs_one_pair(self):
|
12
12
|
nothing = '4S 5H 6S 8D JH'.split()
|
13
13
|
pairOf4 = '2S 4H 6S 4D JH'.split()
|
14
|
-
self.assertEqual(
|
14
|
+
self.assertEqual(poker([nothing, pairOf4]), [pairOf4])
|
15
15
|
|
16
16
|
def test_two_pair(self):
|
17
17
|
pairOf2 = '4S 2H 6S 2D JH'.split()
|
18
18
|
pairOf4 = '2S 4H 6S 4D JH'.split()
|
19
|
-
self.assertEqual(
|
19
|
+
self.assertEqual(poker([pairOf2, pairOf4]), [pairOf4])
|
20
20
|
|
21
21
|
def test_one_pair_vs_double_pair(self):
|
22
22
|
pairOf8 = '2S 8H 6S 8D JH'.split()
|
23
23
|
doublePair = '4S 5H 4S 8D 5H'.split()
|
24
|
-
self.assertEqual(
|
24
|
+
self.assertEqual(poker([pairOf8, doublePair]), [doublePair])
|
25
25
|
|
26
26
|
def test_two_double_pair(self):
|
27
27
|
doublePair2and8 = '2S 8H 2S 8D JH'.split()
|
28
28
|
doublePair4and5 = '4S 5H 4S 8D 5H'.split()
|
29
|
-
self.assertEqual(
|
30
|
-
|
29
|
+
self.assertEqual(
|
30
|
+
poker([doublePair2and8, doublePair4and5]), [doublePair2and8])
|
31
31
|
|
32
32
|
def test_two_double_pair_lower(self):
|
33
33
|
doublePair2and8 = '2S 8H 2S 8C JH'.split()
|
34
34
|
doublePair3and8 = '4S 3H 8S 8D 3H'.split()
|
35
|
-
self.assertEqual(
|
36
|
-
|
35
|
+
self.assertEqual(
|
36
|
+
poker([doublePair2and8, doublePair3and8]), [doublePair3and8])
|
37
37
|
|
38
38
|
def test_two_double_pair_and_high(self):
|
39
39
|
doublePair2and8 = '2S 8H 2C 8C 3H'.split()
|
40
40
|
doublePair2and8high = '2D 2H 8S 8D AH'.split()
|
41
|
-
self.assertEqual(
|
42
|
-
|
41
|
+
self.assertEqual(
|
42
|
+
poker([doublePair2and8high, doublePair2and8]),
|
43
|
+
[doublePair2and8high])
|
43
44
|
|
44
45
|
def test_double_pair_vs_three(self):
|
45
46
|
doublePair2and8 = '2S 8H 2S 8D JH'.split()
|
46
47
|
threeOf4 = '4S 5H 4S 8D 4H'.split()
|
47
|
-
self.assertEqual(
|
48
|
+
self.assertEqual(poker([doublePair2and8, threeOf4]), [threeOf4])
|
48
49
|
|
49
50
|
def test_two_three(self):
|
50
51
|
threeOf2 = '2S 2H 2S 8D JH'.split()
|
51
52
|
threeOf1 = '4S AH AS 8D AH'.split()
|
52
|
-
self.assertEqual(
|
53
|
+
self.assertEqual(poker([threeOf2, threeOf1]), [threeOf1])
|
53
54
|
|
54
55
|
def test_three_vs_straight(self):
|
55
56
|
threeOf4 = '4S 5H 4S 8D 4H'.split()
|
56
57
|
straight = '3S 4H 2S 6D 5H'.split()
|
57
|
-
self.assertEqual(
|
58
|
+
self.assertEqual(poker([threeOf4, straight]), [straight])
|
58
59
|
|
59
60
|
def test_two_straights(self):
|
60
61
|
straightTo8 = '4S 6H 7S 8D 5H'.split()
|
61
62
|
straightTo9 = '5S 7H 8S 9D 6H'.split()
|
62
|
-
self.assertEqual(
|
63
|
+
self.assertEqual(poker([straightTo8, straightTo9]), [straightTo9])
|
63
64
|
straightTo1 = 'AS QH KS TD JH'.split()
|
64
65
|
straightTo5 = '4S AH 3S 2D 5H'.split()
|
65
|
-
self.assertEqual(
|
66
|
+
self.assertEqual(poker([straightTo1, straightTo5]), [straightTo1])
|
66
67
|
|
67
68
|
def test_straight_vs_flush(self):
|
68
69
|
straightTo8 = '4S 6H 7S 8D 5H'.split()
|
69
70
|
flushTo7 = '2S 4S 5S 6S 7S'.split()
|
70
|
-
self.assertEqual(
|
71
|
+
self.assertEqual(poker([straightTo8, flushTo7]), [flushTo7])
|
71
72
|
|
72
73
|
def test_two_flushes(self):
|
73
74
|
flushTo8 = '3H 6H 7H 8H 5H'.split()
|
74
75
|
flushTo7 = '2S 4S 5S 6S 7S'.split()
|
75
|
-
self.assertEqual(
|
76
|
+
self.assertEqual(poker([flushTo8, flushTo7]), [flushTo8])
|
76
77
|
|
77
78
|
def test_flush_vs_full(self):
|
78
79
|
flushTo8 = '3H 6H 7H 8H 5H'.split()
|
79
80
|
full = '4S 5H 4S 5D 4H'.split()
|
80
|
-
self.assertEqual(
|
81
|
+
self.assertEqual(poker([full, flushTo8]), [full])
|
81
82
|
|
82
83
|
def test_two_fulls(self):
|
83
84
|
fullOf4by9 = '4H 4S 4D 9S 9D'.split()
|
84
85
|
fullOf5by8 = '5H 5S 5D 8S 8D'.split()
|
85
|
-
self.assertEqual(
|
86
|
+
self.assertEqual(poker([fullOf4by9, fullOf5by8]), [fullOf5by8])
|
86
87
|
|
87
88
|
def test_full_vs_square(self):
|
88
89
|
full = '4S 5H 4S 5D 4H'.split()
|
89
90
|
squareOf3 = '3S 3H 2S 3D 3H'.split()
|
90
|
-
self.assertEqual(
|
91
|
+
self.assertEqual(poker([full, squareOf3]), [squareOf3])
|
91
92
|
|
92
93
|
def test_two_square(self):
|
93
94
|
squareOf2 = '2S 2H 2S 8D 2H'.split()
|
94
95
|
squareOf5 = '4S 5H 5S 5D 5H'.split()
|
95
|
-
self.assertEqual(
|
96
|
+
self.assertEqual(poker([squareOf2, squareOf5]), [squareOf5])
|
96
97
|
|
97
98
|
def test_square_vs_straight_flush(self):
|
98
99
|
squareOf5 = '4S 5H 5S 5D 5H'.split()
|
99
100
|
straightFlushTo9 = '5S 7S 8S 9S 6S'.split()
|
100
|
-
self.assertEqual(
|
101
|
-
|
101
|
+
self.assertEqual(
|
102
|
+
poker([squareOf5, straightFlushTo9]), [straightFlushTo9])
|
102
103
|
|
103
104
|
def test_two_straight_flushes(self):
|
104
105
|
straightFlushTo8 = '4H 6H 7H 8H 5H'.split()
|
105
106
|
straightFlushTo9 = '5S 7S 8S 9S 6S'.split()
|
106
|
-
self.assertEqual(
|
107
|
-
|
107
|
+
self.assertEqual(
|
108
|
+
poker([straightFlushTo8, straightFlushTo9]), [straightFlushTo9])
|
108
109
|
|
109
110
|
def test_three_hand_with_tie(self):
|
110
|
-
spadeStraightTo9 =
|
111
|
-
diamondStraightTo9 =
|
112
|
-
threeOf4 =
|
113
|
-
self.assertEqual(
|
114
|
-
|
111
|
+
spadeStraightTo9 = '9S 8S 7S 6S 5S'.split()
|
112
|
+
diamondStraightTo9 = '9D 8D 7D 6D 5D'.split()
|
113
|
+
threeOf4 = '4D 4S 4H QS KS'.split()
|
114
|
+
self.assertEqual(
|
115
|
+
poker([spadeStraightTo9, diamondStraightTo9, threeOf4]),
|
116
|
+
[spadeStraightTo9, diamondStraightTo9])
|
115
117
|
|
116
118
|
|
117
119
|
if __name__ == '__main__':
|
@@ -5,37 +5,37 @@ from prime_factors import prime_factors
|
|
5
5
|
|
6
6
|
class PrimeFactorsTest(unittest.TestCase):
|
7
7
|
def test_1(self):
|
8
|
-
self.assertEqual(
|
8
|
+
self.assertEqual(prime_factors(1), [])
|
9
9
|
|
10
10
|
def test_2(self):
|
11
|
-
self.assertEqual(
|
11
|
+
self.assertEqual(prime_factors(2), [2])
|
12
12
|
|
13
13
|
def test_3(self):
|
14
|
-
self.assertEqual(
|
14
|
+
self.assertEqual(prime_factors(3), [3])
|
15
15
|
|
16
16
|
def test_4(self):
|
17
|
-
self.assertEqual([2, 2]
|
17
|
+
self.assertEqual(prime_factors(4), [2, 2])
|
18
18
|
|
19
19
|
def test_6(self):
|
20
|
-
self.assertEqual([2, 3]
|
20
|
+
self.assertEqual(prime_factors(6), [2, 3])
|
21
21
|
|
22
22
|
def test_8(self):
|
23
|
-
self.assertEqual([2, 2, 2]
|
23
|
+
self.assertEqual(prime_factors(8), [2, 2, 2])
|
24
24
|
|
25
25
|
def test_9(self):
|
26
|
-
self.assertEqual([3, 3]
|
26
|
+
self.assertEqual(prime_factors(9), [3, 3])
|
27
27
|
|
28
28
|
def test_27(self):
|
29
|
-
self.assertEqual([3, 3, 3]
|
29
|
+
self.assertEqual(prime_factors(27), [3, 3, 3])
|
30
30
|
|
31
31
|
def test_625(self):
|
32
|
-
self.assertEqual([5, 5, 5, 5]
|
32
|
+
self.assertEqual(prime_factors(625), [5, 5, 5, 5])
|
33
33
|
|
34
34
|
def test_901255(self):
|
35
|
-
self.assertEqual([5, 17, 23, 461]
|
35
|
+
self.assertEqual(prime_factors(901255), [5, 17, 23, 461])
|
36
36
|
|
37
37
|
def test_93819012551(self):
|
38
|
-
self.assertEqual([11, 9539, 894119]
|
38
|
+
self.assertEqual(prime_factors(93819012551), [11, 9539, 894119])
|
39
39
|
|
40
40
|
|
41
41
|
if __name__ == '__main__':
|
@@ -7,25 +7,25 @@ class ProverbTest(unittest.TestCase):
|
|
7
7
|
def test_a_single_consequence(self):
|
8
8
|
expected = 'For want of a nail the shoe was lost.\n'\
|
9
9
|
'And all for the want of a nail.'
|
10
|
-
self.assertEqual(
|
10
|
+
self.assertEqual(proverb(['nail', 'shoe']), expected)
|
11
11
|
|
12
12
|
def test_short_list(self):
|
13
13
|
expected = 'For want of a nail the shoe was lost.\n'\
|
14
14
|
'For want of a shoe the horse was lost.\n'\
|
15
15
|
'And all for the want of a nail.'
|
16
|
-
self.assertEqual(
|
16
|
+
self.assertEqual(proverb(['nail', 'shoe', 'horse']), expected)
|
17
17
|
|
18
18
|
def test_long_list(self):
|
19
19
|
expected = 'For want of a nail the shoe was lost.\n'\
|
20
20
|
'For want of a shoe the horse was lost.\n'\
|
21
21
|
'For want of a horse the rider was lost.\n'\
|
22
22
|
'And all for the want of a nail.'
|
23
|
-
self.assertEqual(
|
23
|
+
self.assertEqual(proverb(['nail', 'shoe', 'horse', 'rider']), expected)
|
24
24
|
|
25
25
|
def test_new_itens(self):
|
26
26
|
expected = 'For want of a key the value was lost.\n'\
|
27
27
|
'And all for the want of a key.'
|
28
|
-
self.assertEqual(
|
28
|
+
self.assertEqual(proverb(['key', 'value']), expected)
|
29
29
|
|
30
30
|
def test_whole_proverb(self):
|
31
31
|
expected = 'For want of a nail the shoe was lost.\n'\
|
@@ -35,8 +35,11 @@ class ProverbTest(unittest.TestCase):
|
|
35
35
|
'For want of a message the battle was lost.\n'\
|
36
36
|
'For want of a battle the kingdom was lost.\n'\
|
37
37
|
'And all for the want of a nail.'
|
38
|
-
self.assertEqual(
|
39
|
-
|
38
|
+
self.assertEqual(
|
39
|
+
proverb([
|
40
|
+
'nail', 'shoe', 'horse', 'rider', 'message', 'battle',
|
41
|
+
'kingdom'
|
42
|
+
]), expected)
|
40
43
|
|
41
44
|
def test_qualifier(self):
|
42
45
|
expected = 'For want of a nail the shoe was lost.\n'\
|
@@ -46,9 +49,13 @@ class ProverbTest(unittest.TestCase):
|
|
46
49
|
'For want of a message the battle was lost.\n'\
|
47
50
|
'For want of a battle the kingdom was lost.\n'\
|
48
51
|
'And all for the want of a horseshoe nail.'
|
49
|
-
self.assertEqual(
|
50
|
-
|
51
|
-
|
52
|
+
self.assertEqual(
|
53
|
+
proverb(
|
54
|
+
[
|
55
|
+
'nail', 'shoe', 'horse', 'rider', 'message', 'battle',
|
56
|
+
'kingdom'
|
57
|
+
],
|
58
|
+
qualifier='horseshoe'), expected)
|
52
59
|
|
53
60
|
|
54
61
|
if __name__ == '__main__':
|
@@ -35,47 +35,49 @@
|
|
35
35
|
|
36
36
|
import unittest
|
37
37
|
|
38
|
-
from pythagorean_triplet import (
|
39
|
-
|
38
|
+
from pythagorean_triplet import (
|
39
|
+
primitive_triplets,
|
40
|
+
triplets_in_range,
|
41
|
+
is_triplet
|
42
|
+
)
|
40
43
|
|
41
44
|
|
42
45
|
class PythagoreanTripletTest(unittest.TestCase):
|
43
|
-
|
44
46
|
def test_triplet1(self):
|
45
47
|
ans = set([(3, 4, 5)])
|
46
|
-
self.assertEqual(
|
48
|
+
self.assertEqual(primitive_triplets(4), ans)
|
47
49
|
|
48
50
|
def test_triplet2(self):
|
49
51
|
ans = set([(13, 84, 85), (84, 187, 205), (84, 437, 445),
|
50
52
|
(84, 1763, 1765)])
|
51
|
-
self.assertEqual(
|
53
|
+
self.assertEqual(primitive_triplets(84), ans)
|
52
54
|
|
53
55
|
def test_triplet3(self):
|
54
56
|
ans = set([(29, 420, 421), (341, 420, 541), (420, 851, 949),
|
55
57
|
(420, 1189, 1261), (420, 1739, 1789), (420, 4891, 4909),
|
56
58
|
(420, 11021, 11029), (420, 44099, 44101)])
|
57
|
-
self.assertEqual(
|
59
|
+
self.assertEqual(primitive_triplets(420), ans)
|
58
60
|
|
59
61
|
def test_triplet4(self):
|
60
62
|
ans = set([(175, 288, 337), (288, 20735, 20737)])
|
61
|
-
self.assertEqual(
|
63
|
+
self.assertEqual(primitive_triplets(288), ans)
|
62
64
|
|
63
65
|
def test_range1(self):
|
64
66
|
ans = set([(3, 4, 5), (6, 8, 10)])
|
65
|
-
self.assertEqual(
|
67
|
+
self.assertEqual(triplets_in_range(1, 10), ans)
|
66
68
|
|
67
69
|
def test_range2(self):
|
68
70
|
ans = set([(57, 76, 95), (60, 63, 87)])
|
69
|
-
self.assertEqual(
|
71
|
+
self.assertEqual(triplets_in_range(56, 95), ans)
|
70
72
|
|
71
73
|
def test_is_triplet1(self):
|
72
|
-
self.
|
74
|
+
self.assertTrue(is_triplet((29, 20, 21)))
|
73
75
|
|
74
76
|
def test_is_triplet2(self):
|
75
|
-
self.
|
77
|
+
self.assertFalse(is_triplet((25, 25, 1225)))
|
76
78
|
|
77
79
|
def test_is_triplet3(self):
|
78
|
-
self.
|
80
|
+
self.assertTrue(is_triplet((924, 43, 925)))
|
79
81
|
|
80
82
|
def test_odd_number(self):
|
81
83
|
self.assertRaises(ValueError, primitive_triplets, 5)
|