Prázdny
Prázdny

Task 3 was revealed 16.10.2024 at 18:00 CET

Login required

*

 

Available from 16.10.2024 18:00 CET until 17.10.2024 17:59 CET - You can get 3 points

*

The Golden Claw

 

 

You have reached the ancient Temple of Delphi, hidden in the mountains of Greece. After exploring dark tunnels and fighting enemies, you find a large stone door. Behind this door is the treasure you are looking for, but it will not open. There is no handle or lever to pull.

In front of you, on the ground, there is a number of pillars with `m` faces each. The pillars form a pyramid. On the door, there is also a pyramid structure sketch, with the same faces. After deciphering an elven description, you know what you have to do:

 

The pillars on ground must show the same face with the corresponding sketch on the door. However, each time you rotate a pillar, all the adjacent pillars below them rotates the same way also, cascading to the bottom of the pyramid.

 

Example:

 

Sketch on the door:

           1

           2 1

          3 1 0

 

Pillars on the ground:

            2

           1 1

          3 3 2

 

The pillar on the top has to be rotated 1 time counter clockwise (-1). Doing so will rotate all the other pillars resulting to:

            1

           0 0

          2 1 1

 

!! Notice, the 2nd pillar of the 3rd row moves 2 times.

Then, rotate the 1st pillar of the 2nd row 2 times clockwise (2).

            1

           2 0

          0 3 1

 

Problem input:

    The initial and target pyramid are given in the form of an array with length `n`. Also the number of faces `m` in each pillar are given

    For the above example, the configuration would be:

        faces = 4, initial = [2 1 1 3 3 2], target = [1 2 1 3 1 0],

 

0 < n < 10^8 (The pyramid will always have a full final row)

2 < m < 10

 

The solution should be an array of the same length as the input, giving how much the pillar should be rotated. (Only the manual rotation should be considered for the response, not the automatic cascading rotation).

    For the above example, the response would be:

        result = [-1 2 1 3 1 -2]

 

Clarification:

The input configuration for the exercise is given in the form of a text file with the following format:

4

2 1 1 3 3 2

1 2 1 3 1 0

 

Where the first row is the number of faces, the second row is the initial configuration, and the third row is the target configuration.

 

The output should be in the format:[-1, 2, 1, 3, 1, -2]

 

Hint: Write your algorithm for the first two configurations first and then write the code that reads the input file and apply the algorithm to all configurations of the file.

 

 

 

 

Your task

Read input file and into the field with the answer, enter :

  • the resulting values for every case, each on a new line
  • the country, which the story refers to
  • at the end paste the source code of your program.

Click here to download the Task 3 Input File

 

 

~~~~~~~~~~~~~~~~~~~~~~~~~

  

Answer

Greece

 

There are many correct answers.

Here is one of the possible correct answers, but because pillars can rotate to the right and to the left and both direction can move to the right position, the are many correct of combinations. Here is one of them:

[1, -1, 0, -2, 0, -1]

[1, -1, 2, 1, -1, 1]

[2, -2, 1]

[-1, -1, 0, 2, 0, 0]

[1, 4, 1]

[1, 0, 0]

[0, 0, 0]

[1, 0, -1, 1, 0, 0, 1, -1, -1, 0]

[3, 1, -3]

[0, 0, 1]

[0, 0, 1, -1, 0, -1]

[2, -2, 0, -3, 1, 0]

[3, -2, 5]

[1, -2, 0, 0, 0, 1, -1, -2, 0, 2]

[0, 0, 0, -1, 1, -1]

[0, -1, 1, -1, 0, -1, 1, 0, -1, 0]

[1, -3, -1, -1, 2, 1]

[1, 2, -1]

[1, 0, -3, -1, 0, -2, 0, -1, -2, -1]

[-1, 0, -1, 1, 0, -1]

[1, 3, -3, -1, -2, -1, 1, 3, -2, 1]

[-1, 0, 0]

[0, 2, -1]

[0, -1, -2, 0, 2, 0, -1, 2, -1, 0]

[3, 0, -1, 4, 2, 0]

[-3, -1, 3]

[1, 1, 2, 0, 0, 1, -1, 1, -1, -1]

[-1, 0, 1]

[-1, 0, 0]

[2, 2, 3]

[-3, -1, 0, 0, -1, 1]

[0, -1, 1, 0, 0, 1, -5, 4, 1, 0]

[-1, 1, 0, 1, 1, 0]

[0, 0, 0, 1, -1, -1, -1, 0, 1, 1]

[0, 0, -1]

[-1, 0, 1, 0, 0, 0, 0, 0, -1, 0]

[-1, 3, 1, 0, 1, 0, 1, 1, -1, 1]

[-2, 2, 0, 2, 1, 0, -2, 3, 1, 0]

[0, 2, -3, -3, 0, -1, 1, -1, 2, 0]

[1, 1, -1, 0, 0, 1, 0, 1, 0, -1]

