# Help with a school project?

This topic is 4799 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey everybody. I'm fairly new to programming, but I would like to learn more about it. I've been reading some tutorials and books, and I've been progressing through some "childish" stuff. I do have a question, though. I have an extra credit project in one of my classes, and it could raise my grade significantly. To an A, to be exact...even if I fail the final. I need to make a DOS executable. It needs to be able to take five number fives and use any symbol to obtain a certain number. So say I have 5-5+5+5+5. That obviously equals 15. Or say I have 5x5x5x5x5 (3125). Or say I even have 5x5x5x5 divided by 5 (125). But, it gets more advanced. I'd have to be able to get a number by putting in 5 to the 5555 power (27,775). I need to be able to type in the target number and get the equation in return. How would I go about doing this? If I could get any input from anyone, I would greatly appreciate it...and so would my low grade in the class. Thanks. edit: I'm using Microsoft Visual C++ 6.0.

##### Share on other sites
People will probably be reluctant to help too much since this is for school, but I'm guessing you may find this quite tricky regardless.

I can't immediately think of an obvious way to reverse-engineer an equation like that from a number. There's another way to do it, though - precalculate the values of the equation for every permutation of operators, store the expression & value pairs somehow, and search through them when you need to find an appropriate expression for a given value. That's one possible strategy, and there's quite a few details for you to work out if you choose to follow it, like how you generate/evaluate the expressions and how you store/use the precalculated data.

There's quite a few permutations - it's the factorial of the number of operators. It looks like you are also allowing the omission of an operator, too, so you can have expressions like 5*55-555? And since I don't see any brackets in your expressions, I'm assuming you aren't using them? Brackets make things more complicated. So, you have +, -, /, *, ^ and an empty operator, which is 6. So, if you're not including brackets, you need to calculate 6! expressions, or 720. That kind of number is quite feasible to calculate when the app starts without anyone really noticing. If you do need to use brackets, you'll need to extend this rough design to accommodate them.

Good luck with it anyway :o) I expect you'll get some credit for it even if you don't get it all working perfectly, so long as you demonstrate some problem-solving skills.

the best way i can see and the previous person probibly covered this (by the way if you want to preserve the text structure for that tree then use // without the slashes). Ok what i would do i read in an equation then store it in a text file and a string, this alows you to do more with it. then parse through the file several times one time for each operator speed level ^ = 3* and / = 2+ and - = 1then do the operation to the numbers on either side of the equation so 6 ^ 2read it in then on the fist pass you find a ^ rewinde to the last number befor the ^ store it in a variable then go 2 chars ahead of that (the number after) and store it then do the ^ operation (whatever then function is in the math library (i dont know i dont use it much yet))and store it then print a | symbol before the number on the left side of the operator (this is in case of duplicates) now go throught the string find a the spot were the | is and delete 3 numbers/operators after that then print your new value at the spot right after the | then erase the | (and the space that it leaves if any) and this should give you a nice step by step brake down of how you solved the equation. this dose of course get slighty more complicated if you have bracets other then that though. If any questions about this method let me know. I havnt done this before i just made this up on the fly so use at own risk (i think ill try this some time) 
 0 
 Share this post Link to post Share on other sites 
 
 
 iMalc    2466 iMalc    2466 Contributor Member 2466 4264 posts Joined March 2004 Posted January 6, 2005 If you currently have a low grade, then to deserve an 'A' I'd say you should get stuck into it on your own, and do lots of thinking and research of your own.People here have given you enough to start on already.This website has a policy to not do people's homework for them. 0 Share this post Link to post Share on other sites 
 Sign in to follow this   Followers 0 
 Go To Topic Listing For Beginners Advertisement 
 Advertisement Popular Tags 2D 3D Advice Algorithm Animation C# C++ Design DX11 Environments Feedback GameMaker Gameplay General Java Learning Mobile Music OpenGL PC Pixel Python Unity Unreal VR Advertisement Popular Now 9 C++ Problems with shift left (<<) By lonewolff Started 9 hours ago 47 Singletons in game engine architecture By matt77hias Started Friday at 10:15 AM 11 Upvoting and Downvoting By francoisdiy Started Wednesday at 04:48 PM 17 Breaking into the Industry with a Bad Degree - Can it be Done? By rcrawford115 Started Tuesday at 03:57 PM 11 The fun of the last part of playing RTS By Pleistorm Started Tuesday at 01:12 PM Advertisement GDNet Discord Chat All Activity Home Forums Community For Beginners Help with a school project?