addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupsimageimagesinstagramlinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1outlookpersonStartprice-ribbonImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruseryahoo

Canton Software Craftsmanship Message Board › Monthly Mentorship Challenge #2

Monthly Mentorship Challenge #2

Shawn Michael C.
user 13107104
Portland, ME
Post #: 9
https://www.codeeval....­

Prefix expressions Share on LinkedIn

Challenge Description:

You are given a prefix expression. Write a program to evaluate it.

Input sample:

The first argument will be an input file with one prefix expression per line. e.g.

* + 2 3 4
Your program has to read this and insert it into any data structure you like. Traverse that data structure and evaluate the prefix expression. Each token is delimited by a whitespace. You may assume that the only valid operators appearing in test data are '+','*' and '/'

Output sample:

Print to stdout, the output of the prefix expression, one per line. e.g.

20

The public shared github repo is here:
https://github.com/ja...­

Just submit a pull request and we'll merge it into the main branch. As always if you have problems or get stuck please feel free to message me or email me at jaegerpicker at gmail dot com or post your question here or on github. Github is likely the best place that way everyone will see it when looking at the examples.
Powered by mvnForum

Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy