SWAPPING (HARD)

Post new topic   Reply to topic

View previous topic View next topic Go down

SWAPPING (HARD)

Post  SwitchCase on Wed Aug 13, 2008 4:01 pm

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 5:35 pm

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 7: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 5:27 pm

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 3:01 pm

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

ankurgutpa

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

View user profile

Back to top Go down

Re: SWAPPING (HARD)

Post  ish_mnnit on Wed Aug 20, 2008 4:13 pm

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 6: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 5:24 pm

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 Fri Sep 26, 2008 12:19 am

.......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 3:59 pm

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 11:06 pm

@amit
also for characters cheers

ankurgutpa

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

View user profile

Back to top Go down

View previous topic View next topic Back to top


Post new topic   Reply to topic
Permissions of this forum:
You cannot reply to topics in this forum