Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
7d7fab7
1st kata in 8kyu, 2nd kata in 7kyu done. README updated. setup.py upd…
Dec 10, 2016
1504935
updated README
Dec 10, 2016
ea03f20
fix minor syntax error in README
Dec 10, 2016
2a9db44
fix minor syntax error in README
Dec 10, 2016
f4f99b8
fix minor syntax error in README
Dec 10, 2016
6618148
Update README.md
serashioda Dec 10, 2016
a42038e
Update README.md
serashioda Dec 10, 2016
6615143
Update README.md
serashioda Dec 10, 2016
db280bf
7kyu remove_min.py done, 6kyu find_odd_int.py done
Dec 10, 2016
1d7f89a
updated README
Dec 10, 2016
cb8e2b9
merged
Dec 10, 2016
2fec90f
finished 7th kyu test_calculate_years, updated README
Dec 10, 2016
3ead564
finished 7kyu xo.py. Updated README
Dec 10, 2016
371dcf5
done with count_bits, shortest-word, test_xo, is_isogram
Dec 10, 2016
20fa163
README
Dec 10, 2016
5415a12
update test and README
Dec 10, 2016
7b75e2e
added modules to setup.py. Fixed README syntax for example. fixed syt…
Dec 11, 2016
b0a7bbf
restructured directory structure
Dec 11, 2016
e6e09ee
moved test directory into new src directory
Dec 11, 2016
97d3e41
fixed TABLE errors in tests
Dec 11, 2016
3222e60
final reformatting to README
serashioda Dec 11, 2016
938cac0
Final, final format changes to README
serashioda Dec 11, 2016
dd852d9
fixed docstring errors
Dec 12, 2016
aac934e
fixed docstring errors
Dec 12, 2016
f971f9a
fixed docstring errors
Dec 12, 2016
9801a07
completed tests for parenthetics.py
Dec 19, 2016
bfdd5ca
wrote paranthetics using previous Stack functions. Tests written and …
Dec 19, 2016
0ac9159
Update README.md
serashioda Dec 19, 2016
afd2560
Update
serashioda Dec 19, 2016
e4b3bfe
Update
serashioda Dec 19, 2016
db28faa
updated tests for 100% coverage.
Dec 19, 2016
c194248
updated tests for 100% coverage.
Dec 19, 2016
c4823a4
tests passing.
Jan 2, 2017
e021558
update .gitignore
Jan 18, 2017
e2e5773
gitc
Jan 18, 2017
fc1a370
AutoCompleter class and methods, __init__ and complete done. Tests ad…
Jan 18, 2017
87b97fc
initial setup for forbes kata
Feb 21, 2017
c08e0f5
def watch_pyramid_from_the_side done.
Feb 22, 2017
579735e
def watch_pyramid_from_above done. starting tests.
Feb 22, 2017
d46d4b0
last two methods done and passing on codewars. Starting tests.
Feb 22, 2017
6c9f47e
tests for empty string, None, and two charac cases added. passing.
Feb 22, 2017
40414b5
more tests added for 3 charac cases. all passing.
Feb 22, 2017
0417237
Update README.md
serashioda Feb 22, 2017
c0be1a6
Update
serashioda Feb 22, 2017
d4cb73f
Update README.md
serashioda Feb 22, 2017
1e88000
added decender order test. passing.
Feb 22, 2017
11e2aa7
Merge branch 'string-pyramid' of https://github.com/serashioda/code-k…
Feb 22, 2017
603e333
find oldest billionaire under 80 years old and youngest billionaire …
Feb 22, 2017
082b2a2
added function to call both oldest under 80 and youngest valid.
Feb 22, 2017
990e347
updated forbes.py to work with test file. Tests written. All passing.
Feb 23, 2017
fc252bf
Update README.md
serashioda Feb 23, 2017
292d88c
Update
serashioda Feb 23, 2017
83ee726
Update
serashioda Feb 23, 2017
13298b6
take out unnecessary code.
Feb 23, 2017
b00690e
Merge branch 'forbes' of https://github.com/serashioda/code-katas int…
Feb 23, 2017
085c6c9
initial setup.
Feb 23, 2017
fd3044a
basic framework setup for flight_path. Also imported shortest_path to…
Feb 23, 2017
5bbdcde
tests done. all passing. took out print statements and pdb's
Feb 23, 2017
6b8332a
brought in shortest_path, stack, and linked_list from data structures.
Feb 23, 2017
ef0d2bf
Update README.md
serashioda Feb 23, 2017
0b6fb1a
Update
serashioda Feb 23, 2017
e06b42d
remove env variables
Feb 24, 2017
7f5ad55
remove env variables
Feb 24, 2017
b14ae72
removed extra sort_cards file
Feb 24, 2017
a58900a
removed extra sort_cards file
Feb 24, 2017
f3b9ade
corpse code and print statements.
Feb 24, 2017
4b71d4a
Merge branch 'flight-paths' of https://github.com/serashioda/code-kat…
Feb 24, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ var/
*.egg-info/
.installed.cfg
*.egg
bin/
lib/
include/
.DS_Store
pyvenv.cfg

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down Expand Up @@ -87,3 +92,5 @@ ENV/

# Rope project settings
.ropeproject

bin/
180 changes: 179 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,179 @@
# code-katas
Repo containing my solutions from Code Katas.

###8kyu

####Multiply:
- MODULE: multiply.py
- TESTS: test_multiply.py
- LINKS:
[Multiply - Kata](https://www.codewars.com/kata/multiply/train/python);
[Solutions](https://www.codewars.com/kata/50654ddff44f800200000004/solutions/python/me/best_practice)
- Interesting solution by jihygk:
```
multiply = __import__('operator').mul
```

###7kyu


####Decending Order:
- MODULE: decending_order.py
- TESTS: test_decending_order.py
- LINKS:
[Decending Order - Kata](https://www.codewars.com/kata/descending-order/train/python);
[Solutions](https://www.codewars.com/kata/5467e4d82edf8bbf40000155/solutions/python/me/best_practice)
- Interesting solution by Edwin.01:
```
def Descending_Order(num):
return int(''.join(str(x) for x in sorted(str(num))[::-1]))
```


####Remove the Minimum:
- MODULE: remove_min.py
- TESTS: test_remove.min.py
- LINKS:
[Remove the Minimum - Kata](https://www.codewars.com/kata/remove-the-minimum/train/python);
[Solutions](https://www.codewars.com/kata/563cf89eb4747c5fb100001b/solutions/python/me/best_practice)
- 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
```


####Money, Money, Money:
- MODULE: calculate_years.py
- TESTS: test_calculate_years.py
- LINKS:
[Money, Money, Money - Kata](https://www.codewars.com/kata/money-money-money/train/python);
[Solutions](https://www.codewars.com/kata/563f037412e5ada593000114/solutions/python/me/best_practice)
- 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)))
```


####Isograms:
- MODULE: is_isogram.py
- TESTS: test_is_isogram.py
- LINKS:
[Isograms - Kata](https://www.codewars.com/kata/isograms/train/python);
[Solutions](https://www.codewars.com/kata/54ba84be607a92aa900000f1/solutions/python/me/best_practice)
- 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()))
```


####Exes and Ohs:
- MODULE: xo.py
- TESTS: test_xo.py
- LINKS:
[Exes and Ohs - Kata](https://www.codewars.com/kata/exes-and-ohs/train/python);
[Solutions](https://www.codewars.com/kata/55908aad6620c066bc00002a/solutions/python/me/best_practice)
- 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')
```


####Shortest Word:
- MODULE: shortest_word.py
- TESTS: test_shortest_word.py
- LINKS:
[Shortest Word - Kata](https://www.codewars.com/kata/shortest-word/train/python);
[Solutions](https://www.codewars.com/kata/57cebe1dc6fdc20c57000ac9/solutions/python/me/best_practice)
- 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())
```


###6kyu


####Find the Odd Int:
- MODULE: find_odd_int.py
- TESTS: test_find_odd_int.py
- LINKS:
[Find the Odd Int - Kata](https://www.codewars.com/kata/find-the-odd-int/train/python);
[Solutions](https://www.codewars.com/kata/54da5a58ea159efa38000836/solutions/python/me/best_practice)
- Interesting solution by Unnamed:
```
import operator

def find_it(xs):
return reduce(operator.xor, xs)
```


####Bit Counting:
- MODULE: count_bits.py
- TESTS: test_count_bits.py
- LINKS: [Bit Counting - Kata](https://www.codewars.com/kata/bit-counting/train/python),
[Solutions](https://www.codewars.com/kata/526571aae218b8ee490006f4/solutions/python/me/best_practice)
- Interesting solution by NTERESTING, xcthulhu, hiasen, RM84, mpeddle, nickie, npd (plus 361 more warriors):
```
def countBits(n):
return bin(n).count("1")
```

####String Pyramid:
- MODULE: string_pyramid.py
- TESTS: test_string_pyramid.py
- LINKS: [String Pyramid - Kata](http://www.codewars.com/kata/string-pyramid/train/python),
[Solutions](http://www.codewars.com/kata/5797d1a9c38ec2de1f00017b/solutions/python/all/clever)
- 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
```


###Other


####Interview Challenge: Proper Parenthetics
- Module: proper-parenthetics.py
- TESTS: test_proper-parenthetics.py
- LINKS: [ASSIGNMENT LINK](https://codefellows.github.io/sea-python-401d5/assignments/proper_parenthetics.html?highlight=proper%20paren)
- DERIVED FROM: [data-structures repo. Specifically stack branch](https://github.com/ellezv/data_structures/tree/stack), collaborated with Maelle Vance.

####Python Practice: The Forbes Top 40
- Module: forbes.py
- JSON data: forbes.json
- TESTS: test_forbes.py
- LINKS: [ASSIGNMENT LINK](https://codefellows.github.io/sea-python-401d5/assignments/kata_forbes_billionaires.html)

####Python Practice: Distance Between Points
- 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)](http://stackoverflow.com/questions/4913349/haversine-formula-in-python-bearing-and-distance-between-two-gps-points)
- LINKS: [ASSIGNMENT LINK](https://codefellows.github.io/sea-python-401d5/assignments/kata_flight_paths.html)
18 changes: 18 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""The setup for katas modules."""

from setuptools import setup

setup(
name="code katas",
description="A Python implementation of Code War katas",
version=0.1,
author="Sera Smith",
author_email="seras37@gmail.com",
license='MIT',
py_modules=['calculate_years', 'count_bits', 'decending_order', 'find_odd_int', 'is_isogram', 'multiply', 'remove_min', 'shortest_word', 'xo'],
package_dir={'': 'src'},
install_requires=['numpy', 'tox'],
extras_require={
"test": ["pytest", "pytest-watch", "pytest-cov", 'tox']
},
)
21 changes: 21 additions & 0 deletions src/autocomplete.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""Implementation of the autocomplete module."""


class AutoCompleter():
"""Auto completer class."""

def __init__(self, vocabulary, max_completions=4):
"""Instantiate with vocabulary and max_compete params."""
self.vocabulary = vocabulary
self.max_completions = max_completions

def complete(self, term):
"""Match terms to max of 4 words, then append and return."""
suggested_words = []
n = len(term)
for word in self.vocabulary:
if word[:n] == term:
suggested_words.append(word)
if len(suggested_words) >= self.max_completions:
return suggested_words
return suggested_words
13 changes: 13 additions & 0 deletions src/calculate_years.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Implementation of the Kata Money, Money, Money."""


def calculate_years(principal, interest, tax, desired):
"""Calculate how many years it take to reach desired principle."""
years = 0
while (principal < desired):
accrued = principal * interest
accrued = accrued - (accrued * tax)
principal += accrued
years += 1

return years
7 changes: 7 additions & 0 deletions src/count_bits.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""Implemntation of the Bit Counting Kata."""


def count_bits(n):
"""Convert a number to binary and counts the number of 1 bits."""
val = bin(n)
return val.count("1")
10 changes: 10 additions & 0 deletions src/decending_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""Implementation of the Kata Descending_Order."""


def decending_order(num):
"""Take a non-neg integer and returns its digits in decending order."""
num_array = list(str(num))
reverse_array = sorted(num_array, reverse=True)
reverse_string = ''.join(reverse_array)
reverse_num = int(reverse_string)
return reverse_num
8 changes: 8 additions & 0 deletions src/find_odd_int.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""Implementation of the Kata Find the Odd Int."""


def find_it(seq):
"""Return only number appearing odd number of times."""
for num in seq:
if seq.count(num) % 2 != 0:
return num
Loading