Statistics

Problem Statement for "BadParser"

Problem Statement

You and a partner have teamed up for a coding project. He is writing the front-end of an arithmetic expression parser, and you are writing the back-end. The expressions are pretty simple, with normal arithmetic operations and no parentheses. As usual, he stayed up too late and made a terrible oversight. His parser spits out an expression tree where the precedence and associativity of the operators may be ignored. For example, let's say his program is given the expression "5+2-3-4*2". Each operator is supposed to be left associative, but his program could spit out the wrong tree:
       His tree                    Correct Tree
          +                             -
        /   \                        /     \
       5     -                     -         *
           /   \                 /   \     /   \
          2     -               +     3   4     2
              /   \           /   \
             3     *         5     2
                 /   \
                4     2
The expressions should be interpreted as follows:
  • 1) As usual, the order of operations gives * and / highest precedence whereas + and - have lowest. * and / have equal precedence. In addition, + and - have equal precedence.
  • 2) Amongst operations of equal precedence, process the leftmost operation first.
Adhering to these rules, the input above would be processed to produce the Correct Tree. In such a tree, lower nodes are processed before higher nodes. The value of a number node is the number itself. The value of an operation node is that operation applied to the values of its left and right subnodes (the value of the left subnode belongs on the left side of the operation). The value of the tree is the value of the top node (called the root node). Unfortunately, your partner's front-end may have violated rules 1 and 2 numerous times. Luckily the ordering of his tree is not messed up. This means that an inorder traversal of the tree beginning with the root will produce the original expression. Inorder traversal pseudocode follows:
InorderTraverse(node) {
	if (left subtree of node exists) 
		InorderTraverse(root of left subtree)
	Print the contents of node
	if (right subtree of node exists) 
		InorderTraverse(root of right subtree)
}
Your program will take a String[] badTree describing his tree, and will return an int which is the correct value of the expression he parsed. All operations are integer operations so division truncates results. For example 5/3=1, and -5/3 = -1.

Each element of badTree will be in one of two forms (quotes for clarity):
  • 1) "op X Y" : op is one of *,/,+,-. X,Y are integers referencing other elements of badTree (0-indexed). X refers to the node's left child and Y refers to the node's right child.
  • 2) "N" : N is a non-negative integer with no extra leading zeros.

Definition

Class:
BadParser
Method:
evaluate
Parameters:
String[]
Returns:
int
Method signature:
int evaluate(String[] badTree)
(be sure your method is public)

Constraints

  • badTree will contain between 1 and 50 elements inclusive.
  • Each element of badTree will be in one of the following forms (quotes for clarity):1) "op X Y" where X and Y are integers, with no extra leading zeros, between 0 and M-1 inclusive. op must be *,+,-, or /. Here M denotes the number of elements in badTree.2) "N" where N is a nonnegative integer with no extra leading zeros between 0 and 1000 inclusive.
  • The elements of badTree will describe a single tree, with element 0 acting as root.
  • The return value, and the value of any subtree of the correct tree will all be between -100000 and 100000 inclusive.
  • The computation of the return value, and the value of any subtree of the correct tree will not require division by 0.

