SWAPPING (HARD)

Go down

SWAPPING (HARD)

Post  SwitchCase on Wed Aug 13, 2008 10:01 am

NOW Ur task is still the same..

Except....
U r allowed only 3 statements..
And only one operator.

(PS: DONT BE SMART AND USE -(-b) as the same thing!!!!)

SwitchCase

Posts : 5
Join date : 2008-08-13

View user profile

Back to top Go down

Re: SWAPPING (HARD)

Post  mnnit.rahul on Wed Aug 13, 2008 11:35 am

a=a^b
b=a^b
a=a^b

mnnit.rahul

Posts : 16
Join date : 2008-08-10

View user profile

Back to top Go down

Re: SWAPPING (HARD)

Post  amazon on Wed Aug 13, 2008 1:14 pm

coooooooooool raaaaahhhhuuuuuulllllllllll



oo spam abuse!!!!

amazon

Posts : 13
Join date : 2008-08-10

View user profile

Back to top Go down

Re: SWAPPING (HARD)

Post  Admin on Sun Aug 17, 2008 11:27 am

rahul soltuion was cool but u know the above solution fails at a prticular test case ..............
find it out ? Very Happy

Admin
Admin

Posts : 39
Join date : 2008-08-03

View user profile http://computerclub09mnnit.forumotion.net

Back to top Go down

Re: SWAPPING (HARD)

Post  ankurgutpa on Wed Aug 20, 2008 9:01 am

well i think solution is correct
i 've tried for all test cases
+ +
+ -
+ 0
- 0
- -
it's working fine cheers
avatar
ankurgutpa

Posts : 44
Join date : 2008-08-10
Age : 31
Location : Tandon 72

View user profile

Back to top Go down

Re: SWAPPING (HARD)

Post  ish_mnnit on Wed Aug 20, 2008 10:13 am

rahul solution can also be written as--
a^=b^=a^=b
i think it shud also work

ish_mnnit

Posts : 4
Join date : 2008-08-10

View user profile

Back to top Go down

Re: SWAPPING (HARD)

Post  sweetesh singh on Wed Aug 20, 2008 12:08 pm

bhagalpur sir

ab aap hi bata dejie ki kis case me a^b wala soln fail ho rha hai???

sweetesh singh

Posts : 8
Join date : 2008-08-12

View user profile

Back to top Go down

Re: SWAPPING (HARD)

Post  gunendu on Wed Sep 24, 2008 11:24 am

xor(^) operator will fail when you will have carry in your addition..

gunendu

Posts : 2
Join date : 2008-09-24

View user profile

Back to top Go down

Re: SWAPPING (HARD)

Post  vikas on Thu Sep 25, 2008 6:19 pm

.......above method will fail when both variables are equal becase in that case xor operation will give zero.

vikas

Posts : 2
Join date : 2008-09-23

View user profile

Back to top Go down

Re: SWAPPING (HARD)

Post  amit.mall on Tue Sep 30, 2008 9:59 am

works only for integers.......

amit.mall

Posts : 1
Join date : 2008-08-15

View user profile

Back to top Go down

Re: SWAPPING (HARD)

Post  ankurgutpa on Tue Sep 30, 2008 5:06 pm

@amit
also for characters cheers
avatar
ankurgutpa

Posts : 44
Join date : 2008-08-10
Age : 31
Location : Tandon 72

View user profile

Back to top Go down

Re: SWAPPING (HARD)

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum