iamtheky Posted April 26, 2016 Share Posted April 26, 2016 If you have at least 2 examples of the input and the output. What is the most efficient way to determine a common question for all examples, if there is? Solutions that add the possibility of even a second operation seem to make the problem much more difficult, for example: 50 "mathed by X" = 29 22 "mathed by X" = 15 it seems like getting to "divided by 2 plus 4" is tough to automate, but easy to come to just looking at it. ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
czardas Posted April 26, 2016 Share Posted April 26, 2016 (edited) Depending on the number of operators and operations included, there are likely to be a multitude of solutions in many (if not possibly all) solvable situations. I believe the general solution leads to infinite recursion. You may still be able to solve this for a small defined set of numbers and operations. Edited April 26, 2016 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
iamtheky Posted April 27, 2016 Author Share Posted April 27, 2016 (edited) in the confines of 2 operators (+ , /). does that make it easier? My thought is, that it is a pretty effective captcha - fairly easy to build questions (maybe even automate some random input output) that only has to be validated by executing the users answers to see if they are == and both return true. Edited April 27, 2016 by iamtheky ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
JohnOne Posted April 27, 2016 Share Posted April 27, 2016 Would it not be easier to generate all the info rather than two numbers and brute force the rest. Silly little unrefined example ... Global $Divisors[2] = [2, 4] $DividedBy = $Divisors[Random(0, 1, 1)] $Plus = Random(1, 9, 1) $Answer1 = Random(1, 100, 1) ConsoleWrite($Answer1 & " / " & $DividedBy & " + " & $Plus & " = " & $Answer1 / $DividedBy + $Plus & @LF) $Answer2 = Random(1, 100, 1) ConsoleWrite($Answer2 & " / " & $DividedBy & " + " & $Plus & " = " & $Answer2 / $DividedBy + $Plus & @LF) AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
RTFC Posted April 27, 2016 Share Posted April 27, 2016 (edited) I would suggest Simulated Annealing (link in sig, adapt example 1). But as czardas already pointed out, the fundamental issue here is non-uniqueness. Your present example is underdetermined. So you'd need several more given solutions to uniquely resolve for two operators and two values. Not sure that would still make a quick captcha then. Edited April 27, 2016 by RTFC My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
czardas Posted April 27, 2016 Share Posted April 27, 2016 (edited) For a brute force approach (two operations / & +): find all the prime factors of the smaller number, reject the ones that are not also prime factors of the larger number, start in the mid-range of the remaining factors and do the division, test the difference for both numbers. The difference will be either greater, less or nothing. Decide which factor to test next based on the previous result. You can quit at the point when one difference suggests you aim higher and the next adjacent factor suggests you aim lower, in which case there is no solution. Once you have a solution add on the difference, it is either the target or (once again) there is no solution. This gives a rough outline at least. Edit: I forgot one very important detail - - some multiples of prime factors may also turn out to be factors common to both numbers, so they also have to be considered. If all factors common to both numbers are in ascending sequence, then the above binary-search-type method should do the trick. Edited April 27, 2016 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now