Computer Club MNNIT
Would you like to react to this message? Create an account in a few clicks or log in to continue.

SWAPPING (HARD)

+6
ish_mnnit
ankurgutpa
Admin
amazon
mnnit.rahul
SwitchCase
10 posters

Go down

SWAPPING (HARD) Empty SWAPPING (HARD)

Post  SwitchCase 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

Back to top Go down

SWAPPING (HARD) Empty Re: SWAPPING (HARD)

Post  mnnit.rahul 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

Back to top Go down

SWAPPING (HARD) Empty Re: SWAPPING (HARD)

Post  amazon Wed Aug 13, 2008 1:14 pm

coooooooooool raaaaahhhhuuuuuulllllllllll



oo spam abuse!!!!

amazon

Posts : 13
Join date : 2008-08-10

Back to top Go down

SWAPPING (HARD) Empty Re: SWAPPING (HARD)

Post  Admin 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

https://computerclub09mnnit.forumotion.net

Back to top Go down

SWAPPING (HARD) Empty Re: SWAPPING (HARD)

Post  ankurgutpa 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
ankurgutpa
ankurgutpa

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

Back to top Go down

SWAPPING (HARD) Empty Re: SWAPPING (HARD)

Post  ish_mnnit 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

Back to top Go down

SWAPPING (HARD) Empty Re: SWAPPING (HARD)

Post  sweetesh singh 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

Back to top Go down

SWAPPING (HARD) Empty Re: SWAPPING (HARD)

Post  gunendu 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

Back to top Go down

SWAPPING (HARD) Empty Re: SWAPPING (HARD)

Post  vikas 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

Back to top Go down

SWAPPING (HARD) Empty Re: SWAPPING (HARD)

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

works only for integers.......

amit.mall

Posts : 1
Join date : 2008-08-15

Back to top Go down

SWAPPING (HARD) Empty Re: SWAPPING (HARD)

Post  ankurgutpa Tue Sep 30, 2008 5:06 pm

@amit
also for characters cheers
ankurgutpa
ankurgutpa

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

Back to top Go down

SWAPPING (HARD) Empty 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