[0, 0, 1, 0, 2, 3, 4, -2, -1, -2]

[-1, 1, 0, -2, -1, 0]

[-2, 0, -4, -2, 3, -1, -1, 1, -1, 0]

[-1, -1, 0, 1, 0, -1, 0, 0, 0, 0]

[-3, 0, 4]

[0, 0, 1]

[0, -1, 0, 0, 0, 0, 0, 0, 0, 1]

[0, -1, -1, 0, -1, 0]

[2, 2, -2, 1, 0, -1]

[-1, 0, -2, 4, 0, 3]

[-1, 0, 0]

[-2, -1, -2, -2, 1, 4]

[-3, 3, -2, 1, 2, -2, 0, 0, 0, -3]

[0, -1, 1, 0, 1, 1, 0, 1, 1, 0]

[0, -1, 2]

[-4, 0, -2]

[3, 4, -4, -3, 0, -2]

[1, -1, -3]

[1, 1, -1]

[-1, 0, 2]

[0, 0, 0]

[3, -2, 1]

[3, 2, -2, -1, 2, 0, -3, 1, 0, -2]

[0, 0, 2, 1, 0, 3]

[3, 0, -1, 3, -1, -2]

[-1, -5, 1, -3, 1, 3, 1, -2, 5, 0]

[4, 3, 1, 2, 2, -2, -3, -2, -1, -2]

[1, -1, 0, -2, -1, 0]

[0, 0, 2]

[-1, 1, 1, 0, -1, 1]

[0, -2, 4]

[1, 0, 1, 2, 1, -2]

[-1, -5, 1]

[-4, -4, 1]

[1, 0, 1, 0, -1, 0]

[0, -1, -3]

[1, 1, 2]

[-2, -2, -1, 5, 2, 2]

[1, 0, 0, 1, 1, 0, 1, 0, 0, 1]

[-2, 1, 1, -2, 1, 1, 0, 1, -1, 0]

[-1, -2, 3]

[1, 0, 0, -1, 0, 0]

[1, 2, -1]

[1, 0, -1, 0, -1, -1]

[1, 0, 1]

[1, 0, 0, 0, 0, -1, 1, 0, -1, 0]

[0, -3, -4]

[1, 2, 0, 0, 2, 2, 1, 0, -1, 1]

[-1, 0, 1]

[-1, -1, 2, 3, 0, 0]

[-1, 1, -1]

[0, 1, -1, 0, 0, -1]

[0, -1, 1, -1, -1, 0]

[2, -1, -2]

[0, -2, 0]

[-1, 0, 2, -2, 2, 1]

[0, -5, 0, -3, -1, -3, 3, 3, -3, -1]

[2, 1, 0, -1, -1, 1]

[1, -2, 2, 2, 1, -1]

[0, 0, -1, 0, 0, -2]

[2, 5, -6, 2, 0, 1, 0, 9, 8, 3, 0, -6, 1, -1, 2, 1, 4, 0, 3, -6, 0, -7, 3, 0, 4, 6, 1, -5, 4, -7, -1, -4, 3, -5, 1, -1, 0, 5, 4, -7, 4, -2, 9, 0, -5, 1, 4, -1, 5, 2, 7, 1, 3, -1, -3, -2, -2, -2, -1, 2, -2, -4, -1, -4, -2, 0, 0, -9, 1, -5, -2, -5, -6, 5, -1, -8, 0, -5, 4, -1, 1, -6, 2, 1, 2, 8, 2, -1, -2, -1, 2, 5, 2, 2, 2, 1, 7, 4, 0, -2, -2, 0, -4, -1, 1, 0, -2, 7, -4, -1, -1, 5, -6, 1, 5, 5, -3, -1, 5, 0, -2, 6, -7, 0, 5, -1, 4, -6, -3, -5, -1, 2, -5, -1, 2, 5, -1, -6, -6, -3, 2, -8, -6, -2, 4, 5, 0, 5, -1, 2, -1, -8, 0, -4, -8, -4, 1, 0, 4, 4, 4, 2, 3, 3, -4, -4, 1, 0, -6, 0, 1, -5, -3, 0, 4, 9, -2, 9, 1, -5, 1, -6, 1, 2, 4, -3, -8, -2, 1, 4, 0, 0, -1, -6, 4, 1, 2, 3, -5, 1, -2, 0, 0, -4, -2, -8, 0, 4, 5, -2]

 

We accepted also the answers, that input 2 faces and 10 faces is out of the conditions.

 

     

Points

Correct answer

Country

Source Code

Round 1

1

1

1

Round 2

2

1

1

Round 3

3

1

1

Round 4

4

1

1

Round 5

5

1

1

                 

 

Bonus points 

Quick and correct answer

 

Round 1

5

4

3

2

1

       

Round 2

                 

Round 3

7

6

5

4

3

2

1

   

Round 4

8

7

6

5

4

3

2

1

 

Round 5

9

8

7

6

5

4

3

2

1