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. Soaps
    mydlo_1 Each box has the same number of soaps. A quarter of all boxes contain only white soaps, and in each of the remaining 120 boxes there are always half the white soaps and half the green. White soaps total 1200. (a) the number of all soap boxes; (b) the sma
  2. Garden
    garden_1 Area of square garden is 4/5 of triangle garden with sides 24 m, 15 m and 15 m. How many meters of fencing need to fence a square garden?
  3. Triangles
    triangles_18 Hanka cut the 20 cm long straws into three pieces each piece had a length in cm. Then, with these three pieces, she tried to make a triangle. a) What circuit has each of the triangles? b) How long can the longest side measure? c) How many different trian
  4. Forestry workers
    forestry_workers In the forest is employed 43 laborers planting trees in nurseries. For 6 hour work day would end job in 35 days. After 11 days, 8 laborers go forth? How many days is needed to complete planting trees in nurseries by others, if they will work 10 hours a da
  5. Trapezoid MO
    right_trapezium The rectangular trapezoid ABCD with right angle at point B, |AC| = 12, |CD| = 8, diagonals are perpendicular to each other. Calculate the perimeter and area of ​​the trapezoid.
  6. A cylinder
    string A cylinder 108 cm high has a circumference of 24 cm. A string makes exactly 6 complete turns around the cylinder while its two ends touch the cylinder's top and bottom. (forming a spiral around the cylinder). How long is the string in cm?
  7. Four numbers
    equilateral_triangle_5 The first number is 50% second, the second number is 40% third, the third number is 20% of the fourth. The sum is 396. What are the numbers?
  8. Pool
    pool If water flows into the pool by two inlets, fill the whole for 18 hours. First inlet filled pool 10 hour longer than second. How long pool is filled with two inlets separately?
  9. School
    ziaci_6 Less than 500 pupils attend school. When it is sorted into pairs, one pupil remains. Similarly, when sorted into 3, 4, 5 and 6 members team one remains. Sorted to seven members teams, no left behind. How many pupils are attending this school?
  10. Girls
    skola_10 The boys and girls in the class formed without the rest of the fives, 2 girls and 3 boys. There are 6 girls missing to create mixed pairs (1 boy and 1 girl). How many girls are in the classroom?
  11. Bridge cards
    cards2 How many bridge hands are possible containing 4 spades,6 diamonds, 1 club, and 2 hearts?
  12. Candy and boxes
    cukriky_13 We have some number of candy and empty boxes. When we put candies in boxes of ten, there will be 2 candies and 8 empty boxes left, when of eight, there will be 6 candies and 3 boxes left. How many candy and empty boxes left when we put candies in boxes of.
  13. Together
    work_1 If 8 men, 10 women, 16 children collects ₹1024 in 4 days, how many days will be required for 6 men, 5 women and 4 boys to collect ₹768? (₹ is Indian Rupee)
  14. Brick
    brick One brick is 6 kg and half a brick heavy. What is the weight of one brick?
  15. House numbering
    byty_1 The residential house has three entrances numbered even numbers, successive immediately behind. The sum of the two numbers on the outside entrances is 68. Calculate the middle of these three numbers.
  16. Snacks
    skola_9 The school attends 344 pupils. Half of them take snacks. 13 pupils who took snacks did not attend school. How many snacks left?
  17. Repair pipe
    workers_39 20 workers had to repair broken pipes in 30 days. After fourteen days, four laborers joined them. How long did the pipe repair work last?