d*********1 发帖数: 25 | 1 Three registers: a , b , c and with three commands available:
a => c; ( a is allowed to store in c)
b => c; ( b is allowed to store in c)
a-c => a; ( a-c is allowed to store in a)
how to store b into a?
I know how to store -b to a so far ...
eg: a => c; then do 'a- c =>a'; we get a=0; then we can do 'b=>c' ; we can
get ; 0- b=>a; so a euqals b;
but i could not get b to a?
any thoughts? |
d*********1 发帖数: 25 | 2 **: 0- b=>a; so a euqals b;
correction; so a should be equal to -b; |
j*****4 发帖数: 292 | 3 a=>c
a-c=>a //a=0 now
b-c=>c
a-c=>a //a=-b
a=>c
a-c=>a //a=0,c=-b
a-c=>a
can
【在 d*********1 的大作中提到】 : Three registers: a , b , c and with three commands available: : a => c; ( a is allowed to store in c) : b => c; ( b is allowed to store in c) : a-c => a; ( a-c is allowed to store in a) : how to store b into a? : I know how to store -b to a so far ... : eg: a => c; then do 'a- c =>a'; we get a=0; then we can do 'b=>c' ; we can : get ; 0- b=>a; so a euqals b; : but i could not get b to a? : any thoughts?
|
d*********1 发帖数: 25 | |
l****o 发帖数: 2909 | 5 I see this question in GS interview and fortunately I solved it. |
d*******k 发帖数: 56 | 6 i wonder why we want to do it this way? can't it be something like this?
b ->c
then a - b ->a (as a - c->a)
then a - b ->c (as a ->c)
then a - (a - b) ->a (as a -c->a)
hence b -> a |
i*****r 发帖数: 1302 | |
C*O 发帖数: 389 | |
d*********1 发帖数: 25 | 9 Re:
b ->c
then a - b ->a (as a - c->a)
then a - b ->c (as a ->c)
then a - (a - b) ->a (as a -c->a)
hence b -> a |
d*******k 发帖数: 56 | 10 thanks. I got it wrong.
【在 d*********1 的大作中提到】 : Re: : b ->c : then a - b ->a (as a - c->a) : then a - b ->c (as a ->c) : then a - (a - b) ->a (as a -c->a) : hence b -> a
|
|
|
z****g 发帖数: 1978 | |
s****p 发帖数: 187 | 12 init: [a,b,c]
a=>c [a,b,a]
a-c=>a [0,b,a]
b=>c [0,b,b]
a-c=>a [-b,b,b]
a=>c [-b,b,-b]
a-c=>a [0,b,-b]
a-c=>a [b,b,-b] |
c*******6 发帖数: 24 | 13 b =>c
a-c =>a (a store a-b)
a =>c (c store a-b)
a-c =>a (a store b)
can
【在 d*********1 的大作中提到】 : Three registers: a , b , c and with three commands available: : a => c; ( a is allowed to store in c) : b => c; ( b is allowed to store in c) : a-c => a; ( a-c is allowed to store in a) : how to store b into a? : I know how to store -b to a so far ... : eg: a => c; then do 'a- c =>a'; we get a=0; then we can do 'b=>c' ; we can : get ; 0- b=>a; so a euqals b; : but i could not get b to a? : any thoughts?
|
s******i 发帖数: 132 | 14 (a b c)-> (a b a)->(0 b a)->(0 b b)->(-b b b)
->(-b b -b)->(0 b -b)->(b b -b)
I think the key is to notice that only b is useful information and one can
only put data in a thru a-c. Once you realize that, just try to set a to be
zero and c to be -b. |
S*******s 发帖数: 13043 | |
k***7 发帖数: 6 | 16 b=>c
a-c=>a
a=>c
a-c=>a |