Updated README

This commit is contained in:
Anup Kumar Panwar
2019-07-06 11:11:20 +05:30
parent 831558d38d
commit 4e413c0183
45 changed files with 404 additions and 702 deletions

View File

@@ -1,29 +0,0 @@
"""Tower of Hanoi."""
# @author willx75
# Tower of Hanoi recursion game algorithm is a game, it consists of three rods
# and a number of disks of different sizes, which can slide onto any rod
import logging
log = logging.getLogger()
logging.basicConfig(level=logging.DEBUG)
def Tower_Of_Hanoi(n, source, dest, by, movement):
"""Tower of Hanoi - Move plates to different rods."""
if n == 0:
return n
elif n == 1:
movement += 1
# no print statement
# (you could make it an optional flag for printing logs)
logging.debug('Move the plate from', source, 'to', dest)
return movement
else:
movement = movement + Tower_Of_Hanoi(n - 1, source, by, dest, 0)
logging.debug('Move the plate from', source, 'to', dest)
movement = movement + 1 + Tower_Of_Hanoi(n - 1, by, dest, source, 0)
return movement

View File

@@ -1 +0,0 @@
from .. import fibonacci

View File

@@ -1,34 +0,0 @@
"""
To run with slash:
1. run pip install slash (may need to install C++ builds from Visual Studio website)
2. In the command prompt navigate to your project folder
3. then type--> slash run -vv -k tags:fibonacci ..
-vv indicates the level of verbosity (how much stuff you want the test to spit out after running)
-k is a way to select the tests you want to run. This becomes much more important in large scale projects.
"""
import slash
from .. import fibonacci
default_fib = [0, 1, 1, 2, 3, 5, 8]
@slash.tag('fibonacci')
@slash.parametrize(('n', 'seq'), [(2, [0, 1]), (3, [0, 1, 1]), (9, [0, 1, 1, 2, 3, 5, 8, 13, 21])])
def test_different_sequence_lengths(n, seq):
"""Test output of varying fibonacci sequence lengths"""
iterative = fibonacci.fib_iterative(n)
formula = fibonacci.fib_formula(n)
assert iterative == seq
assert formula == seq
@slash.tag('fibonacci')
@slash.parametrize('n', [7.3, 7.8, 7.0])
def test_float_input_iterative(n):
"""Test when user enters a float value"""
iterative = fibonacci.fib_iterative(n)
formula = fibonacci.fib_formula(n)
assert iterative == default_fib
assert formula == default_fib