chore: changed name of directory, so change the filepath in README
This commit is contained in:
1 parent
621fc4a731
commit
c577565301
17 files changed
+1
-1
No files matched your search
@@ -0,0 +1,17 @@
|
||||
from src.codewars.kata_building_blocks import Block
|
||||
|
||||
|
||||
def test_block():
|
||||
b1 = Block([2, 2, 2])
|
||||
b2 = Block([41, 87, 67])
|
||||
|
||||
assert b1.get_width() == 2
|
||||
assert b1.get_length() == 2
|
||||
assert b1.get_height() == 2
|
||||
assert b1.get_volume() == 8
|
||||
assert b1.get_surface_area() == 24
|
||||
assert b2.get_width() == 41
|
||||
assert b2.get_length() == 87
|
||||
assert b2.get_height() == 67
|
||||
assert b2.get_volume() == 238989
|
||||
assert b2.get_surface_area() == 24286
|
||||
@@ -0,0 +1,8 @@
|
||||
from src.codewars.kata_ceasar_cipher_helper import CaesarCipher
|
||||
|
||||
|
||||
def test_cipher_helper():
|
||||
c = CaesarCipher(5)
|
||||
|
||||
assert c.encode("Codewars") == "HTIJBFWX"
|
||||
assert c.decode("HTIJBFWX") == "CODEWARS"
|
||||
@@ -0,0 +1,15 @@
|
||||
from src.codewars.kata_chinese_numeral_encoder import to_chinese_numeral
|
||||
|
||||
|
||||
def test_to_chinese():
|
||||
assert to_chinese_numeral(9) == "九"
|
||||
assert to_chinese_numeral(-5) == "负五"
|
||||
assert to_chinese_numeral(0.5) == "零点五"
|
||||
assert to_chinese_numeral(10) == "十"
|
||||
assert to_chinese_numeral(110) == "一百一十"
|
||||
assert to_chinese_numeral(111) == "一百一十一"
|
||||
assert to_chinese_numeral(1000) == "一千"
|
||||
assert to_chinese_numeral(10000) == "一万"
|
||||
assert to_chinese_numeral(10006) == "一万零六"
|
||||
assert to_chinese_numeral(10306.005) == "一万零三百零六点零零五"
|
||||
assert to_chinese_numeral(-10.000001) == "负十点零零零零零一"
|
||||
@@ -0,0 +1,7 @@
|
||||
from src.codewars.kata_force_of_gravity import solution
|
||||
|
||||
|
||||
def test_a():
|
||||
assert solution([1000, 1000, 100], ["g", "kg", "m"]) == 6.67e-12
|
||||
assert solution([1000, 1000, 100], ["kg", "kg", "m"]) == 6.6699999999999995e-09
|
||||
assert solution([1000, 1000, 100], ["kg", "kg", "cm"]) == 0.0000667
|
||||
@@ -0,0 +1,5 @@
|
||||
from src.codewars.kata_most_words_used import top_3_words
|
||||
|
||||
|
||||
def test_top_3_words():
|
||||
assert top_3_words() == 0
|
||||
@@ -0,0 +1,15 @@
|
||||
from src.codewars.kata_next_bigger_number_same_digits import next_bigger
|
||||
|
||||
|
||||
def test_next_bigger():
|
||||
assert next_bigger(12) == 21
|
||||
assert next_bigger(21) == -1
|
||||
assert next_bigger(513) == 531
|
||||
assert next_bigger(2017) == 2071
|
||||
assert next_bigger(414) == 441
|
||||
assert next_bigger(144) == 414
|
||||
assert next_bigger(1234567890) == 1234567908
|
||||
assert next_bigger(59884848459853) == 59884848483559
|
||||
assert next_bigger(7600201336) == 7600201363
|
||||
assert next_bigger(5113455566888) == 5113455568688
|
||||
assert next_bigger(4769560370633) == 4769560373036
|
||||
@@ -0,0 +1,15 @@
|
||||
from src.codewars.kata_object_oriented_piracy import Ship
|
||||
|
||||
|
||||
def test_piracy():
|
||||
empty_ship = Ship(0, 0)
|
||||
assert not empty_ship.is_worth_it()
|
||||
|
||||
boat = Ship(15, 20)
|
||||
assert not boat.is_worth_it()
|
||||
|
||||
worthy_ship = Ship(100, 20)
|
||||
assert worthy_ship.is_worth_it()
|
||||
|
||||
big_boat = Ship(35, 20)
|
||||
assert not big_boat.is_worth_it()
|
||||
@@ -0,0 +1,27 @@
|
||||
from src.codewars.kata_pagination_helper import PaginationHelper
|
||||
|
||||
|
||||
def test_pagination():
|
||||
collection = ["a", "b", "c", "d", "e", "f"]
|
||||
helper = PaginationHelper(collection, 4)
|
||||
|
||||
assert helper.page_count() == 2
|
||||
assert helper.item_count() == 6
|
||||
assert helper.page_item_count(0) == 4
|
||||
assert helper.page_item_count(1) == 2
|
||||
assert helper.page_item_count(2) == -1
|
||||
assert helper.page_index(5) == 1
|
||||
assert helper.page_index(2) == 0
|
||||
assert helper.page_index(20) == -1
|
||||
assert helper.page_index(-10) == -1
|
||||
|
||||
empty = PaginationHelper([], 10)
|
||||
|
||||
assert empty.item_count() == 0
|
||||
assert empty.page_count() == 0
|
||||
assert empty.page_index(0) == -1
|
||||
assert empty.page_index(1) == -1
|
||||
assert empty.page_index(-1) == -1
|
||||
assert empty.page_item_count(0) == -1
|
||||
assert empty.page_item_count(1) == -1
|
||||
assert empty.page_item_count(-1) == -1
|
||||
@@ -0,0 +1,16 @@
|
||||
from src.codewars.kata_rgb_2_hex import rgb
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("r", "g", "b", "expected"),
|
||||
[
|
||||
(0, 0, 0, "000000"),
|
||||
(1, 2, 3, "010203"),
|
||||
(255, 255, 255, "FFFFFF"),
|
||||
(254, 253, 252, "FEFDFC"),
|
||||
(-20, 275, 125, "00FF7D"),
|
||||
],
|
||||
)
|
||||
def test_rgb_2_hex(r, g, b, expected):
|
||||
assert rgb(r, g, b) == expected
|
||||
@@ -0,0 +1,10 @@
|
||||
from src.codewars.kata_snail import snail
|
||||
|
||||
|
||||
def test_snail():
|
||||
array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
||||
|
||||
assert snail(array) == [1, 2, 3, 6, 9, 8, 7, 4, 5]
|
||||
|
||||
array = [[1, 2, 3], [8, 9, 4], [7, 6, 5]]
|
||||
assert snail(array) == [1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||
@@ -0,0 +1,13 @@
|
||||
from src.codewars.kata_the_lamp import Lamp
|
||||
|
||||
|
||||
def test_lamp():
|
||||
my_lamp = Lamp("Blue")
|
||||
|
||||
assert my_lamp.color == "Blue"
|
||||
assert not my_lamp.on
|
||||
assert my_lamp.state() == "The lamp is off."
|
||||
my_lamp.toggle_switch()
|
||||
assert my_lamp.state() == "The lamp is on."
|
||||
my_lamp.toggle_switch()
|
||||
assert my_lamp.state() == "The lamp is off."
|
||||
@@ -0,0 +1,15 @@
|
||||
from src.codewars.kata_thinkful_quarks import Quark
|
||||
|
||||
|
||||
def test_quark():
|
||||
q1 = Quark("red", "up")
|
||||
q2 = Quark("blue", "strange")
|
||||
|
||||
assert q1.color == "red"
|
||||
assert q2.flavor == "strange"
|
||||
assert q2.baryon_number == 1 / 3
|
||||
|
||||
q1.interact(q2)
|
||||
|
||||
assert q1.color == "blue"
|
||||
assert q2.color == "red"
|
||||
@@ -0,0 +1,13 @@
|
||||
from src.codewars.kata_thinkful_vectors import Vector
|
||||
|
||||
|
||||
def test_vector():
|
||||
v1 = Vector(3, 4)
|
||||
v2 = Vector(1, 2)
|
||||
|
||||
assert v1.x == 3
|
||||
assert v2.y == 2
|
||||
assert hasattr(v1, "add")
|
||||
assert isinstance(v1.add(v2), Vector)
|
||||
assert (v1.add(v2)).x == 4
|
||||
assert (v1.add(v2)).y == 6
|
||||
@@ -0,0 +1,7 @@
|
||||
from src.codewars.kata_version_mamanger import VersionManager
|
||||
|
||||
|
||||
def test_lamp():
|
||||
v = VersionManager("1.1.1")
|
||||
|
||||
assert v.release() == "1.1.1"
|
||||
@@ -0,0 +1,16 @@
|
||||
from src.codewars.kata_vigenere_cipher_helper import VigenereCipher
|
||||
|
||||
|
||||
def test_cipher_helper():
|
||||
abc = "abcdefghijklmnopqrstuvwxyz"
|
||||
key = "password"
|
||||
c = VigenereCipher(key, abc)
|
||||
|
||||
assert c.encode("codewars") == "rovwsoiv"
|
||||
assert c.decode("rovwsoiv") == "codewars"
|
||||
|
||||
assert c.encode("waffles") == "laxxhsj"
|
||||
assert c.decode("laxxhsj") == "waffles"
|
||||
|
||||
assert c.encode("CODEWARS") == "CODEWARS"
|
||||
assert c.decode("CODEWARS") == "CODEWARS"
|
||||
@@ -0,0 +1,15 @@
|
||||
from src.codewars.kata_who_the_most_money import Student, most_money
|
||||
|
||||
|
||||
def test_most_money():
|
||||
phil = Student("Phil", 2, 2, 1)
|
||||
cam = Student("Cameron", 2, 2, 0)
|
||||
geoff = Student("Geoff", 0, 3, 0)
|
||||
|
||||
assert most_money([cam, geoff, phil]) == "Phil"
|
||||
|
||||
phil = Student("Phil", 2, 2, 2)
|
||||
cam = Student("Cameron", 2, 2, 2)
|
||||
geoff = Student("Geoff", 2, 2, 2)
|
||||
|
||||
assert most_money([cam, geoff, phil]) == "all"
|
||||
Reference in new issue
Block a user