Examples

  1. {"+ 1 2","5","- 3 4","2","- 5 6","3","* 7 8","4","2"}

    Returns: -4

    The example in the problem statement.

  2. {"- 1 2","5","- 3 4","2","- 5 6","3","* 7 8","4","2"}

    Returns: -8

    The example in the problem statement with the + replaced by a -.

  3. {"* 1 2","5","- 3 4","2","- 5 6","3","* 7 8","4","2"}

    Returns: -1

    The example in the problem statement with the + replaced by a *.

  4. {"99"}

    Returns: 99

  5. {"* 1 2","+ 3 4","+ 5 6","200","200","200","200"}

    Returns: 40400

  6. {"* 1 2","2","* 3 4","2","* 5 6","2","* 7 8","2","* 9 10","2","- 11 12","2","- 13 14","2","- 15 16","2","2"}

    Returns: 58

  7. {"/ 1 2","/ 3 4","/ 5 6","4","1","4","2"}

    Returns: 0

  8. {"/ 1 2","/ 3 4","/ 5 6","4","1","1","2"}

    Returns: 2

  9. {"/ 2 1","/ 3 4","/ 5 6","4","1","1","2"}

    Returns: 0

  10. {"/ 14 30","424","/ 41 26","724","/ 31 43","- 27 15","- 37 46","179","584","374","* 24 20","445","/ 2 45","488","- 32 40","/ 29 19","376","890","* 16 11","916","874","186","- 36 12","137","11","- 33 34","- 8 38","- 6 9","/ 10 48","/ 4 23","+ 17 44","165","/ 7 47","187","- 13 28","886","399","803","841","481","858","- 39 35","+ 18 22","593","/ 1 42","/ 21 25","233","254","* 5 3"}

    Returns: -744

  11. {"- 47 36","188","+ 5 15","495","162","795","369","811","+ 18 32","- 21 39","751","864","545","* 11 30","/ 8 44","- 38 24","343","/ 35 27","14","+ 20 43","/ 4 16","/ 42 10","1","/ 17 2","- 14 29","795","- 45 3","+ 31 41","9","474","/ 6 34","* 13 1","/ 9 25","- 26 19","/ 7 40","139","/ 48 23","606","- 46 28","364","510","- 12 37","+ 22 33","168","831","826","607","315","137"}

    Returns: 1302

  12. {"+ 48 19","174","941","- 5 12","353","/ 34 4","- 43 47","- 3 9","464","617","/ 2 13","893","561","233","- 11 15","- 29 42","- 31 23","510","+ 8 41","- 17 26","907","/ 18 7","736","784","- 45 14","510","+ 46 28","/ 21 38","- 35 16","232","632","- 32 33","/ 44 24","488","93","757","872","450","966","197","- 22 30","236","/ 10 25","- 27 40","975","- 20 6","593","- 37 36","- 39 1"}

    Returns: -5416

  13. {"- 13 23","- 42 8","670","/ 37 1","525","996","327","347","- 15 40","724","- 39 35","- 30 41","/ 3 17","824","- 20 48","- 5 28","455","- 18 43","259","442","204","709","/ 10 25","- 14 32","582","399","- 29 7","+ 21 22","- 9 16","- 27 6","842","949","- 19 36","+ 38 26","- 31 46","296","- 47 44","116","552","675","582","- 33 12","547","826","/ 2 11","413","499","- 24 34","/ 4 45"}

    Returns: -4698

  14. {"/ 12 2","- 46 6","/ 24 32","159","109","680","/ 4 15","986","275","+ 17 25","903","294","261","682","54","- 20 10","/ 48 14","* 27 28","/ 1 37","155","* 23 33","384","497","/ 30 8","488","169","485","286","- 29 38","/ 35 47","+ 22 43","- 7 19","- 9 18","435","- 40 39","311","750","- 45 26","450","269","- 16 36","917","/ 11 13","/ 21 44","/ 3 34","/ 42 41","653","946","/ 5 31"}

    Returns: -2171

  15. {"- 31 9","996","930","- 33 6","712","/ 20 44","46","796","257","- 36 28","724","/ 25 12","357","904","/ 15 34","143","295","125","* 42 8","116","- 19 17","/ 7 26","- 13 21","421","540","/ 29 2","* 4 1","/ 35 32","* 38 37","/ 41 24","250","700","864","2","- 16 45","807","- 23 39","/ 48 5","* 10 3","710","275","- 30 46","/ 40 27","- 22 18","- 43 14","- 47 11","73","447","679"}

    Returns: -3841

  16. {"/ 11 3","177","630","- 14 6","/ 46 10","618","- 41 47","383","803","15","- 23 25","29","+ 2 1","/ 34 40","/ 21 37","- 30 38","576","363","- 22 35","- 26 42","- 29 24","/ 18 4","/ 19 36","793","667","+ 44 33","886","419","51","882","- 8 32","752","- 20 16","272","577","/ 43 28","- 39 13","- 15 12","84","817","861","990","- 5 31","+ 9 45","- 17 48","444","593","215","- 7 27"}

    Returns: -5665

  17. {"/ 23 12","- 32 20","* 22 11","- 42 21","/ 3 38","+ 47 43","- 44 16","- 2 39","- 14 19","453","830","- 26 28","- 7 46","- 8 5","523","2","54","327","44","/ 17 36","908","/ 30 18","522","419","* 29 41","62","/ 37 1","250","379","- 31 48","541","221","- 40 15","817","+ 45 13","/ 25 34","/ 24 4","852","903","704","- 6 9","456","- 33 10","851","+ 35 27","311","189","629","8"}

    Returns: -2529

  18. {"- 16 34","202","- 32 18","207","809","393","* 8 47","- 42 10","/ 12 25","* 6 29","+ 44 26","* 31 46","/ 24 43","519","737","87","71","19","402","- 28 38","+ 13 2","/ 15 41","992","751","/ 21 35","78","- 27 36","/ 1 9","* 40 4","740","/ 37 23","/ 48 17","19","514","- 11 33","549","813","/ 39 14","* 45 3","/ 5 19","978","/ 20 30","56","691","336","241","/ 7 22","398","542"}

    Returns: -2328

  19. {"+ 30 36","496","+ 19 14","/ 12 46","443","978","315","- 6 35","8","- 15 28","- 48 13","620","- 26 25","809","- 38 47","723","- 32 37","/ 31 8","- 17 24","/ 22 40","90","597","671","458","- 10 33","/ 18 2","- 39 42","897","302","- 16 4","- 5 1","541","351","/ 20 27","758","- 44 21","- 45 3","252","/ 23 43","112","93","/ 7 9","/ 11 29","583","888","465","- 41 34","928","139"}

    Returns: -2826

  20. {"/ 27 9","/ 16 19","315","961","+ 15 33","738","717","- 6 2","615","/ 42 22","812","/ 24 25","* 38 21","489","- 30 45","- 20 14","914","/ 1 28","- 39 41","- 26 18","967","709","- 43 32","- 17 13","557","613","809","925","472","+ 48 40","/ 47 3","- 44 4","- 35 10","100","929","- 8 23","38","12","- 7 11","/ 29 5","292","862","954","663","- 34 36","841","- 31 37","685","- 12 46"}

    Returns: -5637

  21. {"- 43 38","- 32 31","371","658","684","+ 27 13","230","/ 24 36","- 40 46","460","401","273","554","- 47 41","/ 39 11","/ 7 16","688","255","/ 14 15","- 35 28","- 8 21","2","- 29 33","556","* 6 4","331","- 37 48","- 12 3","271","562","+ 23 26","- 44 20","+ 42 45","20","939","- 1 2","+ 22 10","185","/ 19 25","293","/ 30 9","152","499","755","- 18 17","/ 34 5","992","471","815"}

    Returns: -2094

  22. {"/ 42 36","- 4 27","845","/ 38 26","- 5 7","433","- 35 20","542","86","412","/ 8 41","495","950","452","- 6 9","842","- 10 43","- 37 25","257","- 31 40","33","+ 22 24","196","- 33 34","- 39 1","322","973","895","701","770","- 12 17","- 44 46","864","/ 32 2","841","246","- 19 16","321","- 48 21","+ 30 15","- 29 3","816","450","- 47 28","- 11 45","- 13 23","505","- 18 14","393"}

    Returns: -4633

  23. {"- 2 36","34","- 30 9","923","- 18 24","490","/ 20 33","/ 31 27","/ 17 22","110","78","/ 40 4","935","678","- 37 41","512","- 46 35","- 32 45","563","- 5 28","652","161","/ 47 12","6","/ 1 43","327","- 21 14","928","145","426","990","/ 13 39","191","379","/ 8 10","979","+ 26 11","370","511","409","/ 38 15","- 29 34","173","- 6 44","- 7 16","- 3 48","* 19 42","- 23 25","747"}

    Returns: -27869

  24. {"* 35 45","975","308","/ 25 44","+ 19 1","- 33 26","/ 41 30","221","- 15 31","94","/ 36 42","529","435","- 24 12","/ 5 21","658","- 22 2","- 10 18","186","* 47 34","355","108","661","565","- 11 17","215","- 20 6","- 39 23","485","464","47","487","104","95","/ 14 9","+ 8 7","* 3 4","223","2","/ 32 37","689","212","235","5","- 29 43","- 48 13","- 27 28","/ 40 16","- 46 38"}

    Returns: -31544

  25. {"- 43 33","705","468","697","- 12 16","492","838","+ 45 20","- 26 35","- 32 42","- 27 7","- 19 22","794","195","571","653","784","/ 21 39","- 28 23","- 47 4","- 41 5","378","- 36 10","- 13 37","/ 34 11","324","- 40 30","+ 15 31","719","+ 2 6","242","333","62","+ 25 17","524","727","- 38 46","/ 1 24","903","/ 14 18","206","/ 8 48","575","- 3 29","981","3","- 9 44","609","618"}

    Returns: -4403

  26. {"+ 22 30","- 13 3","291","/ 28 42","/ 10 12","256","16","349","- 34 29","- 40 35","572","697","845","835","- 15 41","612","946","- 18 47","- 24 20","/ 8 36","125","772","564","+ 39 21","- 25 33","655","* 7 32","143","/ 9 43","507","- 6 38","878","- 23 37","187","/ 27 45","788","683","898","/ 31 26","/ 44 46","550","- 48 19","676","* 4 5","/ 17 14","- 1 11","870","/ 16 2","767"}

    Returns: -3182

  27. {"+ 37 39","675","* 36 27","999","/ 34 23","223","- 13 10","88","+ 41 24","812","775","791","- 7 4","262","- 19 38","544","211","- 28 48","/ 16 20","345","- 47 31","948","157","/ 45 18","393","277","- 32 35","- 6 12","/ 29 25","856","- 15 22","/ 42 43","221","+ 44 14","- 1 21","423","690","207","/ 40 11","/ 33 2","/ 3 17","- 26 30","32","/ 8 5","77","655","550","- 9 46","506"}

    Returns: -2582

  28. {"- 9 31","- 48 34","/ 26 5","- 27 14","988","428","546","/ 46 41","* 12 42","- 3 20","280","- 36 15","- 18 32","608","437","- 33 7","- 28 24","719","- 40 21","160","365","46","660","- 30 25","925","/ 11 29","- 35 4","/ 17 38","394","- 6 8","109","/ 22 47","+ 43 10","34","663","206","- 2 44","546","- 1 13","155","316","132","- 45 16","269","96","12","864","+ 37 23","/ 19 39"}

    Returns: -893

  29. {"/ 18 22","209","575","- 24 32","841","- 46 48","- 26 4","- 21 30","274","946","627","+ 1 16","564","/ 15 29","404","/ 9 34","224","- 3 8","- 28 45","117","/ 31 42","42","/ 11 35","920","/ 43 7","/ 36 47","301","453","/ 19 14","123","/ 12 41","+ 17 44","400","11","138","- 37 20","- 23 27","/ 2 39","- 6 13","- 40 5","87","- 38 33","777","/ 25 10","829","339","564","142","989"}

    Returns: -4000

  30. {"- 15 37","/ 32 44","+ 5 13","489","837","84","- 31 10","/ 28 11","589","989","839","767","/ 18 27","- 24 16","/ 9 38","272","519","817","554","41","/ 45 43","838","/ 6 36","987","558","723","869","- 35 25","919","916","/ 48 7","- 30 20","/ 26 40","/ 4 23","678","- 3 47","/ 21 34","/ 22 33","- 2 41","/ 12 17","- 8 14","174","- 39 46","+ 29 1","802","+ 19 42","276","503","697"}

    Returns: -242

  31. {"- 4 31","/ 43 32","907","597","/ 22 38","/ 24 44","692","- 8 28","/ 26 45","310","541","200","- 1 13","205","148","22","49","- 16 36","- 29 5","- 10 11","/ 15 27","- 39 3","363","- 12 20","- 40 33","+ 42 14","/ 21 37","641","800","111","66","- 35 34","860","+ 30 2","628","- 17 6","- 47 46","- 19 25","684","860","729","296","/ 9 41","446","/ 7 48","867","644","- 23 18","756"}

    Returns: -3326

  32. {"/ 42 38","/ 32 17","244","- 34 27","580","755","545","846","722","281","448","- 16 33","808","366","- 35 37","- 8 18","697","- 25 28","+ 2 29","60","/ 45 30","634","325","176","740","258","+ 40 23","- 6 21","- 7 5","837","999","- 1 22","578","/ 10 26","852","* 20 48","- 3 13","72","- 39 15","/ 47 19","/ 4 24","- 31 43","963","997","/ 46 41","290","+ 12 11","- 9 14","- 44 36"}

    Returns: -4750

  33. {"- 20 35","- 46 16","/ 33 31","239","134","47","* 41 22","48","786","/ 3 44","633","810","59","/ 19 5","38","753","/ 45 26","933","/ 47 15","707","- 6 34","/ 8 10","172","518","- 12 36","227","982","440","531","/ 13 25","- 4 24","* 23 39","47","- 38 21","27","474","+ 18 27","- 43 7","194","+ 37 9","- 11 30","/ 42 14","- 1 40","474","/ 29 28","- 17 32","466","/ 48 2","139"}

    Returns: -127

  34. {"- 43 35","- 31 37","186","854","12","- 40 18","742","- 12 16","/ 45 10","/ 7 26","287","/ 13 6","641","- 27 36","445","/ 47 2","* 25 42","995","892","- 33 48","/ 19 4","292","- 44 23","306","30","/ 24 8","600","/ 9 41","544","772","333","/ 34 39","747","167","- 46 20","+ 11 28","664","- 5 22","- 1 32","761","- 21 14","658","792","704","+ 3 17","- 15 29","128","- 30 38","939"}

    Returns: -1486

  35. {"- 21 43","8","5","/ 48 18","262","- 26 47","/ 11 36","35","985","- 14 3","/ 42 39","992","413","/ 40 45","805","995","- 35 25","/ 32 10","811","- 15 22","720","/ 12 31","980","- 13 44","- 34 4","+ 9 41","739","- 30 33","- 5 19","529","/ 20 7","/ 46 28","285","595","39","694","344","/ 38 24","51","/ 27 6","112","/ 17 2","326","* 1 16","926","690","583","- 8 29","- 37 23"}

    Returns: -10110

  36. {"/ 28 48","643","- 24 47","/ 10 39","/ 43 2","27","- 36 13","- 11 23","- 9 38","594","677","497","392","- 16 5","875","404","- 15 46","969","- 21 7","330","588","422","- 3 26","/ 8 44","- 31 32","+ 34 1","61","507","989","- 14 42","/ 37 35","749","/ 19 17","42","/ 6 20","714","/ 30 40","911","- 29 4","- 18 33","119","774","- 41 25","/ 12 27","541","306","834","584","/ 45 22"}

    Returns: -3439

  37. {"/ 44 43","/ 6 29","- 48 46","428","421","14","209","374","+ 1 19","678","* 37 8","- 5 40","429","758","933","511","- 26 20","/ 32 4","345","/ 34 31","- 45 27","181","- 33 38","- 47 16","- 10 21","/ 24 30","272","45","/ 36 2","* 11 13","667","223","806","- 12 41","/ 35 42","- 22 7","827","- 3 23","536","7","- 15 28","959","930","74","/ 39 25","112","/ 14 17","/ 9 18","199"}

    Returns: -2637

  38. {"- 38 48","474","593","/ 22 32","/ 28 33","- 14 41","/ 1 24","- 2 13","- 3 39","334","468","+ 25 31","/ 29 21","958","+ 7 42","341","153","/ 18 26","- 36 30","554","163","147","151","105","/ 15 8","991","381","/ 47 20","584","/ 45 19","/ 6 34","- 9 40","/ 27 46","* 10 5","- 11 35","/ 12 23","579","476","714","365","- 44 43","- 37 17","509","245","599","557","866","274","- 16 4"}

    Returns: -2046

  39. {"- 11 21","- 41 5","* 18 9","629","643","395","- 8 23","/ 10 14","- 31 12","918","793","33","+ 13 39","174","+ 40 48","995","- 4 42","763","- 26 32","/ 30 22","/ 6 36","- 47 16","632","33","+ 25 3","147","799","15","/ 33 1","+ 7 15","990","110","105","121","- 17 46","- 20 27","- 38 34","917","/ 43 28","621","834","510","/ 44 29","749","/ 37 19","663","/ 2 24","694","- 45 35"}

    Returns: -1307

  40. {"+ 22 29","* 38 37","359","* 44 27","/ 14 39","+ 18 4","206","48","734","272","/ 1 48","544","422","275","* 23 34","38","442","/ 43 7","709","- 10 11","/ 8 46","* 41 19","- 36 24","- 9 35","- 31 25","/ 5 21","+ 42 2","+ 30 28","+ 33 16","+ 13 45","157","+ 12 20","623","431","282","134","491","280","197","- 32 26","+ 3 17","262","893","927","428","- 6 40","222","73","/ 15 47"}

    Returns: -67666

  41. {"/ 6 33","926","625","960","+ 48 38","360","418","/ 20 35","/ 27 40","820","- 26 43","139","- 19 42","- 2 1","824","239","512","- 47 11","- 8 22","- 21 24","/ 34 37","+ 29 44","/ 46 17","+ 15 45","690","490","- 23 28","- 7 3","80","586","* 9 12","30","* 10 41","/ 30 36","489","20","34","128","474","476","525","+ 31 14","* 5 4","169","719","- 18 13","- 16 39","885","/ 32 25"}

    Returns: -93350

  42. {"* 43 11","600","+ 48 9","419","213","* 14 32","+ 8 10","818","453","210","+ 13 31","/ 30 17","678","/ 3 28","/ 16 33","426","+ 23 35","939","/ 2 47","- 34 46","272","+ 19 45","* 5 36","+ 25 29","201","* 38 4","- 15 6","512","286","501","- 41 24","/ 44 20","467","381","* 27 22","72","735","- 26 12","695","818","/ 37 42","- 1 18","93","- 39 40","626","188","905","+ 21 7","608"}

    Returns: -4264

  43. {"- 6 36","/ 20 34","768","+ 15 28","+ 35 3","773","983","629","+ 22 18","/ 17 21","363","+ 47 31","/ 33 25","+ 12 44","132","576","* 2 43","735","/ 38 1","577","* 26 37","279","/ 10 32","615","348","987","932","* 45 13","- 9 40","/ 48 7","* 14 4","* 27 41","+ 5 11","66","- 23 30","534","/ 19 8","/ 46 29","122","886","/ 24 16","762","616","788","123","+ 42 39","13","991","999"}

    Returns: 26465

  44. {"- 24 23","748","+ 4 29","403","- 1 9","+ 30 13","159","212","+ 31 45","597","189","- 46 35","* 27 2","+ 44 37","/ 16 10","/ 48 17","562","52","737","/ 40 38","163","918","45","+ 42 19","/ 18 41","+ 20 5","112","/ 8 21","745","- 43 11","35","824","844","- 39 25","510","/ 7 33","* 3 12","* 26 47","* 14 36","1000","29","* 34 6","916","400","* 22 28","210","798","/ 15 32","468"}

    Returns: 31646

  45. {"/ 46 12","834","328","/ 4 27","700","/ 25 47","- 15 42","- 19 30","531","275","- 35 1","62","392","911","+ 26 21","- 45 17","334","479","- 16 41","- 38 37","840","41","698","/ 28 32","829","+ 14 34","/ 24 36","932","+ 10 29","146","236","731","305","465","- 43 20","+ 48 31","+ 2 3","995","/ 44 39","/ 23 13","/ 9 33","446","952","+ 22 8","+ 6 11","- 5 18","* 40 7","624","622"}

    Returns: -2040

  46. {"/ 2 24","459","779","- 34 22","384","682","837","512","693","- 41 21","/ 32 31","/ 33 7","100","+ 1 43","- 39 12","- 19 35","418","+ 48 11","/ 13 44","* 14 8","- 36 9","142","139","/ 4 40","- 3 37","- 20 6","903","627","+ 38 17","688","+ 46 10","* 42 18","749","607","- 47 26","* 45 30","- 16 5","- 28 23","257","166","/ 27 15","896","578","526","* 29 25","32","306","178","404"}

    Returns: -82080

  47. {"+ 36 14","* 4 10","+ 47 3","- 1 39","/ 29 38","367","- 20 33","/ 21 43","/ 30 13","/ 7 31","702","604","- 18 34","689","605","873","/ 5 22","982","* 2 25","354","* 32 24","- 11 17","+ 9 46","592","718","462","158","/ 42 6","+ 35 44","72","- 41 27","253","+ 28 16","639","834","- 23 48","+ 45 12","* 8 26","/ 37 19","84","439","23","/ 15 40","938","953","497","56","163","57"}

    Returns: 2730

  48. {"- 12 47","451","202","+ 19 17","323","* 25 33","348","* 38 32","663","- 13 8","/ 5 48","453","937","38","+ 26 44","273","/ 10 2","+ 9 30","687","464","+ 16 37","/ 35 46","/ 24 23","755","- 11 40","564","* 4 42","891","/ 22 20","+ 18 27","- 15 45","/ 7 29","77","/ 14 41","267","/ 3 43","830","404","- 34 1","+ 6 21","658","263","276","583","393","551","* 36 28","/ 31 39","347"}

    Returns: 1138

  49. {"- 10 45","237","+ 6 23","117","- 16 43","66","68","/ 41 5","148","/ 36 19","/ 26 39","877","242","629","40","727","638","- 33 13","* 14 42","- 28 20","/ 18 32","- 15 8","179","983","405","790","124","* 46 34","608","/ 27 25","528","211","* 31 30","- 38 3","+ 2 37","412","* 22 48","141","319","+ 40 7","+ 9 44","/ 1 29","- 4 24","743","- 11 35","430","/ 47 12","/ 21 17","626"}

    Returns: -26026

  50. {"/ 1 2","- 3 4","3","0","5"}

    Returns: -1

  51. { "- 1 2", "- 3 4", "1", "+ 5 6", "2", "1", "/ 7 8", "4", "* 9 10", "2", "2" }

    Returns: 2

  52. { "- 1 2", "5", "- 3 4", "2", "- 5 6", "3", "* 7 8", "4", "2" }

    Returns: -8

  53. { "* 1 2", "5", "/ 3 4", "3", "2" }

    Returns: 7

  54. { "* 1 2", "5", "+ 3 4", "3", "2" }

    Returns: 17

  55. { "/ 1 2", "4", "2" }

    Returns: 2

  56. { "+ 1 2", "+ 3 4", "+ 5 6", "5", "5", "5", "5" }

    Returns: 20

  57. { "* 1 2", "5", "* 3 4", "6", "+ 5 6", "10", "12" }

    Returns: 312

  58. { "- 1 2", "5", "+ 3 4", "5", "5" }

    Returns: 5


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: