Sign in to follow this  
Followers 0
iamtheky

Finding the question

6 posts in this topic

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.


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by czardas

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by RTFC

Share this post


Link to post
Share on other sites

#6 ·  Posted (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 by czardas

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0