All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Logic
Covert Quantity VI (Posted on 2022-11-22) Difficulty: 3 of 5
+-----------+---------+
| 1 4 6 7 3 | R R R B |
+-----------+---------+
| 0 2 6 3 7 |  B B B  |
+-----------+---------+
| 6 9 3 0 8 |    R    |
+-----------+---------+
| 5 6 0 7 3 |   R R   |
+-----------+---------+
| 5 9 4 1 8 |   R B   |
+-----------+---------+
Each of the rows of the table given above indicates an attempt to find out the secret number.

• Each key has, in the column to the right has the letters R and B.
• Each R indicates that this digit has one digit common with the secret number, but in a different position.
• Each B indicates that the number has one digit common with the secret number in the same position.

Determine the secret number, given that the 3-digit number constituted by concatenating the last three digits (reading left to right) is a prime number.

See The Solution Submitted by K Sengupta    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution (spoiler) | Comment 1 of 5
 1 4 6 7 3 | R R R B 
 0 2 6 3 7 |  B B B  
 6 9 3 0 8 |    R    
 5 6 0 7 3 |   R R   
 5 9 4 1 8 |   R B   

The program below reads the above file and tests all the combinations.

clc, clearvars
fid=fopen('c:\VB5 Projects\flooble\covert input vi.txt','r');
for i=1:5
   l=fgetl(fid);
   l=erase(l,' ');
   ix=strfind(l,'|');
   trial{i}=l(1:ix-1);
   clues{i}=l(ix+1:end);
end
fclose(fid);
for n=0:99999
   ctok=0; tt=false(1,5);
   good=true;
   s=char(string(n));
   if length(s)<5
      s=['00000' s];
      s=s(end-4:end);
   end
   for i=1:5
      trialC=trial{i};
      did=false(1,5); 
      bCount=0; rCount=0;
      for p=1:5
         if s(p)==trialC(p)
            bCount=bCount+1;
            did(p)=true;
      %     trialC(p)=' ';
         end
      end
      for p=1:5
        if ~did(p)
         f=strfind(trialC,s(p));
         if f           
            rCount=rCount+1;
            trialC(f(1))=' ';
         end
        end
      end
      result=[repmat('R',1,rCount) repmat('B',1,bCount)];
      if ~isequal(result,clues{i})
         good=false;
         break
      else
        ctok=ctok+1;
        tt(i)=true;
      end
   end
   if ctok>4  && isprime(str2double(s(3:5)))
      disp([n ctok])
      disp(tt)
   end
end

It finds the answer as 42617.  Without the prime restriction, it would also find 12437.

The commented line in the program (led by %) has do do with handling duplicates, but was not really needed due to lack of duplicates in the hidden number.

  Posted by Charlie on 2022-11-22 10:26:33
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (6)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information