Repo containing my solutions from Code Katas.
- MODULE: multiply.py
- TESTS: test_multiply.py
- LINKS: Multiply - Kata; Solutions
- Interesting solution by jihygk:
multiply = __import__('operator').mul
- MODULE: decending_order.py
- TESTS: test_decending_order.py
- LINKS: Decending Order - Kata; Solutions
- Interesting solution by Edwin.01:
def Descending_Order(num):
return int(''.join(str(x) for x in sorted(str(num))[::-1]))
- MODULE: remove_min.py
- TESTS: test_remove.min.py
- LINKS: Remove the Minimum - Kata; Solutions
- Interesting solution by Streetmentioner, Emigre, syim, JustyFY, MMMAAANNN, doublenns (plus 94 more warriors):
def remove_smallest(numbers):
if numbers:
numbers.remove(min(numbers))
return numbers
- MODULE: calculate_years.py
- TESTS: test_calculate_years.py
- LINKS: Money, Money, Money - Kata; Solutions
- Interesting solution by CrazyMerlyn:
from math import ceil, log
def calculate_years(principal, interest, tax, desired):
if principal >= desired: return 0
return ceil(log(float(desired) / principal, 1 + interest * (1 - tax)))
- MODULE: is_isogram.py
- TESTS: test_is_isogram.py
- LINKS: Isograms - Kata; Solutions
- Interesting solution by madbook, Kamyk, hiasen, dia_c, staticor, lancelote (plus 76 more warriors):
def is_isogram(string):
return len(string) == len(set(string.lower()))
- MODULE: xo.py
- TESTS: test_xo.py
- LINKS: Exes and Ohs - Kata; Solutions
- Interesting solution by jolaf, Beast, Tgc, MMMAAANNN, SquishyStrawberry, Devilart (plus 126 more warriors):
def xo(s):
s = s.lower()
return s.count('x') == s.count('o')
- MODULE: shortest_word.py
- TESTS: test_shortest_word.py
- LINKS: Shortest Word - Kata; Solutions
- Interesting solution by MiraliN, Cptnprice, FranzSchubert92, Chris_Rands, Mr.Child, gallione11 (plus 12 more warriors):
def find_short(s):
return min(len(x) for x in s.split())
- MODULE: sum_terms.py
- TESTS: test_sum_terms.py
- LINKS: Sum of the First nth Term of Series - Kata; Solutions
- Interesting solution by MMMAAANNN, doctornick5, Slx64:
def series_sum(n):
return '{:.2f}'.format(sum(1.0/(3 * i + 1) for i in range(n)))
- MODULE: find_odd_int.py
- TESTS: test_find_odd_int.py
- LINKS: Find the Odd Int - Kata; Solutions
- Interesting solution by Unnamed:
import operator
def find_it(xs):
return reduce(operator.xor, xs)
- MODULE: count_bits.py
- TESTS: test_count_bits.py
- LINKS: Bit Counting - Kata, Solutions
- Interesting solution by NTERESTING, xcthulhu, hiasen, RM84, mpeddle, nickie, npd (plus 361 more warriors):
def countBits(n):
return bin(n).count("1")
- MODULE: string_pyramid.py
- TESTS: test_string_pyramid.py
- LINKS: String Pyramid - Kata, Solutions
- Interesting solution by lechevalier:
def watch_pyramid_from_the_side(c, i=1, acc=[]):
if c == None: return c
if not c: return '\n'.join(acc)
return watch_pyramid_from_the_side(c[:-1], i+2, [' '+l+' 'for l in acc]+[c[-1]*i])
def watch_pyramid_from_above(c, i=1, acc=[]):
if c == None: return c
if not c: return '\n'.join(acc)
return watch_pyramid_from_above(c[:-1], i+2, [c[-1] * i] + [c[-1]+l+c[-1] for l in acc] + [c[-1] * i] * bool(acc))
def count_visible_characters_of_the_pyramid(c):
return c and (2*len(c)-1)**2 or -1
def count_all_characters_of_the_pyramid(c):
return c and (4*len(c)**3-len(c))//3 or -1
- Module: human_readable.py
- TESTS: test_human_readable.py
- LINKS: Human Readable Time - Kata
- Module: proper-parenthetics.py
- TESTS: test_proper-parenthetics.py
- LINKS: ASSIGNMENT LINK
- DERIVED FROM: data-structures repo. Specifically stack branch, collaborated with Maelle Vance.
- Module: forbes.py
- JSON data: forbes.json
- TESTS: test_forbes.py
- LINKS: ASSIGNMENT LINK
- Module: flight_paths.py
- Reference module: shortest_path_stack_linked_lst.py
- JSON data: flight_paths.json
- TESTS: test_flight_paths.py
- CREDIT: Haversine Formula derived from Stack Overflow- Haversine Formula in Python (Bearing and Distance between two GPS points)
- LINKS: ASSIGNMENT LINK