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.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/common/exercises/simple-cipher/description.md +1 -1
  3. data/common/exercises/triangle/description.md +12 -23
  4. data/lib/trackler/version.rb +1 -1
  5. data/tracks/kotlin/config.json +5 -0
  6. data/tracks/kotlin/exercises/bank-account/build.gradle +32 -0
  7. data/tracks/kotlin/exercises/bank-account/src/example/kotlin/BankAccount.kt +27 -0
  8. data/tracks/kotlin/exercises/bank-account/src/main/kotlin/.keep +0 -0
  9. data/tracks/kotlin/exercises/bank-account/src/test/kotlin/BankAccountTest.kt +73 -0
  10. data/tracks/kotlin/exercises/settings.gradle +1 -0
  11. data/tracks/python/config.json +11 -11
  12. data/tracks/python/exercises/accumulate/accumulate_test.py +16 -14
  13. data/tracks/python/exercises/acronym/acronym_test.py +8 -7
  14. data/tracks/python/exercises/allergies/allergies_test.py +5 -6
  15. data/tracks/python/exercises/atbash-cipher/atbash_cipher_test.py +16 -22
  16. data/tracks/python/exercises/binary-search/binary_search_test.py +12 -10
  17. data/tracks/python/exercises/binary/binary_test.py +7 -8
  18. data/tracks/python/exercises/circular-buffer/circular_buffer_test.py +16 -17
  19. data/tracks/python/exercises/clock/clock_test.py +35 -35
  20. data/tracks/python/exercises/crypto-square/crypto_square_test.py +5 -6
  21. data/tracks/python/exercises/diamond/diamond_test.py +3 -4
  22. data/tracks/python/exercises/etl/etl_test.py +4 -4
  23. data/tracks/python/exercises/gigasecond/gigasecond_test.py +11 -19
  24. data/tracks/python/exercises/grade-school/grade_school_test.py +17 -19
  25. data/tracks/python/exercises/grains/grains_test.py +14 -14
  26. data/tracks/python/exercises/grep/grep_test.py +51 -64
  27. data/tracks/python/exercises/hamming/hamming_test.py +13 -13
  28. data/tracks/python/exercises/hello-world/hello_world_test.py +1 -2
  29. data/tracks/python/exercises/hexadecimal/hexadecimal_test.py +9 -10
  30. data/tracks/python/exercises/house/house_test.py +6 -6
  31. data/tracks/python/exercises/kindergarten-garden/kindergarten_garden_test.py +22 -19
  32. data/tracks/python/exercises/largest-series-product/largest_series_product_test.py +29 -28
  33. data/tracks/python/exercises/linked-list/linked_list_test.py +18 -19
  34. data/tracks/python/exercises/list-ops/list_ops_test.py +44 -39
  35. data/tracks/python/exercises/matrix/matrix_test.py +6 -6
  36. data/tracks/python/exercises/meetup/meetup_test.py +27 -27
  37. data/tracks/python/exercises/minesweeper/example.py +4 -2
  38. data/tracks/python/exercises/minesweeper/minesweeper_test.py +9 -9
  39. data/tracks/python/exercises/nucleotide-count/nucleotide_count_test.py +6 -6
  40. data/tracks/python/exercises/ocr-numbers/ocr_numbers_test.py +63 -49
  41. data/tracks/python/exercises/octal/octal_test.py +7 -7
  42. data/tracks/python/exercises/palindrome-products/palindrome_products_test.py +9 -9
  43. data/tracks/python/exercises/pascals-triangle/pascals_triangle_test.py +7 -7
  44. data/tracks/python/exercises/phone-number/phone_number_test.py +8 -8
  45. data/tracks/python/exercises/pig-latin/pig_latin_test.py +15 -15
  46. data/tracks/python/exercises/point-mutations/point_mutations_test.py +11 -11
  47. data/tracks/python/exercises/poker/poker_test.py +32 -30
  48. data/tracks/python/exercises/prime-factors/prime_factors_test.py +11 -11
  49. data/tracks/python/exercises/proverb/proverb_test.py +16 -9
  50. data/tracks/python/exercises/pythagorean-triplet/pythagorean_triplet_test.py +14 -12
  51. data/tracks/python/exercises/queen-attack/queen_attack_test.py +10 -10
  52. data/tracks/python/exercises/rail-fence-cipher/example.py +2 -1
  53. data/tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py +14 -13
  54. data/tracks/python/exercises/raindrops/raindrops_test.py +16 -16
  55. data/tracks/python/exercises/rectangles/rectangles_test.py +9 -9
  56. data/tracks/python/exercises/rna-transcription/rna_transcription_test.py +8 -8
  57. data/tracks/python/exercises/robot-name/robot_name_test.py +1 -1
  58. data/tracks/python/exercises/robot-simulator/robot_simulator_test.py +18 -19
  59. data/tracks/python/exercises/roman-numerals/roman_numerals_test.py +1 -1
  60. data/tracks/python/exercises/run-length-encoding/run_length_encoding_test.py +15 -16
  61. data/tracks/python/exercises/saddle-points/saddle_points_test.py +4 -4
  62. data/tracks/python/exercises/say/say_test.py +21 -23
  63. data/tracks/python/exercises/scrabble-score/scrabble_score_test.py +9 -9
  64. data/tracks/python/exercises/secret-handshake/secret_handshake_test.py +14 -13
  65. data/tracks/python/exercises/series/example.py +3 -3
  66. data/tracks/python/exercises/series/series_test.py +16 -12
  67. data/tracks/python/exercises/simple-cipher/simple_cipher_test.py +21 -19
  68. data/tracks/python/exercises/space-age/space_age_test.py +16 -16
  69. data/tracks/python/exercises/strain/strain_test.py +9 -8
  70. data/tracks/python/exercises/sublist/sublist_test.py +19 -20
  71. data/tracks/python/exercises/sum-of-multiples/example.py +1 -4
  72. data/tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py +31 -26
  73. data/tracks/python/exercises/triangle/triangle_test.py +15 -30
  74. data/tracks/python/exercises/trinary/trinary_test.py +7 -7
  75. data/tracks/python/exercises/twelve-days/twelve_days_test.py +13 -14
  76. data/tracks/python/exercises/word-count/example.py +1 -9
  77. data/tracks/python/exercises/word-count/word_count_test.py +0 -15
  78. data/tracks/python/exercises/wordy/wordy_test.py +17 -18
  79. data/tracks/python/exercises/zebra-puzzle/example.py +20 -23
  80. data/tracks/python/exercises/zebra-puzzle/zebra_puzzle_test.py +3 -3
  81. data/tracks/python/test/check-exercises.py +1 -1
  82. 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", number)
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", number)
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", number)
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", number)
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", number)
25
+ self.assertEqual(number, "0000000000")
26
26
 
