Logik game

Letter game Logik is a two player game, which has the following rules:
1. The first player thinks five-letter word in which no letter is not
repeated.
2. The second player writes a five-letter word.
3. The first player answers two numbers - the first number indicates how many letters written word coincides with the imaginary word, and is also on the correct position; the second number indicates how many letters written word is contained in the imaginary word, but is not the right place.
4. Steps 2 and 3 are repeated until the second player imaginary word guess.
Recording one game of two friends looked like this:
SONET 1 2
MUDRC 0 2
PLAST 0 2
KMOTR 0 4
ATOLY 1 1
DOGMA 0 2

The next move was meant by the word guessed. Determine which word
it was.

Note:
Our presented solution contains a program in PHP language, which will solve the given combination of letters - by brute force, quickly and painlessly.

Result

x = (Correct answer is: STROM) Wrong answer

Solution:

x = STROM
function match($s1, $s2, $q, $w)
{
    $a = $b = 0;
    for($i=0;$i<5;$i++)
    {
        if($s1{$i} == $s2{$i})
        {
            $a++;
        }
        else
        {
            $b += strpos($s2, $s1{$i})!==false;
        }
    }

    return $a == $q && $b == $w;
}

for($a=65; $a<91; $a++)
{
    for($b=65; $b<91; $b++)
    {
        for($c=65; $c<91; $c++)
        {
            for($d=65; $d<91; $d++)
            {
                for($e=65; $e<91; $e++)
                {
                    $s=chr($a).chr($b).chr($c).chr($d).chr($e);
                    if(!match($s,"SONET", 1, 2)) continue;
                    if(!match($s,"MUDRC", 0, 2)) continue;
                    if(!match($s,"PLAST", 0, 2)) continue;
                    if(!match($s,"KMOTR", 0, 4)) continue;
                    if(!match($s,"ATOLY", 1, 1)) continue;
                    if(!match($s,"DOGMA", 0, 2)) continue;

                    echo $s;
                    exit;
                }
            }
        }

    }
}








Leave us a comment of example and its solution (i.e. if it is still somewhat unclear...):

Showing 0 comments:
1st comment
Be the first to comment!
avatar




Would you like to compute count of combinations? See also our permutations calculator.

Next similar examples:

  1. Hockey players
    players After we cycle five hockey players sit down. What is the probability that the two best scorers of this crew will sit next to each other?
  2. Numbers
    numbers_3 How many different 7 digit natural numbers in which no digit is repeated, can be composed from digits 0,1,2,3,4,5,6?
  3. Playing cards
    playing_cards How many possible ways are to shuffle 6 playing cards?
  4. Word
    words What is the probability that a random word composed of chars H, T, M, A will be MATH?
  5. Phone numbers
    old_phone How many 7-digit telephone numbers can be compiled from the digits 0,1,2,..,8,9 that no digit is repeated?
  6. Rectangles
    rectangles How many rectangles with area 3002 cm2 whose sides is natural numbers are?
  7. Shelf
    bookshelf.JPG How many ways are there to arrange 6 books on a shelf?
  8. Lock
    combination-lock Combination lock will open when the right choice of 3 numbers (from 1 to 25 inclusive) is selected. A. How many different lock combinations are possible? B. Is he combination lock named appropriately?
  9. School trip
    hostel_1 Class has 17 students. What different ways students can be accommodated in the hostel, where available 3× 2-bed, 1× 3-bed and 2× 4-bed rooms. (Each room has its own unique number)
  10. Toys
    toys 3 children pulled 12 different toys from a box. Many ways can be divided toys so that each children had at least one toy?
  11. Vans
    shuttlevan In how many ways can 5 shuttle vans line up at the airport?
  12. Pairs
    pair At the table sit 8 people, 4 on one side and 4 on the other side. Among them are 3 pairs. Every pair wants to sit opposite each other. How many ways can they sit?
  13. Subsets
    1venna_sets How many are all subsets of set ??
  14. Kids
    kids How many different ways can sit 8 boys and 3 girls in line, if girls want to sit on the edge?
  15. Chess
    sachovnica How many ways can select 4 fields on classic chess board with 64 fields, so that fields don't has the same color?
  16. 7 heroes
    7statocnych 5 heroes galloping on 5 horses behind. How many ways can sort them behind?
  17. Flags
    vlajka_cz How many different flags can be made from colors purple, yellow, red, white, blue, green, orange so that each flag consisted of three different colors?