[Community Puzzle] A story to go in circles

https://www.codingame.com/training/easy/a-story-to-go-in-circles

Send your feedback or ask for help here!

Created by @Magicien-d-oz,validated by @bbb000bbbyyy,@Deltaspace and @Fireball0923.
If you have any issues, feel free to ping them.

@Magicien-d-oz
Le puzzle est sympa mais l’énoncĂ© n’est pas (assez) clair je trouve.

  • le point de dĂ©part n’est pas prĂ©cisĂ© et celui-ci compte comme un ‘move’
  • on ne sait pas si on doit tester toutes les cases par lesquelles on passe dans un ‘trip’ ou si on saute directement
  • on ne sait pas si la rotation compte comme un ‘move’
  • l’explication de la position ‘inchangĂ©e’ aprĂšs rotation est trĂšs trompeuse

J’ai perdu 1h sur ce dernier point car le hasard fait que les 3 premiers tests passent mĂȘme avec une mauvaise interprĂ©tation de cette rĂšgle.

1 Like

Salut,
Je suis content que le puzzle soit Ă  ton goĂ»t. Pour ces changements je vais m’y mettre tout de suite, tu as tout Ă  fait raison, c’est juste que lorsque l’on crĂ©er un puzzle cela semble tellement une Ă©vidence pour soi-mĂȘme que l’on croit que cela est Ă©vident pour tout le monde. Je vais donc le modifiĂ© et j’essayerai de te recontacter pour savoir si tu trouves l’énoncĂ©s plus claire.
Ton expĂ©rience et tes retours m’ont Ă©tĂ© prĂ©cieux, merci !
Magicien-d-oz

1 Like

Thanks for asking and the clearification. Please keep in mind not everyone using CG can speak/read French. Luckily the google translator was helping me out.

1 Like

@Magicien-d-oz

Thanks for the update.

To me, the latest rule is still unclear. I will try with an example :

  • let our position be (x, y)
  • the letter at (x, y) send us to (x’, y’) which is a ‘#’
  • because (x’, y’) is a ‘#’, we rotate the grid
  • my understanding was to keep the position ‘unchanged’, so (x, y), but actually the correct meaning is to keep (x’, y’)

Regards,

1 Like

Hello,

It seems that the validations tests are quite different from the tests we have. In one case, I got right answers on tests 1, 2 and 3 but I validated the validation 2, 3, 4. I changed the code (it was my mistake) and it passes again 1, 2, 3 but all the validations ones. I can share the code in private if someone wants to dig a bit more (in python 3).

I think it’s related to memoization of the position but not the grid angle but not able to find exactly the why.

Regards,
Nicolas

1 Like

Thankyou for fixing the puzzle. Drove me crazy last night. The original said we could end on a symbol (# @) so I counted every action. I couldn’t implement shortcuts until I knew test 2 & test 3 would pass. From there it was pretty well understood. The high range of ii added that little something that made this fun. It would be more interesting if the letters said something. shrug G/J

1 Like

I have sorted the logic in several different ways, strings, lists, dictionaries, etc. but I can’t optimise to pass 4th validation. I have tried recognising that there are only 4 possible rotations and tried a range of other options 
 ideas?

There is not enough cases to test the algorithm’s efficiency. There are no intermediate cases between the third and the fourth.

Bonjour,

Merci pour ce puzzle intĂ©ressant. Je rencontre des difficultĂ©s Ă  dĂ©boguer mon code pour le quatriĂšme test mais j’ai rĂ©ussi les trois prĂ©cĂ©dents.

En effet, quand j’affiche la taille de la grille avec le code fournit initialement, nb vaut 21845. Ne doit il pas ĂȘtre infĂ©rieur Ă  10 ? De plus je n’arrive pas a afficher les lignes de la grille.

Avez-vous une idée de ce qui ce passe ?
Merci

@victorallard Which language?
Note that you can check the testcases by clicking on the “Show testcases” icon at the top-right corner of the testcases box and test your code against custom testcases by activating SETTINGS > Mode > EXPERT.

I code in C++.
I know I can run my own tests but I can’t see what’s wrong in my code to test. If only I could see the inputs of the 4th test, I will be able to understand the problem.

@victorallard The 4th test or validator? As I said, you can see the tests.

Probably not related, but there was a problem in the generated code though, ii was declared as a 32-bit integer (int in C/C++) while it should be a 64-bit integer (long long in C/C++). I fixed the stub accordingly.
Edit: Oh actually that’s exactly your problem. Use long long instead of int for ii and it’ll do a proper parsing of both ii and nb.

Thank, you !
I can now debug my code.

I find the following rule confusing.

“-You start from the letter in the top left corner of the grid. This departure counts as a movement.”

What does ‘departure counts as a movement’ mean exactly? It seems to me that each “movement” is a departure. Is the “start” somehow automatically considered a movement? If I “start” at the top left, then there has been no departure yet.

@igibbs Have you “manually” simulated the ii = 123458 moves? :wink:

Thanks Niako, I figured out my problem with ‘Test 2’. Yes, I “manually” simulated with 123458 moves.

it means that when the first move to count is setting position to (0,0).
so if the number ii of displacements is 12 you’ll really move only 11 times.

for the test 2, when you are on “#” or a “@”, you have to rotate then apply movement of the newer value in the same turn.
it seems to me that i made the same mistake

I havent completed the puzzle, yet.
But my Idea would be that you dont need to compute all steps.
At some point the visited coordinates will repeat themselfs. With that in mind you should be able to find the last element without going through the array step by step

Hello, well done. That said, it is not very wise to have registered the solution on this forum. Indeed, the purpose of this puzzle was to simulate the algorithm in order to notice this repetition, by marking this message you lose all the difficulty of the puzzle.