Compare commits
4 Commits
e521f037a4
...
d010de0fe5
| Author | SHA1 | Date | |
|---|---|---|---|
| d010de0fe5 | |||
| c00cbd030b | |||
| a681ae4f2b | |||
| 90ba3e1e60 |
@ -17,7 +17,7 @@ Repository for CDS-2020 Programming and Promt Engineering II
|
|||||||
# Codewars
|
# Codewars
|
||||||
|Title|Source (src/codewars/)|Test (test/codewars/)|URL|
|
|Title|Source (src/codewars/)|Test (test/codewars/)|URL|
|
||||||
|-|-|-|-|
|
|-|-|-|-|
|
||||||
|Find the force of gravity between two objects|kata_force_of_gravity.py|test_force_of_gravity.py|[5b609ebc8f47bd595e000627](https://www.codewars.com/kata/5b609ebc8f47bd595e000627/)|
|
|Find the force of gravity between two objects|kata_force_of_gravity.py|test_force_of_gravity.py|[5b609ebc8f47bd595e000627](https://www.codewars.com/kata/5b609ebc8f47bd595e000627)|
|
||||||
|The Lamp: Revisited|kata_the_lamp.py|test_the_lamp.py|[570e6e32de4dc8a8340016dd](https://www.codewars.com/kata/570e6e32de4dc8a8340016dd)|
|
|The Lamp: Revisited|kata_the_lamp.py|test_the_lamp.py|[570e6e32de4dc8a8340016dd](https://www.codewars.com/kata/570e6e32de4dc8a8340016dd)|
|
||||||
|OOP: Object Oriented Piracy|kata_object_oriented_piracy.py|test_object_oriented_piracy.py|[54fe05c4762e2e3047000add](https://www.codewars.com/kata/54fe05c4762e2e3047000add)|
|
|OOP: Object Oriented Piracy|kata_object_oriented_piracy.py|test_object_oriented_piracy.py|[54fe05c4762e2e3047000add](https://www.codewars.com/kata/54fe05c4762e2e3047000add)|
|
||||||
|Vigenère Cipher Helper|kata_vigenere_cipher_helper.py|test_vigenere_cipher_helper.py|[52d1bd3694d26f8d6e0000d3](https://www.codewars.com/kata/52d1bd3694d26f8d6e0000d3)|
|
|Vigenère Cipher Helper|kata_vigenere_cipher_helper.py|test_vigenere_cipher_helper.py|[52d1bd3694d26f8d6e0000d3](https://www.codewars.com/kata/52d1bd3694d26f8d6e0000d3)|
|
||||||
@ -27,3 +27,4 @@ Repository for CDS-2020 Programming and Promt Engineering II
|
|||||||
|Thinkful - Object Drills: Vectors|kata_thinkful_vectors.py|test_thinkful_vectors.py|[587f1e1f39d444cee6000ad4](https://www.codewars.com/kata/587f1e1f39d444cee6000ad4)|
|
|Thinkful - Object Drills: Vectors|kata_thinkful_vectors.py|test_thinkful_vectors.py|[587f1e1f39d444cee6000ad4](https://www.codewars.com/kata/587f1e1f39d444cee6000ad4)|
|
||||||
|Building blocks|kata_building_blocks.py|test_building_blocks.py|[55b75fcf67e558d3750000a3](https://www.codewars.com/kata/55b75fcf67e558d3750000a3)|
|
|Building blocks|kata_building_blocks.py|test_building_blocks.py|[55b75fcf67e558d3750000a3](https://www.codewars.com/kata/55b75fcf67e558d3750000a3)|
|
||||||
|PaginationHelper|kata_pagination_helper.py|test_pagination_helper.py|[515bb423de843ea99400000a](https://www.codewars.com/kata/515bb423de843ea99400000a)|
|
|PaginationHelper|kata_pagination_helper.py|test_pagination_helper.py|[515bb423de843ea99400000a](https://www.codewars.com/kata/515bb423de843ea99400000a)|
|
||||||
|
|Who has the most money?|kata_who_the_most_money.py|test_who_the_most_money.py|[528d36d7cc451cd7e4000339](https://www.codewars.com/kata/528d36d7cc451cd7e4000339)|
|
||||||
|
|||||||
15
src/codewars/kata_who_the_most_money.py
Normal file
15
src/codewars/kata_who_the_most_money.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
class Student:
|
||||||
|
def __init__(self, name, fives, tens, twenties):
|
||||||
|
self.name = name
|
||||||
|
self.fives = fives
|
||||||
|
self.tens = tens
|
||||||
|
self.twenties = twenties
|
||||||
|
|
||||||
|
|
||||||
|
def most_money(students):
|
||||||
|
student_names = [x.name for x in students]
|
||||||
|
student_money = [x.fives * 5 + x.tens * 10 + x.twenties * 20 for x in students]
|
||||||
|
|
||||||
|
if len(set(student_money)) == 1 and len(student_money) > 1:
|
||||||
|
return "all"
|
||||||
|
return max(list(zip(student_names, student_money)), key=lambda x: x[1])[0]
|
||||||
15
tests/codewars/test_who_the_most_money.py
Normal file
15
tests/codewars/test_who_the_most_money.py
Normal file
@ -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"
|
||||||
Loading…
x
Reference in New Issue
Block a user