A Math problem for brain surgeons

Give a function so X can be transformed to Y? Where;

If X is 5; Y should be 4
If X is 6; Y should be 3
If X is 7; Y should be 2
If X is 8; Y should be 1

For example;
You can say (Y = X-1) is such a formula. If we plug it in:

5-1 = 4 (Correct)
6-1 = 5 (Nop)
7-1 = 6 (Nop)
8-1 = 7 (Nop)

So, is there a formula that will do this transformation?

I came up with one but its too tedious. I am sure the brain surgeons of gupshup can do better! :slight_smile:

can you tell us if it is linear, quadratic, cubic, etc?

unless you want people to make pure luck for a mathematical problem

Easy Peasy…

Y = 9 - X

Okie so does that qualify me as a brain surgeon???

http://www3.pak.org/gupshup/smilies/tongue.gif


May The Madness Be Upon You!!!

HAHAHAHAHA

So much for me thinking it was a brain teaser!!!

Maddy the official brain surgeon of C&A!!

Hmcq -- hahahahah can't stop laughing.

LOL!

Maddy you drained the suspense out of it! I was hoping a few more questions like hmcq. :-P

You want to know what my computer science teacher came up with, when I asked him?

i admire ishmart kakiz…

http://www3.pak.org/gupshup/smilies/tongue.gif

http://www3.pak.org/gupshup/smilies/ok.gif

God bless u all…

DerVaisH


din bher ki sab batein saray kaam tumharay naam…
jab se likhi hai mein ne har ik shaam tumharay naam…
duniya ke baazar mein apni, kia Qeemut hai phir bhi…
jo bhi mil saktay hon mere, daam tumharay naam

Aww soo sorry to spoil your fun ahmedjee

http://www3.pak.org/gupshup/smilies/biggrin.gif

Maybe you can post another one???
And pray tell what did your teacher come up with???


May The Madness Be Upon You!!!

As per my teacher;


if (X >= 5) && (X <= 9)
Y = X - (((X mod% 5) << 1) - 1);

Those who are not familiar with C code, here is the explaination:

The method is to first x mod 5, then multply it by 2 and then subract 1 from it. And then subtract the result from original X. :-P

Hehe! Correct but an overkill!

It just proves that its not the question but how you ask it that matters. He was laughing like hmcq when I told him the simpler version. Phew! He wasn't mad.

p.s: The modulus (mod), or remainder, divides number1 by number2 and returns only the remainder as result!

Believe it or not…thats wht I thought of first…
This is what happens when you get too technical about life!!!

http://www3.pak.org/gupshup/smilies/hehe.gif


May The Madness Be Upon You!!!