def test_arrangement(self):
        actual = arithmetic_arranger(["3 + 855", "3801 - 2", "45 + 43", "123 + 49"])
        expected = "    3      3801      45      123\n+ 855    -    2    + 43    +  49\n-----    ------    ----    -----"
        self.assertEqual(actual, expected, 'Expected different output when calling "arithmetic_arranger()" with ["3 + 855", "3801 - 2", "45 + 43", "123 + 49"]')

        actual = arithmetic_arranger(["11 + 4", "3801 - 2999", "1 + 2", "123 + 49", "1 - 9380"])
        expected = "  11      3801      1      123         1\n+  4    - 2999    + 2    +  49    - 9380\n----    ------    ---    -----    ------"
        self.assertEqual(actual, expected, 'Expected different output when calling "arithmetic_arranger()" with ["11 + 4", "3801 - 2999", "1 + 2", "123 + 49", "1 - 9380"]')
Beispiel #2
0
 def test_incorrect_operator(self):
     actual = arithmetic_arranger(
         ["3 / 855", "3801 - 2", "45 + 43", "123 + 49"])
     expected = "Error: Operator must be '+' or '-'."
     self.assertEqual(
         actual, expected,
         '''Expected calling "arithmetic_arranger()" with a problem that uses the "/" operator to return "Error: Operator must be '+' or '-'."'''
     )
Beispiel #3
0
 def test_too_many_digits(self):
     actual = arithmetic_arranger(
         ["24 + 85215", "3801 - 2", "45 + 43", "123 + 49"])
     expected = "Error: Numbers cannot be more than four digits."
     self.assertEqual(
         actual, expected,
         'Expected calling "arithmetic_arranger()" with a problem that has a number over 4 digits long to return "Error: Numbers cannot be more than four digits."'
     )
Beispiel #4
0
 def test_solutions(self):
     actual = arithmetic_arranger(
         ["32 - 698", "1 - 3801", "45 + 43", "123 + 49"], True)
     expected = "   32         1      45      123\n- 698    - 3801    + 43    +  49\n-----    ------    ----    -----\n -666     -3800      88      172"
     self.assertEqual(
         actual, expected,
         'Expected solutions to be correctly displayed in output when calling "arithmetic_arranger()" with arithemetic problems and a second argument of `True`.'
     )
Beispiel #5
0
 def test_only_digits(self):
     actual = arithmetic_arranger(
         ["98 + 3g5", "3801 - 2", "45 + 43", "123 + 49"])
     expected = "Error: Numbers must only contain digits."
     self.assertEqual(
         actual, expected,
         'Expected calling "arithmetic_arranger()" with a problem that contains a letter character in the number to return "Error: Numbers must only contain digits."'
     )
Beispiel #6
0
 def test_too_many_problems(self):
     actual = arithmetic_arranger([
         "44 + 815", "909 - 2", "45 + 43", "123 + 49", "888 + 40",
         "653 + 87"
     ])
     expected = "Error: Too many problems."
     self.assertEqual(
         actual, expected,
         'Expected calling "arithmetic_arranger()" with more than five problems to return "Error: Too many problems."'
     )
Beispiel #7
0
    def test_arrangement(self):
        actual = arithmetic_arranger([
                                        "3 + 855", 
                                        "3801 - 2", 
                                        "45 + 43", 
                                        "123 + 49"
                                    ])
        expected = (
            "  855      3801      45      123\n"
            "+   3    -    2    + 43    +  49\n"
            "-----    ------    ----    -----\n"
            )
        self.assertEqual(actual,expected,'Test failed')

# if __name__ == "__main__":
#     unittest.main()
# This entrypoint file to be used in development. Start by reading README.md
from arithmetic_arranger import arithmetic_arranger
from unittest import main

print(arithmetic_arranger(["32 + 698", "3801 - 2", "45 + 43", "123 + 49"]))
print(
    arithmetic_arranger(["32 - 698", "1 - 3801", "45 + 43", "123 + 49"], True))

# Run unit tests automatically
main(module='test_module', exit=False)
Beispiel #9
0
from arithmetic_arranger import arithmetic_arranger

# print(arithmetic_arranger(["32 + 698", "3801 - 2", "45 + 43", "123 + 49"]))

print(
    arithmetic_arranger(["32 + 8", "1 - 3801", "9999 + 9999", "523 - 49"],
                        True))

# print(arithmetic_arranger(["3 + 855", "3801 - 2", "45 + 43", "123 + 49"]))
# print(arithmetic_arranger(["11 + 4", "3801 - 2999", "1 + 2", "123 + 49", "1 - 9380"]))
Beispiel #10
0
# This entrypoint file to be used in development. Start by reading README.md
from arithmetic_arranger import arithmetic_arranger
# from unittest import main

print("start")
print(
    arithmetic_arranger(["32 + 698", "3801 - 2", "45 + 43", "123 + 49"], True))

# Run unit tests automatically
# main(module='test_module', exit=False)
Beispiel #11
0
# This entrypoint file to be used in development. Start by reading README.md
from arithmetic_arranger import arithmetic_arranger
from unittest import main

print(' ')
print(arithmetic_arranger(["32 + 698", "3801 - 2", "45 + 43", "123 + 49"]))
print(' ')
print(
    arithmetic_arranger(
        ["11 + 4", "3801 - 2999", "1 + 2", "123 + 49", "1 - 9380"]))
print(' ')
print(
    arithmetic_arranger(
        ["44 + 815", "909 - 2", "45 + 43", "123 + 49", "888 + 40",
         "653 + 87"]))
print(' ')
print(arithmetic_arranger(["3 / 855", "3801 - 2", "45 + 43", "123 + 49"]))
print(' ')
print(arithmetic_arranger(["24 + 85215", "3801 - 2", "45 + 43", "123 + 49"]))
print(' ')
print(arithmetic_arranger(["98 + 3g5", "3801 - 2", "45 + 43", "123 + 49"]))
print(' ')
print(arithmetic_arranger(["32 - 698", "1 - 3801", "45 + 43", "123 + 49"]))
print(' ')

# Run unit tests automatically
# main(module='test_module', exit=False)
Beispiel #12
0
# This entrypoint file to be used in development. Start by reading README.md
from arithmetic_arranger import arithmetic_arranger
from unittest import main

x = arithmetic_arranger(["32 + 698"])
print(x)
Beispiel #13
0
# This entrypoint file to be used in development. Start by reading README.md
from arithmetic_arranger import arithmetic_arranger
from unittest import main

print(arithmetic_arranger(["1 + 2"]))
# print(arithmetic_arranger(["32 + 698", "3801 - 2", "45 + 43", "123 + 49"]))

# Run unit tests automatically
main(module='test_module', exit=False)
Beispiel #14
0
# This entrypoint file to be used in development. Start by reading README.md
from arithmetic_arranger import arithmetic_arranger
from unittest import main

print(arithmetic_arranger(["3 + 855", "3801 - 2", "45 + 43", "123 + 49"]))

#Run unit tests automatically
main(module='test_module', exit=False)
Beispiel #15
0
# This entrypoint file to be used in development. Start by reading README.md
from arithmetic_arranger import arithmetic_arranger

print('Write 5 problems:')

problems = []
for i in range(5):
    problems.append(input('-:'))

print(arithmetic_arranger(problems))
Beispiel #16
0
def test_template(arguments, expected_output, fail_message):
    actual = arithmetic_arranger(*arguments)
    assert actual == expected_output, fail_message
Beispiel #17
0
 def test_simple_arangement(self):
     actual = arithmetic_arranger(["235 + 52"])
     expected = "  235\n+  52\n-----"
     self.assertEqual(actual, expected)
Beispiel #18
0
# This entrypoint file to be used in development. Start by reading README.md
from arithmetic_arranger import arithmetic_arranger
from unittest import main

print(arithmetic_arranger([32 + 698, 3801 - 2, 45 + 43, 123 + 49]))

# Run unit tests automatically
main(module='test_module', exit=False)
Beispiel #19
0
# This entrypoint file to be used in development. Start by reading README.md
from arithmetic_arranger import arithmetic_arranger
from unittest import main

print(arithmetic_arranger(["32 + 698", "3801 + 2", "45 + 43", "123 + 49"]))

# Run unit tests automatically
main(module='test_module', exit=False)
from arithmetic_arranger import arithmetic_arranger
from unittest import main
import argparse

# Adding command line argument parser:
parser = argparse.ArgumentParser(description='Provide list of operations')
parser.add_argument(
    '-a',
    '--arrange',
    action='append',
    type=str,
    help=
    "Provide a list of operations in a following format ['int + int', 'int - int']. Available operations are addition and subtraction."
)
parser.add_argument(
    '-o',
    '--output',
    type=bool,
    help='Flag which decides if the output will be calculated.')

# Parsing arguments:
args = parser.parse_args()

# Printing output:
print(arithmetic_arranger(problems=args.arrange, output_flag=args.output))
Beispiel #21
0
# This entrypoint file to be used in development. Start by reading README.md
from pytest import main

from arithmetic_arranger import arithmetic_arranger

print(arithmetic_arranger(['3801 - 2', '123 + 49'], True))

