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. Butter
    factory_butter At the Orville redenbocher popcorn factory there is a tank of artificial butter substitute which is 55 feet tall and 18 feet in diameter. How many gallons of artificial butter substitute can the tank contain?
  2. Garden
    garden_1 Area of square garden is 6/4 of triangle garden with sides 56 m, 35 m and 35 m. How many meters of fencing need to fence a square garden?
  3. 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.
  4. A truck
    truck_11 A truck departs from a distribution center. From there, it goes 20m west, 30m north and 10m west and reaches a shop. How can the truck reach back to the distribution center from the shop (what is the shortest path)?
  5. Cone 15
    cone_9 The radius of the base of a right circular cone is 14 inches and it's height 18 inches. What is the slant height?
  6. Sale discount
    penize_49 The product was discounted so that eight products at a new price cost just as five products at an old price. How many percents is the new price lower than the old price?
  7. Cube root
    30gon_1 Find cube root of 18
  8. 7 digit number
    numbers2_49 If 3c54d10 is divisible by 330, what is the sum of c and d?
  9. Stamps 2
    stamp_9 Dennis spent 34.15 on stamps. The number of .56 is 10 less than four times of stamps bought for .41. How many of each stamp did he buy?
  10. Supermarket 2
    pie_3 A supermarket had a buko pie sale. In the morning 2/3 of the pies were sold and in the afternoon 1/6 of the pies were sold. If 150 pies were left, how many pies had been sold? Show your solution.
  11. Parking
    cars_27 At a building parking, 245 spaces are for cars, 56 are for vans and the rest are for buses. If 14% of all parking spaces are for buses, how many parking spaces are there in the building? How many spaces are for buses?
  12. Transformer
    trafo Solve the textbook problems - transformer: a) N1 = 40, N2 = 80, U2 = 80 V, U1 =? b) N1 = 400, U1 = 200 V, U2 = 50 V, N2 =?
  13. Wiring 2
    cu_wire_3 Willie cut a piece of wire that was 3/8 of the total length of the wire. He cut another piece that was 9m long. The two pieces together were one half of the total length of the wire. How long was the wire before he cut it?
  14. Octane value
    fuel_7 I loaded 10L 95 octane gasoline and 5L 100 octane gasoline. What is the resulting octane value of the gasoline in the tank?
  15. Catering business
    cookies_4 Montealegre family has a catering business. In one birthday party, they charged their costumer 11,767.50 for a party of 90 persons and a service charge of 2,500.50. How much was the average cost per person? Please show your solution.
  16. Electric input power
    resistor_7 Solve problems related to electric power: a) U = 120 V, I = 0.5 A, P =? b) P = 200 W, U = 230 V, I =? c) I = 5 A, P = 2200W, U =?
  17. Two pumps
    pumps_4 Pump A takes twice as long to fill a tank than B . Together they take 2 hours to fill the tank. How long does each one take to fill the tank by itself?