Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello everyone
So i need to make an AI that solves following task:
It has a target number(1-999), 4 random numbers (1-9) 1 random number from (10, 15, 25) and 1 random from (50,75,100)
Using 4 basic operations (+ - * /) and without repeating any number, make the target number (or the closest you can get). Concating digits isn't allowed (etc make 44 from 4 4). You don't have to use all the numbers you are given.



Does anybody have any idea on how to achieve this?

What I have tried:

I've tried the brute force approach- get every possible expression that can be made from those numbers and operators,and try to parse it's result as polish notation.
However, number of possible strings is extremly high and computer fails to do it in reasonable amount of time.
Posted
Updated 24-Apr-18 22:12pm

1 solution

This looks like homework, which we will not do for you.
It's also a very common homework task which is why a search-engine would have found you over 2 million options to look at.

You might like to start with this CodeProject article Countdown Number Puzzle Solver[^]
 
Share this answer
 
Comments
Maciej Los 25-Apr-18 4:28am    
5ed!
Member 12837306 25-Apr-18 6:52am    
its not a homework, i did not ask you to do it for me but to give some advice
of course i did search the search engines, don't treat me like an idiot sir.
thank you for the article you provided.
CHill60 25-Apr-18 7:23am    
If it's not homework it is certainly a set exercise. I was in no way treating you like an idiot, just pointing out that there are lot of resources out there. Unfortunately many members post their homework here expecting to find an instant solution or to have it written for them - I (we) get a bit jaded as a result. I apologise if I caused you offence.

If it helps I found the resources with the search text "target number with basic operations". I found the specific article reference by placing "CodeProject" at the end of my search string - something I always do to try and focus on articles found here. It's always worth a try.
Member 12837306 26-Apr-18 8:19am    
I've managed to solve this using the help from article you posted. thank you
CHill60 26-Apr-18 8:31am    
Great news! Thanks for letting me know

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900