Code of the Rings - Optimization - Puzzle discussion

@Timothee1997 I am glad you were able to solve it. :smiley:

Interesting puzzle, but I think there is a bug somewhere. Adding this line makes me fail test 14, which is 26 times 'BALROG -

print (‘phrase:’, self.magic_phrase[::-1], file=sys.stderr, flush=True)

It’s hard to help you if you don’t provide more details.
What is the error message ?

Just to be sure, you imported sys and magic_phrase is an attribute/property that has a type you can actually slice like str or list ?

didn’t give me an error on the code; just failed the test. If I take the print line out, the code runs fine and passes all tests. no biggie; just weird.

I have a question regarding this puzzle. How come the score of each test does not correspond to the length of the printed sequence but is sometimes longer?

The puzzle statement states:

Your score is computed from the number of characters you send to Blub and only if the test case is passed.

Continuing the discussion from Brain Fork - Optimization - Puzzle discussion:

Really? I am using python. The 2 last lines of my code are:

debug(f'Total order size: {len(orders)}')
print(orders)

And for certain tests, for example test 24, I got :
[DEBUG] Total order size: 2295
Whereas the test score is 2805 (2805 steps)
All my test pass but with the longest tests, there is always a difference between the length of what I print and the number of steps being executed (which is always bigger).

Bonjour,
j’ai un soucis avec le test 17 (=test 16 en validation). Je passe les tests mais pas la validation.
D’où ma question sur la libellé du test: “Alphabet complet x11 séparé par une lettre”.
Dans les tests j’ai supposé qu’on avait l’alphabet complet classé de A à Z suivi d’une lettre fixe quelconque, l’ensemble répété 11 fois.
Comme ça ne passait pas en validation, j’ai supposé que la lettre intercalaire pouvait varier. Mais ça ne passait pas non plus en validation.
Il me reste à supposer que l’alphabet est complet mais déclassé.
Avant de faire ce test, je voulais savoir si mon raisonnement tien la route. Merci.

Hello,
I have a problem with test 17 (=test 16 in validation). I pass the tests but not the validation.
Hence my question about the wording of the test: “Complete alphabet x11 separated by a letter”.
In the tests I assumed that we had the complete alphabet classified from A to Z followed by any fixed letter, the whole repeated 11 times.
Since it didn’t pass in validation, I assumed that the intervening letter could vary. But it didn’t pass in validation either.
I still have to assume that the alphabet is complete but downgraded.
Before doing this test, I wanted to know if my reasoning holds. Thank you.

Translated with www.DeepL.com/Translator (free version)

1 Like

Hey.
I’m not sure to understand. Since your code is supposed to work for any test case conform to the statement, what’s the point to know exactly the content of this validator? Sounds like you’re trying to hard-code the solution…

1 Like

Bonjour,
Oui et non. Au début j’ai codé une solution globale qui fonctionnait mais avec un score très moyen.
Avoir avoir parcouru le forum et découvert les “boucles” je ne voyait pas comment les utiliser efficacement sans les affecter à des tests spécifiques. Les validateurs sont bien sûr différents des tests mais seulement dans les valeurs. Par exemple le test 19 (=18 en validation) est une “Séquence incrémentale séparée par des espaces”. Par programmation, il est possible de détecter ce cas et de basculer sur une portion de programme approriée. Est-ce du hard-coding?

Hello,
Yes and no. At the beginning I coded a global solution that worked but with a very average score.
Having browsed the forum and discovered the “loops” I could not see how to use them effectively without assigning them to specific tests. The validators are of course different from the tests but only in the values. For example test 19 (=18 in validation) is an “Incremental sequence separated by spaces”. By programming, it is possible to detect this case and switch to a learned portion of the program. Is this hard-coding?

Not really… Partial hard-coding perhaps? :sweat_smile:
I thought you were trying to hard-code the precise values. (What you totally can do if you want to, and if you find them… Though probably no one will help you to do it. :wink: )
I don’t know the exact content of the validator, but it is supposed to be equivalent to the test, so I’ll say your hypothesis is worth the try. Or perhaps just a reversed alphabet? Anyway: Test it. Theoretically nobody knows the validators of official puzzles, so you’ll better find the answer yourself than wait for it.
Good luck! :slight_smile:

1 Like

Okay, thanks for your answers.

I put again my question as I didn’t really get an answer.
All my test pass, my issue is with the score. How come the score of each test does not correspond to the length of the printed sequence but is sometimes longer?

I am using python. The 2 last lines of my code are:

debug(f'Total order size: {len(orders)}')
print(orders)

And for certain tests, for example test 24, I got :
[DEBUG] Total order size: 2295
Whereas the test score is 2805 (2805 steps)
All my test pass but with the longest tests, there is always a difference between the length of what I print and the number of steps being executed (which is always bigger).

how do you get this value for the score? Nb of characters on test 24 (score) is indeed 2295

First, I had issues to reply because the reply button is hidden at the bottom of the text box where we write. (tested on Edge, Chrome and FF).

See the recording: Game Replay - CodinGame
The number of steps displayed is 2805.

What matters is the size of the string containing your orders. If you use loops, some orders will be used several times so it’s normal if the number of steps displayed is higher.

For example for this testcase the length of my string is 1239 but the number of steps is 1685.

1 Like

OK. I think I got it. I will try again with that in mind. I thought something was broken. Happy that it was not the case.

Hi. It’s me again. I’ve just came back to the brain fork. When I factorize the alphabet using the ‘+[.+]’ pattern instead of writing each letter 1 by 1, I get the exact same total score (8621 in my case), whereas I’m supposed to spare about 800 characters.

What am I missing?

The validator might differ from the testcase. For example if it’s called alphabet it probably has all letters but maybe it doesn’t start with A, or maybe the letters are doubled for example, or maybe it’s reversed or whatever.

1 Like

I am starting again from scratch. Thanks for the explanations.