|
|
| Search | Car Forums | Gallery | Articles | Helper | Air Dried Fresh Beef Dog Food | IgorSushko.com | Corporate |
|
|||||||
| COMPLETELY off-topic Talk about anything other than cars. But you can't be mad and angry in this forum! |
![]() |
Show Printable Version |
Subscribe to this Thread
|
|
|
Thread Tools |
|
#1
|
|||
|
|||
|
Math puzzler
I was going to post a couple of riddles or puzzlers that I have heard, but I'm sure everyone has heard of them before so heres a math/computer question asked to me at an interview...I wasnt able to solve it right away but I got the job any because my cousin worked there
Puzzler: If you have two variables X and Y. What is the algorithm/How can you swap their values without using a third variable? EX: X=25 Y=7 how can you get X=7 and Y=25 without using another variable. |
|
#2
|
||||
|
||||
|
Re: Math puzzler
In the same equation? I don't think you are allowed to change the value of variables in an equation.
__________________
Just because offense is offered, does not mean you have to take it. |
|
#3
|
||||
|
||||
|
Re: Math puzzler
If X = "25" And _
Y = "7"Then Set X = "7" And_ Set Y = "25" End If hehehe...how's that? |
|
#5
|
|||
|
|||
|
Re: Re: Math puzzler
Quote:
Yes in the same equation. So if you were allowed to use an extra variable the answer would be something like this. Swapping X and Y Z=X X=Y Y=Z using numbers as an ex: X=25 Y=7 Z=0 1)Z=X so Z=25 2)X=Y so X=7 3)Y=Z so Y=25 and now X and Y have switched values without Z's help you cant do this because after X=Y or X=7 you would lose the value of X or 25 to give to Y Wow this was supposed to be just a lil teazer but i think its just making it clear that I'm a massive dork
|
|
#6
|
|||
|
|||
|
Re: Math puzzler
lol, close one there lee, but no cigar
logarithmes are gay, lol, I just finished school and here he comes with more school work
|
|
#7
|
|||
|
|||
|
Re: Re: Math puzzler
Quote:
hahaha cheater I knew someone was goin to do that
|
|
#9
|
|||
|
|||
|
Re: Re: Math puzzler
Quote:
Well done! I read ur profile and figured ud get it pretty soon Interests: Cars and computers Biography: Male computer engineering college student from Southern Cali |
|
![]() |
POST REPLY TO THIS THREAD |
![]() |
|
|