# Run unit tests automatically
main()
Beispiel #22
0
# This entrypoint file to be used in development. Start by reading README.md
from arithmetic_arranger import arithmetic_arranger
from unittest import main

print(arithmetic_arranger(["3 + 855", "3801 - 2", "45 + 43", "123 + 49"]))
print(arithmetic_arranger(["32 + 698", "3801 - 2", "45 + 43", "123 + 49"]))
print(arithmetic_arranger(["98 + 3g5", "3801 - 2", "45 + 43", "123 + 49"]))
print(
    arithmetic_arranger(
        ["11 + 4", "3801 - 2999", "1 + 2", "123 + 49", "1 - 9380"]))
print(
    arithmetic_arranger(["32 - 698", "1 - 3801", "45 + 43", "123 + 49"], True))

# Run unit tests automatically
main(module='test_module', exit=False)
      ans[3] += ((spaces-len(str(result))+1)*" ")+str(result)+" "*4
  if print_ == True:
    arranged_problems = "\n".join(ans)
  else:
    arranged_problems = "\n".join(ans[:-1])
  print((arranged_problems))
  return arranged_problems
  
  
  
  # This entrypoint file to be used in development. Start by reading README.md
from arithmetic_arranger import arithmetic_arranger
from unittest import main


print(arithmetic_arranger(["32 - 698", "1 - 3801", "45 + 43", "123 + 49"]))
print("   32         1      45      123\n- 698    - 3801    + 43    +  49\n-----    ------    ----    -----\n -666     -3800      88      172"==arithmetic_arranger(["32 - 698", "1 - 3801", "45 + 43", "123 + 49"],True))
print(("   32         1      45      123\n- 698    - 3801    + 43    +  49\n-----    ------    ----    -----\n -666     -3800      88      172"))


# Run unit tests automatically
main(module='test_module', exit=False)


import unittest
from arithmetic_arranger import arithmetic_arranger


# the test case
class UnitTests(unittest.TestCase):
    def test_arrangement(self):
from arithmetic_arranger import arithmetic_arranger

first_problems = ["32 + 698", "3801 - 2", "45 + 43", "123 + 49"]
print(arithmetic_arranger(first_problems, True))
print()
print(arithmetic_arranger(["32 + 8", "1 - 3801", "9999 + 9999", "523 - 49"], True))
Beispiel #25
0
from arithmetic_arranger import arithmetic_arranger
from unittest import main

while True:
    equations = input('Give me up to 5 equations split by commas\n')
    equations = equations.replace(', ', ',').split(',')
    show_answer = input('Do you want to see the answers for these equations? [yes, no]\n')
    show_answer = True if 'y' in show_answer.lower() else False
    print(arithmetic_arranger(equations,show_answer))
# print(arithmetic_arranger(['32 + 698','3801 - 2','45 + 43','123 + 49']))

# main(module='test_module', exit=False)
Beispiel #26
0
# This entrypoint file to be used in development. Start by reading README.md
from arithmetic_arranger import arithmetic_arranger
from unittest import main

print(
    arithmetic_arranger(
        ["11 + 4", "3801 - 2999", "1 + 2", "123 + 49", "1 - 9380"]))
print(
    arithmetic_arranger(["32 + 8", "1 - 3801", "9999 + 9999", "523 + 49"],
                        True))
#Run unit tests automatically
main(module='test_module', exit=False)
from arithmetic_arranger import arithmetic_arranger
from unittest import main

print(
    arithmetic_arranger(["32 - 698", "1 - 3801", "45 + 43", "123 + 49"], True))

# Run unit tests automatically
main(module='test_module', exit=False)
Beispiel #28
0
# This entrypoint file to be used in development. Start by reading README.md
from arithmetic_arranger import arithmetic_arranger
from unittest import main

print(
    *arithmetic_arranger(["3 + 855", "3801 - 2", "45 + 43", "123 + 49"], True))

# Run unit tests automatically
main(module='test_module', exit=False)
# This entrypoint file to be used in development. Start by reading README.md
from arithmetic_arranger import arithmetic_arranger
from unittest import main


print(arithmetic_arranger(["11 + 4", "3801 - 2999", "1 + 2", "123 + 49", "1 - 9380"],True))


# Run unit tests automatically
main(module='test_module', exit=False)
Beispiel #30
0
# This entrypoint file to be used in development. Start by reading README.md
from arithmetic_arranger import arithmetic_arranger
from unittest import main

print(arithmetic_arranger(['3 + 855', '3801 - 2', '45 + 43', '123 + 49']),
      True)
# "98 + 3g5", "3801 - 2", "45 + 43", "123 + 49"
#'24 + 85215', '3801 - 2', '45 + 43', '123 + 49'

# Run unit tests automatically
main(module='test_module', exit=False)