项目作者: siawashkasra

项目描述 :
Arithmetic Format
高级语言: Python
项目地址: git://github.com/siawashkasra/arithmetic_formater.git
创建时间: 2020-11-27T05:06:26Z
项目社区:https://github.com/siawashkasra/arithmetic_formater

开源协议:

下载


Arithmetic Format

Students in primary school often arrange arithmetic problems vertically to make them easier to solve. For example, “235 + 52” becomes:

  1. 235
  2. + 52
  3. -----

Arithmetic Format receives a list of strings that are arithmetic problems and returns the problems arranged vertically and side-by-side. The function optionally takes a second argument. When the second argument is set to True, the answers are displayed.

For example

Function Call:

  1. arrange(["32 + 698", "3801 - 2", "45 + 43", "123 + 49"])

Output:

  1. 32 3801 45 123
  2. + 698 - 2 + 43 + 49
  3. ----- ------ ---- -----

Function Call:

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

Output:

  1. 32 1 9999 523
  2. + 8 - 3801 + 9999 - 49
  3. ---- ------ ------ -----
  4. 40 -3800 19998 474