You are viewing a single comment's thread. Return to all comments →
In line 3, I'm storing the results of X>Y, X==Y, X<Y in $result as an array. If the result is (1, 0, 0) -> print 'X > Y' (0, 1, 0) -> print 'X == Y' (0, 0, 1) -> print 'X < Y' Let's define a function that maps the tuple into an integer offset f(1, 0, 0) = 0 // "X > Y" i.e. ${answers[0]} f(0, 1, 0) = 1 // "X == Y" i.e. ${answers[1]} f(0, 0, 1) = 2 // "X < Y" i.e. ${answers[2]} So we can see that f(x, y, z) = x*0 + y*1 + z*2 = y+2z
Seems like cookies are disabled on this browser, please enable them to open this website
Comparing Numbers
You are viewing a single comment's thread. Return to all comments →