27
27
  def test_area_code(self):
28
28
  number = Phone("1234567890")
29
- self.assertEqual("123", number.area_code())
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", number.pretty())
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", number.pretty())
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("appleay", translate("apple"))
8
+ self.assertEqual(translate("apple"), "appleay")
9
9
 
10
10
  def test_word_beginning_with_e(self):
11
- self.assertEqual("earay", translate("ear"))
11
+ self.assertEqual(translate("ear"), "earay")
12
12
 
13
13
  def test_word_beginning_with_p(self):
14
- self.assertEqual("igpay", translate("pig"))
14
+ self.assertEqual(translate("pig"), "igpay")
15
15
 
16
16
  def test_word_beginning_with_k(self):
17
- self.assertEqual("oalakay", translate("koala"))
17
+ self.assertEqual(translate("koala"), "oalakay")
18
18
 
19
19
  def test_word_beginning_with_ch(self):
20
- self.assertEqual("airchay", translate("chair"))
20
+ self.assertEqual(translate("chair"), "airchay")
21
21
 
22
22
  def test_word_beginning_with_qu(self):
23
- self.assertEqual("eenquay", translate("queen"))
23
+ self.assertEqual(translate("queen"), "eenquay")
24
24
 
25
25
  def test_word_beginning_with_squ(self):
