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. Password
    codes The voltage station is every day changing the master password, which consists of three letters. Code generation process does not change and is based on the following procedure: The following letters (A) to (I) correspond to different numbers from 1 to 9. I
  2. Word MATEMATIKA
    math_1 How many words can be created from the word MATEMATIKA by changing the order of the letters, regardless of whether or not the words are meaningful?
  3. Digits
    numbers2_18 How many natural numbers greater than 4000 which are formed from the numbers 0,1,3,7,9 with the figures not repeated, B) How many will the number of natural numbers less than 4000 and the numbers can be repeated?
  4. Eight blocks
    cuboids Dana had the task to save the eight blocks of these rules: 1. Between two red cubes must be a different color. 2. Between two blue must be two different colors. 3. Between two green must be three different colors. 4. Between two yellow blocks must be four
  5. Rhombus 29
    rhombus3_2 One of the diagonals of a rhombus is equal to a side of the rhombus. Find the angles of the rhombus.
  6. Dice
    dices2_4 We throw five times the dice. What is the probability that six fits exactly twice?
  7. Combinations of sweaters
    sveter I have 4 sweaters two are white, 1 red and 1 green. How many ways can this done?
  8. Phone numbers
    old_phone How many 9-digit telephone numbers can be compiled from the digits 0,1,2,..,8,9 that no digit is repeated?
  9. Three-digit numbers
    poker_hand_ranking How many three-digit numbers are from the numbers 0 2 4 6 8 (with/without repetition)?
  10. Hockey match
    football_2 The hockey match ended with result 3:1. How many different storylines may have the match?
  11. Salami
    salama How many ways can we choose 5 pcs of salami, if we have 6 types of salami for 10 pieces and one type for 4 pieces?
  12. Competition
    sutaz 15 boys and 10 girls are in the class. On school competition of them is selected 6-member team composed of 4 boys and 2 girls. How many ways can we select students?
  13. Desks
    desks A class has 20 students. The classroom consists of 20 desks, with 4 desks in each of 5 different rows. Amy, Bob, Chloe, and David are all friends, and would like to sit in the same row. How many possible seating arrangements are there such that Amy, Bob, C
  14. Trainings
    tenis The table contains tennis training schedule for Saturday's younger students during the winter indoor season. Before the start of the summer season is preparing a new training schedule. Tomas Kucera will be able to practice only in the morning, sisters Kova
  15. Toys
    toys 3 children pulled 9 different toys from a box. Many ways can be divided toys so that each children had at least one toy?
  16. Test points
    test_2 If you earned 80% of the possible 40 points, how many points did you miss to get 100%?
  17. Dices throws
    dices_4 What is the probability that the two throws of the dice: a) Six falls even once b) Six will fall at least once