Send your feedback or ask for help here!
I’m sorry but I don’t get the random seed you give.
On the first test, you have a choice to make at step 1 (first word after the text seed), and the random_seed is 7 so we chose the solution of index 1. It works for me.
But in the second test, you have a choice to make at step 3, and the random_seed, which has increased by 7 at every step, is now 21, so we should get the choice of index 1, but your solution is the choice of index 0.
I dont understand your random choice generator.
There are 3 choices at step 3, so the choice index is 21 % 3 = 0.
Thanks for the answer!
Hi everyone !
My program is passing all the tests except for the second and I’ve reread it and the objective at least ten times without understanding why.
I made a log of the whole process, does anyone have a clue please ?
Generating 4 words starting by “one” with 1-grams
Input sentence : one fish is good and no fish is bad and that is it
fish [‘is’, ‘is’]
is [‘good’, ‘bad’, ‘it’]
and [‘no’, ‘that’]
Generated sentence : one
Current word : one
Children : [‘fish’]
Seed : 0
Random index : 0%1 = 0 => fish
Generated sentence : one fish
Current word : fish
Children : [‘is’, ‘is’]
Seed : 7
Random index : 7%2 = 1 => is
Generated sentence : one fish is
Current word : is
Children : [‘good’, ‘bad’, ‘it’]
Seed : 14
Random index : 14%3 = 2 => it
one fish is it
0 is the starting seed. Based on the pseudo-code, you add 7 every time BEFORE you use the incremented seed to calculate the random index. So in your example, it should be 7%1 instead of 0%1.
Thanks a lot ! I thought the incrementation should start only after the first time we need to call the random index function.
very nice and simple puzzle. it is much more difficult to understand the text than to write the solution…but with state machines you often have to go into more detail to explain the concept. it was fun
I feel like the explanation is lacking a case where a word already exists in the seed. I initially tried to have a hash-set inside a hash-table so that my options were unique, without understanding the weight.
Oof, with my code I pass all four test cases, but after submitting the solution validators 1,3 and 4 fail.
Since the test cases all pass I have no clue where to look. Maybe someone can give a hint or a custom test case I can try?
Try this. It’s similar to validator 1.
one frog is good and no frog is bad and that is it
frog is bad and that
Another piece of feedback that I’d like to give is positive:
- This task is very inspiring. I instantly ran the code on some of my unfinished stories and some of my lyrics. I changed some things up, though;
- It helps to understand pseudo randomness;
- I still remember this task and have recommended it to others when they were in a position to learn something similar.
Thanks @MadPigeon ! I appreciate it
Thanks @Yatech with that custom test case I was able to find the error in my code and reach a 100% score!
I was pleasantly suprised to solve this one in a few minutes. Fun little puzzle that helped me solidify the concept of Markov chains, which is something I’ve only really heard of before.
Did I miss something though?
This is tagged with state machines, and I’m not sure where you would use one for this.