hard code to solve

hey can anyone solve this problem ive been thinking about it for days but cant find a solution.

Project Description
You are given a certain number of matches (i.e., N matches) and you must find the number of different numbers that can be represented using the N matches. Assume that all numbers will be greater or equal to 0.
Consider the following table that illustrates how many numbers can be created with
matchstick based on the number of matchsticks given.

User Requirements
The input must be a sequence of positive integers in free format. For each N, 1 <= N <= 80, output the number of different (non-negative) numbers representable with <=N matches. Your answers will all be less than 262.

Software Requirements
 You must create a function called determineCount that returns nothing and
receives at least the user’s entry value in addition to any other item you deem
necessary to solve this problem. This function will display a sentence and series of digital numbers that can
be created based on the user entry as seen in the above figures.

if theres anyone who can give clues to solve this is would b appreciated.

here is how many matches sticks each number has
[0] = 6
[1] = 2
[2] = 5
[3] = 5
[4] = 4
[5] = 5
[6] = 6
[7] = 3
[8] = 7
[9] = 5

i have so far created an array to put how many sticks go in each number but i dont know where to begin my algorithm or how it would fit in the int

here are some answers for those wondering

3 matches should have 2 answers: 1,7
5 matches should have 10 answers: 1,2,3,4,5,7,9,11,17,71


so the answer overall should look like this

Enter the number of match sticks: 5

You can make 10 digital numbers from 5 match sticks as seen
below.

1 2 3 4 5 7 9 11 17 71

Last edited on
Start by creating the outermost layer of the program. Start by creating the function but not making it do anything just yet, and by setting up the input/output for the user.

Was it ever specified what they meant by represent and what arrangements of matchsticks are valid? There was a mention of a table, could you post that here or give us a link?

-Albatross
yea albatross sorry i didn't realize i didnt put some important things up i have created the output and input for the program and an array but i am stuck after that here is what i have so far.

#include <iostream>

using namespace std;

void determineCount(int numbersPar);

int main () {
//declarations


int usernum;

//get user input
cout << "Enter the number of match sticks: ";
cin >> usernum;
cout << endl;
determineCount(usernum);
cout << endl;


return 0;
}

void determineCount(int numbersPar) {
int numbers [10];
//calculations
numbers[0] = 6;
numbers[1] = 2;
numbers[2] = 5;
numbers[3] = 5;
numbers[4] = 4;
numbers[5] = 5;
numbers[6] = 6;
numbers[7] = 3;
numbers[8] = 7;
numbers[9] = 5;

//output

cout << "You can make " << amount << " digital numbers from " << numbersPar << " match sticks as seen below." << endl;
cout << endl;
Ohhh, I see. Oooh, this is a tricksy computational problem, isn't it? This reminds me of something from Project Euler.

The brute-force solution would be to iterate through numbers until you reach a point where any larger numbers would be impossible to compute. However, such a solution would take HORRIFICALLY long to compute (you'd need 40 digits for the lexically largest number, to put that in perspective a million requires only 7). You really don't want to take this approach.

So how do we cut down on that?

You can solve this problem without putting excessive strain on your computer by first determining the different sets of digits that you can get from a set of matchsticks, and then computing the the number of unique combinations of those. It may help to go from lower-costing digits to higher-costing digits, instead of from 0 to 9.

I won't give that much more help here because the challenge of the problem is not its implementation, and that would take the feeling of accomplishment once you solve it. ;)

-Albatross

now when you say determine the different sets of digits from the matchset do you mean how many different ways for 1 with 80 matches?
I mean what different digits can you get out of a set of matches.

For example, with five matches, you can get 1, two 1s, 2, 3, 4, 5, 7, 1 and 7, and 9.

-Albatross
i seee but the problem is that the matchsticks have to go up to 80 and finding all the different combinations for 80 would take a lifetime ;p unless i understood you wrong
Yes, ya missed something. :P

Again, I'd rather not give out too many hints. But think about ways you can save the computer compuational work (hint: organize the digits by their cost), and think of it from a perspective of "can I add this digit here" rather than "is this number feasible".

Or, see if you can find a different way of solving the problem. I have not solved this problem and am merely observing a way that I think it could be solved, but have not myself attempted.

-Albatross
so first declare the order of the numbers by there matchsticks and then go from highest to lowest by seeing if there are enough matchsticks
I get 6251654166345058316 possible numbers, including small numbers like "1". Quite expensive if you don't use something-something-oization.
i dont think im that far helios
From the original post:
jliusuwan wrote:
Your answers will all be less than 262.


Where is that number coming from? I'm getting 255 digital numbers with 11 matchsticks. I imagine 80 is off the charts. Is there some additional constraint in the problem?
Due to the fact that Albatross has stressed that the OP should solve this by themselves. I would like to offer a hint, the hint will be slightly encoded so that only those who want to see it will see it. It is a gibberish and leet like combo.
0u7dw4y a dp4y 0lutiOn5ay 0tn4y 3b4y 35tb4y?
dp4y
What??

Just use ROT13 like a normal person.
booradley sorry that 2^62.

guys please ive been thinking of a way to do this even with all your hints to find a solution but i cant even think of a way to start it is there anymore hints you guys could give me fyi this is my first programming class im still new to thinking outside the box and everything i need this program done in 24 hours
Topic archived. No new replies allowed.