26
- self.assertEqual("aresquay", translate("square"))
26
+ self.assertEqual(translate("square"), "aresquay")
27
27
 
28
28
  def test_word_beginning_with_th(self):
29
- self.assertEqual("erapythay", translate("therapy"))
29
+ self.assertEqual(translate("therapy"), "erapythay")
30
30
 
31
31
  def test_word_beginning_with_thr(self):
32
- self.assertEqual("ushthray", translate("thrush"))
32
+ self.assertEqual(translate("thrush"), "ushthray")
33
33
 
34
34
  def test_word_beginning_with_sch(self):
35
- self.assertEqual("oolschay", translate("school"))
35
+ self.assertEqual(translate("school"), "oolschay")
36
36
 
37
37
  def test_translates_phrase(self):
38
- self.assertEqual("ickquay astfay unray", translate("quick fast run"))
38
+ self.assertEqual(translate("quick fast run"), "ickquay astfay unray")
39
39
 
40
40
  def test_word_beginning_with_ye(self):
41
- self.assertEqual("ellowyay", translate("yellow"))
41
+ self.assertEqual(translate("yellow"), "ellowyay")
42
42
 
43
43
  def test_word_beginning_with_yt(self):
44
- self.assertEqual("yttriaay", translate("yttria"))
44
+ self.assertEqual(translate("yttria"), "yttriaay")
45
45
 
46
46
  def test_word_beginning_with_xe(self):
47
- self.assertEqual("enonxay", translate("xenon"))
47
+ self.assertEqual(translate("xenon"), "enonxay")
48
48
 
49
49
  def test_word_beginning_with_xr(self):
50
- self.assertEqual("xrayay", translate("xray"))
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(0, hamming_distance('', ''))
8
+ self.assertEqual(hamming_distance('', ''), 0)
9
9
 
10
10
  def test_no_difference_between_identical_strands(self):
11
- self.assertEqual(0, hamming_distance('GGACTGA', 'GGACTGA'))
11
+ self.assertEqual(hamming_distance('GGACTGA', 'GGACTGA'), 0)
12
12
 
13
13
  def test_complete_hamming_distance_in_small_strand(self):
14
- self.assertEqual(3, hamming_distance('ACT', 'GGA'))
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(19,
18
- hamming_distance('GGACGGATTCTGACCTGGACTAATTTTGGGG',
19
- 'AGGACGGATTCTGACCTGGACTAATTTTGGGG'))
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(1, hamming_distance('GGACG', 'GGTCG'))
22
+ self.assertEqual(hamming_distance('GGACG', 'GGTCG'), 1)
23
23
 
24
24
  def test_larger_distance(self):
