Question: need help with my cs program In Countdown numbers game: * Players are given six integer numbers and a target integer number * The six

need help with my cs program

In Countdown numbers game:

* Players are given six integer numbers and a target integer number

* The six numbers should be combined using the mathematical operators + - * and / in a way that gets as close as possible to the target number. Each number can only be used at most once, but it is okay not to use a number

* Getting the target number is worth 10 points, getting within 5 of the target is worth 7 points, getting within 10 is worth 5 points.

Evaluating numeric expressions

implement a function evaluateCountdown that takes a string containing a mathematical expression written in Reverse Polish Notation, and returns the result of evaluating the expression, as a double.

RPN expressions can be evaluated by making a stack of numbers (using e.g. a vector), splitting the input string by spaces into tokens, and working through it one token at a time

After going through all the tokens, the answer is then on the top of the stack: return it.

Solving countdown problems

Implement a function solveCountdownProblem that takes a vector containing 6 numbers, and a target number; and returns a CountdownSolution object containing the solution to the problem that gets as close as possible to the target.

provided code:

#ifndef COUNTDOWN_H

#define COUNTDOWN_H

#include

#include

#include

std::string intToString(const int x) {

std::ostringstream str;

str

return str.str();

}

class CountdownSolution {

private:

std::string solution;

int value;

public:

CountdownSolution() : solution(), value(0) {}

CountdownSolution(const std::string & solutionIn, const int valueIn)

: solution(solutionIn), value(valueIn) {

}

const std::string & getSolution() const {

return solution;

}

int getValue() const {

return value;

}

};

// Do not edit above this line

// TODO: write code here:

#endif

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!