Re: [algogeeks] pseudi hits and hits

2012-01-27 Thread Rujin Cao
A  little thought about this:

Since there are four colors Red, Yellow, Green, or Blue , we can use 2-bit
to represent each color, say

00 - Red
01 - Yellow
10 - Green
11 - Blue

so in total,  1 byte (unsigned char in C++) should be enough.


For the logic of detecting hits and pHits, the bit operation involved can
be the XOR, i.e.
the XOR result will be zero, if the two color are identical.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] pseudi hits and hits

2012-01-26 Thread Ashish Goel
The computer has four slots containing balls that are Red, Yellow, Green,
or Blue. eg RGYB or RRGB..
you as a user trying to guess it. You may for ex guess this as RRGY, if you
guess a color right at same position, it is a hit, however, if you guess
the colour there which is there in original solution(other than hits) but
at some other position is a pseudo hit. eg solution RGGB and guess is YRGB
then 2 hits and 1 pHit.
For each guess you are told the number of hits and pHits.
Given guess and solution, WAP to find the number of hits and pseudo hits.


This is simple, trying to using bit operations, somewhat writing wrong
stuff.

Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.