Skip to content

Commit 3d1a587

Browse files
authored
Create README.md
1 parent 6aa1061 commit 3d1a587

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

arithmetic-formatter/README.md

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Project Description
2+
3+
### Assignment
4+
5+
Students in primary school often arrange arithmetic problems vertically to make them easier to solve. For example, "235 + 52" becomes:
6+
```
7+
235
8+
+ 52
9+
-----
10+
```
11+
12+
Create a function that receives a list of strings that are arithmetic problems and returns the problems arranged vertically and side-by-side. The function should optionally take a second argument. When the second argument is set to `True`, the answers should be displayed.
13+
14+
### For example
15+
16+
Function Call:
17+
```py
18+
arithmetic_arranger(["32 + 698", "3801 - 2", "45 + 43", "123 + 49"])
19+
```
20+
21+
Output:
22+
```
23+
32 3801 45 123
24+
+ 698 - 2 + 43 + 49
25+
----- ------ ---- -----
26+
```
27+
28+
Function Call:
29+
```py
30+
arithmetic_arranger(["32 + 8", "1 - 3801", "9999 + 9999", "523 - 49"], True)
31+
```
32+
33+
Output:
34+
```
35+
32 1 9999 523
36+
+ 8 - 3801 + 9999 - 49
37+
---- ------ ------ -----
38+
40 -3800 19998 474
39+
```
40+
41+
### Rules
42+
43+
The function will return the correct conversion if the supplied problems are properly formatted, otherwise, it will **return** a **string** that describes an error that is meaningful to the user.
44+
45+
46+
* Situations that will return an error:
47+
* If there are **too many problems** supplied to the function. The limit is **five**, anything more will return:
48+
`Error: Too many problems.`
49+
* The appropriate operators the function will accept are **addition** and **subtraction**. Multiplication and division will return an error. Other operators not mentioned in this bullet point will not need to be tested. The error returned will be:
50+
`Error: Operator must be '+' or '-'.`
51+
* Each number (operand) should only contain digits. Otherwise, the function will return:
52+
`Error: Numbers must only contain digits.`
53+
* Each operand (aka number on each side of the operator) has a max of four digits in width. Otherwise, the error string returned will be:
54+
`Error: Numbers cannot be more than four digits.`
55+
* If the user supplied the correct format of problems, the conversion you return will follow these rules:
56+
* There should be a single space between the operator and the longest of the two operands, the operator will be on the same line as the second operand, both operands will be in the same order as provided (the first will be the top one and the second will be the bottom.
57+
* Numbers should be right-aligned.
58+
* There should be four spaces between each problem.
59+
* There should be dashes at the bottom of each problem. The dashes should run along the entire length of each problem individually. (The example above shows what this should look like.)
60+
<!-- -->
61+
[FreeCodeCamp](https://www.freecodecamp.org/learn/scientific-computing-with-python/scientific-computing-with-python-projects/arithmetic-formatter)

0 commit comments

Comments
 (0)