Back in the day, when phones were "landlines", computers were the size of minivans, and Brian Kelly was a linebacker at Assumption College, the pride and joy of every engineering geek was his HP scientific calculator. Even the mighty Woz 1 cherished his legendary HP-35.

Of course, since the old timers back then were super awesome (unlike today's young whippersnappers), they didn't use the standard lame infix notation to perform their calculations; instead, they used the uber 1337 reverse polish notation.

That is, rather than entering in <operand> <operation> <operand>, you would enter in <operand> <operand> <operation> to perform a calculation on the RPN calculator. Using RPN eliminates the need for paretheses and orders of operation since it is never ambiguous what operands are used with which operation; the operation is always applied to the previous arguments.

This means that if you wanted to perform 3 + 4, you would have to enter in:

3 4 +

To prove that you too are uber awesome and to relive some of the glory days, you are to create a RPN calulator that can perform: +, -, *, /, and ^. For the sake of nostalgia, you should output the results of the caluation as digital LED numbers as shown here:

    _  _     _  _  _  _  _  _
  | _| _||_||_ |_   ||_||_|| |
  ||_  _|  | _||_|  ||_| _||_|

Each digit is composed of a combination of | and _ and occupies the same amount of space.

For a negative number such as -3, you should display:

    _
 _  _|
    _|

Input

Each line in the input will be a RPN expression that you have to calculate.

Example Input

4
5 8 * 1 +

Output

For each RPN expression, output the calculation as a LED number.

Example Output

|_|
  |

|_|  |
  |  |

Note: All calculations are done using integer arithmetic; there are no decimals.

Submission

To submit your work, follow the same procedure you used for Reading 00:

$ cd path/to/cse-30872-fa19-assignments     # Go to assignments repository
$ git checkout master                       # Make sure we are on master
$ git pull --rebase                         # Pull any changes from GitLab

$ git checkout -b challenge02               # Create and checkout challenge02 branch

$ $EDITOR challenge02/program.cpp           # Edit your code

$ git add challenge02/program.cpp           # Stage your changes
$ git commit -m "challenge02: done"         # Commit your changes

$ git push -u origin challenge02            # Send changes to GitLab

To check your code, you can use the .scripts/submit.py script or curl:

$ .scripts/submit.py
Submitting challenge02 assignment ...
Submitting challenge02 code ...
  Result Success
   Score 6.00

$ curl -F source=@challenge02/program.cpp  https://dredd.h4x0r.space/code/cse-30872-fa19/challenge02
{"score": 6, "result": "Success"}

Once you have commited your work and pushed it to GitLab, member to create a merge request. Refer to the Reading 01 TA List to determine your corresponding TA for the merge request.


  1. Woz spilled my french fries. I will never forget.