25
- self.assertEqual(2, hamming_distance('ACCAGGG', 'ACTATGG'))
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(3, hamming_distance('AAACTAGGGG', 'AGGCTAGCGGTAGGAC'))
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(5, hamming_distance('GACTACGGACAGGGTAGGGAAT',
32
- 'GACATCGCACACC'))
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], poker([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([pairOf4], poker([nothing, pairOf4]))
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([pairOf4], poker([pairOf2, pairOf4]))
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([doublePair], poker([pairOf8, doublePair]))
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([doublePair2and8],
30
- poker([doublePair2and8, doublePair4and5]))
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([doublePair3and8],
36
- poker([doublePair2and8, doublePair3and8]))
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([doublePair2and8high],
42
- poker([doublePair2and8high, doublePair2and8]))
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([threeOf4], poker([doublePair2and8, threeOf4]))
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([threeOf1], poker([threeOf2, threeOf1]))
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([straight], poker([threeOf4, straight]))
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([straightTo9], poker([straightTo8, straightTo9]))
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([straightTo1], poker([straightTo1, straightTo5]))
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([flushTo7], poker([straightTo8, flushTo7]))
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([flushTo8], poker([flushTo8, flushTo7]))
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([full], poker([full, flushTo8]))
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([fullOf5by8], poker([fullOf4by9, fullOf5by8]))
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([squareOf3], poker([full, squareOf3]))
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([squareOf5], poker([squareOf2, squareOf5]))
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([straightFlushTo9],
101
- poker([squareOf5, straightFlushTo9]))
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([straightFlushTo9],
107
- poker([straightFlushTo8, straightFlushTo9]))
107
+ self.assertEqual(
108
+ poker([straightFlushTo8, straightFlushTo9]), [straightFlushTo9])
108
109
 
109
110
  def test_three_hand_with_tie(self):
110
- spadeStraightTo9 = "9S 8S 7S 6S 5S".split()
111
- diamondStraightTo9 = "9D 8D 7D 6D 5D".split()
112
- threeOf4 = "4D 4S 4H QS KS".split()
113
- self.assertEqual([spadeStraightTo9, diamondStraightTo9],
114
- poker([spadeStraightTo9, diamondStraightTo9, threeOf4]))
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([], prime_factors(1))
8
+ self.assertEqual(prime_factors(1), [])
9
9
 
10
10
  def test_2(self):
11
- self.assertEqual([2], prime_factors(2))
11
+ self.assertEqual(prime_factors(2), [2])
12
12
 
13
13
  def test_3(self):
14
- self.assertEqual([3], prime_factors(3))
14
+ self.assertEqual(prime_factors(3), [3])
15
15
 
16
16
  def test_4(self):
17
- self.assertEqual([2, 2], prime_factors(4))
17
+ self.assertEqual(prime_factors(4), [2, 2])
18
18
 
19
19
  def test_6(self):
20
- self.assertEqual([2, 3], prime_factors(6))
20
+ self.assertEqual(prime_factors(6), [2, 3])
21
21
 
22
22
  def test_8(self):
23
- self.assertEqual([2, 2, 2], prime_factors(8))
23
+ self.assertEqual(prime_factors(8), [2, 2, 2])
24
24
 
25
25
  def test_9(self):
26
- self.assertEqual([3, 3], prime_factors(9))
26
+ self.assertEqual(prime_factors(9), [3, 3])
27
27
 
28
28
  def test_27(self):
29
- self.assertEqual([3, 3, 3], prime_factors(27))
29
+ self.assertEqual(prime_factors(27), [3, 3, 3])
30
30
 
31
31
  def test_625(self):
32
- self.assertEqual([5, 5, 5, 5], prime_factors(625))
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], prime_factors(901255))
35
+ self.assertEqual(prime_factors(901255), [5, 17, 23, 461])
36
36
 
37
37
  def test_93819012551(self):
38
- self.assertEqual([11, 9539, 894119], prime_factors(93819012551))
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(expected, proverb(['nail', 'shoe']))
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(expected, proverb(['nail', 'shoe', 'horse']))
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(expected, proverb(['nail', 'shoe', 'horse', 'rider']))
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(expected, proverb(['key', 'value']))
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(expected, proverb(['nail', 'shoe', 'horse', 'rider',
39
- 'message', 'battle', 'kingdom']))
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(expected, proverb(['nail', 'shoe', 'horse', 'rider',
50
- 'message', 'battle', 'kingdom'],
51
- qualifier='horseshoe'))
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 (primitive_triplets, triplets_in_range,
39
- is_triplet)
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(ans, primitive_triplets(4))
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(ans, primitive_triplets(84))
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(ans, primitive_triplets(420))
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(ans, primitive_triplets(288))
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(ans, triplets_in_range(1, 10))
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(ans, triplets_in_range(56, 95))
71
+ self.assertEqual(triplets_in_range(56, 95), ans)
70
72
 
71
73
  def test_is_triplet1(self):
72
- self.assertEqual(True, is_triplet((29, 20, 21)))
74
+ self.assertTrue(is_triplet((29, 20, 21)))
73
75
 
74
76
  def test_is_triplet2(self):
75
- self.assertEqual(False, is_triplet((25, 25, 1225)))
77
+ self.assertFalse(is_triplet((25, 25, 1225)))
76
78
 
77
79
  def test_is_triplet3(self):
78
- self.assertEqual(True, is_triplet((924, 43, 925)))
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)