Well i don’t undestand whats the problem
Solution 2 is the one i’m working on
What are we looking at in your links? What problem do you want us to help with specifically?
oh sorry, it’s a github repository, but it didn’t show, probably it’s because i used jupyter botebooks, the problem is that If you enter in the repository it shows the data formated in the way that the problem describe, but i don’t know why it’s says that it’s not formmated in the correct way
did you run the tests? What errors did you receive?
I can not pass the formatting tests, but in mi code it seems pretty similar
Please post the actual errors you received.
32 3801 45 123
+ 698 - 2 + 43 + 49
_____ ______ ____ ____
730 3799 88 172
========================================================================================================================== test session starts ==========================================================================================================================
platform linux -- Python 3.8.12, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 -- /home/runner/boilerplate-arithmetic-formatter/venv/bin/python
cachedir: .pytest_cache
rootdir: /home/runner/boilerplate-arithmetic-formatter
collected 10 items
test_module.py::test_template[test_two_problems_arrangement1] FAILED [ 10%]
test_module.py::test_template[test_two_problems_arrangement2] FAILED [ 20%]
test_module.py::test_template[test_four_problems_arrangement] FAILED [ 30%]
test_module.py::test_template[test_five_problems_arrangement] FAILED [ 40%]
test_module.py::test_template[test_too_many_problems] PASSED [ 50%]
test_module.py::test_template[test_incorrect_operator] PASSED [ 60%]
test_module.py::test_template[test_too_many_digits] PASSED [ 70%]
test_module.py::test_template[test_only_digits] PASSED [ 80%]
test_module.py::test_template[test_two_problems_with_solutions] FAILED [ 90%]
test_module.py::test_template[test_five_problems_with_solutions] FAILED [100%]
=============================================================================================================================== FAILURES ================================================================================================================================
_____________________________________________________________________________________________________________ test_template[test_two_problems_arrangement1] _____________________________________________________________________________________________________________
arguments = [['3801 - 2', '123 + 49']], expected_output = ' 3801 123\n- 2 + 49\n------ -----', fail_message = 'Expected different output when calling "arithmetic_arranger()" with ["3801 - 2", "123 + 49"]'
@pytest.mark.parametrize('arguments,expected_output,fail_message', test_cases)
def test_template(arguments, expected_output, fail_message):
actual = arithmetic_arranger(*arguments)
> assert actual == expected_output, fail_message
E AssertionError: Expected different output when calling "arithmetic_arranger()" with ["3801 - 2", "123 + 49"]
E assert ' 3801 123\n - 2 + 49\n ______ ____\n 3799 172' == ' 3801 123\n- 2 + 49\n------ -----'
E - 3801 123
E ? -
E + 3801 123
E ? ++++
E - - 2 + 49
E ? -
E + - 2 + 49
E ? ++++
E - ------ -----
E + ______ ____
E + 3799 172
test_module.py:77: AssertionError
_____________________________________________________________________________________________________________ test_template[test_two_problems_arrangement2] _____________________________________________________________________________________________________________
arguments = [['1 + 2', '1 - 9380']], expected_output = ' 1 1\n+ 2 - 9380\n--- ------', fail_message = 'Expected different output when calling "arithmetic_arranger()" with ["1 + 2", "1 - 9380"]'
@pytest.mark.parametrize('arguments,expected_output,fail_message', test_cases)
def test_template(arguments, expected_output, fail_message):
actual = arithmetic_arranger(*arguments)
> assert actual == expected_output, fail_message
E AssertionError: Expected different output when calling "arithmetic_arranger()" with ["1 + 2", "1 - 9380"]
E assert ' 1 1\n + 2 - 9380\n ___ ______\n 3 -9379' == ' 1 1\n+ 2 - 9380\n--- ------'
E - 1 1
E + 1 1
E ? ++++
E - + 2 - 9380
E + + 2 - 9380
E ? ++++
E - --- ------
E + ___ ______
E + 3 -9379
test_module.py:77: AssertionError
_____________________________________________________________________________________________________________ test_template[test_four_problems_arrangement] _____________________________________________________________________________________________________________
arguments = [['3 + 855', '3801 - 2', '45 + 43', '123 + 49']], expected_output = ' 3 3801 45 123\n+ 855 - 2 + 43 + 49\n----- ------ ---- -----'
fail_message = 'Expected different output when calling "arithmetic_arranger()" with ["3 + 855", "3801 - 2", "45 + 43", "123 + 49"]'
@pytest.mark.parametrize('arguments,expected_output,fail_message', test_cases)
def test_template(arguments, expected_output, fail_message):
actual = arithmetic_arranger(*arguments)
> assert actual == expected_output, fail_message
E AssertionError: Expected different output when calling "arithmetic_arranger()" with ["3 + 855", "3801 - 2", "45 + 43", "123 + 49"]
E assert (' 3 3801 45 123\n'\n ' + 855 - 2 + 43 + 49\n'\n ' _____ ______ ____ ____\n'\n ' 858 3799 88 172') == (' 3 3801 45 123\n'\n '+ 855 - 2 + 43 + 49\n'\n '----- ------ ---- -----')
E - 3 3801 45 123
E ? -
E + 3 3801 45 123
E ? ++++
E - + 855 - 2 + 43 + 49
E ? -
E + + 855 - 2 + 43 + 49
E ? ++++
E - ----- ------ ---- -----
E + _____ ______ ____ ____
E + 858 3799 88 172
test_module.py:77: AssertionError
_____________________________________________________________________________________________________________ test_template[test_five_problems_arrangement] _____________________________________________________________________________________________________________
arguments = [['11 + 4', '3801 - 2999', '1 + 2', '123 + 49', '1 - 9380']], expected_output = ' 11 3801 1 123 1\n+ 4 - 2999 + 2 + 49 - 9380\n---- ------ --- ----- ------'
fail_message = 'Expected different output when calling "arithmetic_arranger()" with ["11 + 4", "3801 - 2999", "1 + 2", "123 + 49", "1 - 9380"]'
@pytest.mark.parametrize('arguments,expected_output,fail_message', test_cases)
def test_template(arguments, expected_output, fail_message):
actual = arithmetic_arranger(*arguments)
> assert actual == expected_output, fail_message
E AssertionError: Expected different output when calling "arithmetic_arranger()" with ["11 + 4", "3801 - 2999", "1 + 2", "123 + 49", "1 - 9380"]
E assert (' 11 3801 1 123 1\n'\n ' + 4 - 2999 + 2 + 49 - 9380\n'\n ' ___ ______ ___ ____ ______\n'\n ' 15 802 3 172 -9379') == (' 11 3801 1 123 1\n'\n '+ 4 - 2999 + 2 + 49 - 9380\n'\n '---- ------ --- ----- ------')
E - 11 3801 1 123 1
E ? -
E + 11 3801 1 123 1
E ? +++
E - + 4 - 2999 + 2 + 49 - 9380
E ? - -
E + + 4 - 2999 + 2 + 49 - 9380
E ? ++++
E - ---- ------ --- ----- ------
E + ___ ______ ___ ____ ______
E + 15 802 3 172 -9379
test_module.py:77: AssertionError
____________________________________________________________________________________________________________ test_template[test_two_problems_with_solutions] ____________________________________________________________________________________________________________
arguments = [['3 + 855', '988 + 40'], True], expected_output = ' 3 988\n+ 855 + 40\n----- -----\n 858 1028'
fail_message = 'Expected solutions to be correctly displayed in output when calling "arithmetic_arranger()" with ["3 + 855", "988 + 40"] and a second argument of `True`.'
@pytest.mark.parametrize('arguments,expected_output,fail_message', test_cases)
def test_template(arguments, expected_output, fail_message):
actual = arithmetic_arranger(*arguments)
> assert actual == expected_output, fail_message
E AssertionError: Expected solutions to be correctly displayed in output when calling "arithmetic_arranger()" with ["3 + 855", "988 + 40"] and a second argument of `True`.
E assert ' 3 988\n + 855 + 40\n _____ _____\n 858 1028' == ' 3 988\n+ 855 + 40\n----- -----\n 858 1028'
E - 3 988
E + 3 988
E ? ++++
E - + 855 + 40
E + + 855 + 40
E ? ++++
E - ----- -----
E + _____ _____
E - 858 1028
E + 858 1028
E ? ++++
test_module.py:77: AssertionError
___________________________________________________________________________________________________________ test_template[test_five_problems_with_solutions] ____________________________________________________________________________________________________________
arguments = [['32 - 698', '1 - 3801', '45 + 43', '123 + 49', '988 + 40'], True]
expected_output = ' 32 1 45 123 988\n- 698 - 3801 + 43 + 49 + 40\n----- ------ ---- ----- -----\n -666 -3800 88 172 1028'
fail_message = 'Expected solutions to be correctly displayed in output when calling "arithmetic_arranger()" with five arithmetic problems and a second argument of `True`.'
@pytest.mark.parametrize('arguments,expected_output,fail_message', test_cases)
def test_template(arguments, expected_output, fail_message):
actual = arithmetic_arranger(*arguments)
> assert actual == expected_output, fail_message
E AssertionError: Expected solutions to be correctly displayed in output when calling "arithmetic_arranger()" with five arithmetic problems and a second argument of `True`.
E assert (' 32 1 45 123 988\n'\n ' - 698 - 3801 + 43 + 49 + 40\n'\n ' _____ ______ ____ ____ _____\n'\n ' -666 -3800 88 172 1028') == (' 32 1 45 123 988\n'\n '- 698 - 3801 + 43 + 49 + 40\n'\n '----- ------ ---- ----- -----\n'\n ' -666 -3800 88 172 1028')
E - 32 1 45 123 988
E ? -
E + 32 1 45 123 988
E ? ++++
E - - 698 - 3801 + 43 + 49 + 40
E ? -
E + - 698 - 3801 + 43 + 49 + 40
E ? ++++
E - ----- ------ ---- ----- -----
E + _____ ______ ____ ____ _____
E - -666 -3800 88 172 1028
E ? -
E + -666 -3800 88 172 1028
E ? ++++
test_module.py:77: AssertionError
======================================================================================================================== short test summary info ========================================================================================================================
FAILED test_module.py::test_template[test_two_problems_arrangement1] - AssertionError: Expected different output when calling "arithmetic_arranger()" with ["3801 - 2", "123 + 49"]
FAILED test_module.py::test_template[test_two_problems_arrangement2] - AssertionError: Expected different output when calling "arithmetic_arranger()" with ["1 + 2", "1 - 9380"]
FAILED test_module.py::test_template[test_four_problems_arrangement] - AssertionError: Expected different output when calling "arithmetic_arranger()" with ["3 + 855", "3801 - 2", "45 + 43", "123 + 49"]
FAILED test_module.py::test_template[test_five_problems_arrangement] - AssertionError: Expected different output when calling "arithmetic_arranger()" with ["11 + 4", "3801 - 2999", "1 + 2", "123 + 49", "1 - 9380"]
FAILED test_module.py::test_template[test_two_problems_with_solutions] - AssertionError: Expected solutions to be correctly displayed in output when calling "arithmetic_arranger()" with ["3 + 855", "988 + 40"] and a second argument of `True`.
FAILED test_module.py::test_template[test_five_problems_with_solutions] - AssertionError: Expected solutions to be correctly displayed in output when calling "arithmetic_arranger()" with five arithmetic problems and a second argument of `True`.
====================================================================================================================== 6 failed, 4 passed in 0.36s ======================================================================================================================
KeyboardInterrupt
here’s my code and the implementation
Looking at your replit, I see for the test arithmetric-formatter(["3801 - 2", "123 + 49"])
, your function returns:
' 3801 123\n - 2 + 49\n ______ ____\n 3799 172'
instead of the correct:
' 3801 123\n- 2 + 49\n------ -----'
i edited the post to use a better formatting to see the errors.
if you look at it now you can clearly see that your lines are not lined up properly
For eg this output:
32 3801 45 123
+ 698 - 2 + 43 + 49
_____ ______ ____ ____
730 3799 88 172
is clearly misaligned and also it seems you are using the wrong character for the lines. (it should be a dash or minus-sign)
Thanks for all your comments i managed to modify my code and fulfil the requierements