-
Grand Future Air Dried Fresh Beef Dog Food
Air Dried Dog Food | Fresh Beef

Carnivore Diet for Dogs

Go Back   Automotive Forums Car Chat > Coffee Break (Off-Topic) > COMPLETELY off-topic
Register FAQ Community
COMPLETELY off-topic Talk about anything other than cars. But you can't be mad and angry in this forum!
Reply Show Printable Version Show Printable Version | Subscription Subscribe to this Thread
 
Thread Tools
  #1  
Old 07-08-2004, 01:00 PM
2Slow4U_Noob 2Slow4U_Noob is offline
AF Enthusiast
 
Join Date: May 2004
Posts: 535
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to 2Slow4U_Noob Send a message via Yahoo to 2Slow4U_Noob
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.
Reply With Quote
  #2  
Old 07-08-2004, 01:14 PM
boingo82's Avatar
boingo82 boingo82 is offline
Can't polish a turd.
 
Join Date: Oct 2001
Posts: 3,067
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Reply With Quote
  #3  
Old 07-08-2004, 01:19 PM
Jet-Lee's Avatar
Jet-Lee Jet-Lee is offline
Banned
 
Join Date: Apr 2004
Posts: 2,580
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Jet-Lee Send a message via Yahoo to Jet-Lee
Re: Math puzzler

If X = "25" And _
Y = "7"Then
Set X = "7" And_
Set Y = "25"
End If

hehehe...how's that?
Reply With Quote
  #4  
Old 07-08-2004, 01:25 PM
psychobadboy's Avatar
psychobadboy psychobadboy is offline
AF Enthusiast
 
Join Date: May 2004
Posts: 1,317
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to psychobadboy
Re: Math puzzler

25 and 7 were example numbers. That wouldn't work for other values of x and y.

I'm working on it...
__________________
My Car
Reply With Quote
  #5  
Old 07-08-2004, 01:27 PM
2Slow4U_Noob 2Slow4U_Noob is offline
AF Enthusiast
Thread starter
 
Join Date: May 2004
Posts: 535
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to 2Slow4U_Noob Send a message via Yahoo to 2Slow4U_Noob
Re: Re: Math puzzler

Quote:
Originally Posted by boingo82
In the same equation? I don't think you are allowed to change the value of variables in an equation.

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
Reply With Quote
  #6  
Old 07-08-2004, 01:28 PM
Raz_Kaz Raz_Kaz is offline
AF Fanatic
 
Join Date: Jan 2004
Posts: 5,373
Thanks: 0
Thanked 0 Times in 0 Posts
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
Reply With Quote
  #7  
Old 07-08-2004, 01:29 PM
2Slow4U_Noob 2Slow4U_Noob is offline
AF Enthusiast
Thread starter
 
Join Date: May 2004
Posts: 535
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to 2Slow4U_Noob Send a message via Yahoo to 2Slow4U_Noob
Re: Re: Math puzzler

Quote:
Originally Posted by Jet-Lee
If X = "25" And _
Y = "7"Then
Set X = "7" And_
Set Y = "25"
End If

hehehe...how's that?

hahaha cheater I knew someone was goin to do that
Reply With Quote
  #8  
Old 07-08-2004, 01:38 PM
psychobadboy's Avatar
psychobadboy psychobadboy is offline
AF Enthusiast
 
Join Date: May 2004
Posts: 1,317
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to psychobadboy
Re: Math puzzler

Answer:
y=x-y
x=x-y
y=x+y
__________________
My Car
Reply With Quote
  #9  
Old 07-08-2004, 01:45 PM
2Slow4U_Noob 2Slow4U_Noob is offline
AF Enthusiast
Thread starter
 
Join Date: May 2004
Posts: 535
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to 2Slow4U_Noob Send a message via Yahoo to 2Slow4U_Noob
Re: Re: Math puzzler

Quote:
Originally Posted by psychobadboy
Answer:
y=x-y
x=x-y
y=x+y

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
Reply With Quote
  #10  
Old 07-08-2004, 01:51 PM
psychobadboy's Avatar
psychobadboy psychobadboy is offline
AF Enthusiast
 
Join Date: May 2004
Posts: 1,317
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to psychobadboy
__________________
My Car
Reply With Quote
 
Reply

POST REPLY TO THIS THREAD

Go Back   Automotive Forums Car Chat > Coffee Break (Off-Topic) > COMPLETELY off-topic


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -5. The time now is 09:07 PM.

Community Participation Guidelines | How to use your User Control Panel

Powered by: vBulletin | Copyright Jelsoft Enterprises Ltd.
 
 
no new posts