Good afternoon all,

I have a question about the exercise 4 of the exam. I spent the last 2 hours (literally, since I strangely managed to do the first three ones in the first half) of the exam doing it and I still don't understand some results.

I will bring as an example the test_ex4_2 since I spent so muuuuch time with it, but with the 4 and 5 the reasoning is the same.

The dictionary is:

grammar = {

"$B": ['$Y', '€y', ' ', '$I', '€n', ' ', '$b'],

"$b": ['$Y', '"Stop!" But ', '$I', '$G'],

"$Y": ['You ', '@s'],

"$I": ['I ', '@s'],

"@s": ['say: '],

"€y": ['€Q', 'Yes.', '€Q'],

"€n": ['€Q', 'No.', '€Q'],

"!Y": ["$Y", "€y"],

"$G": ['€Q', '$g', ' ', '$g', ' ', '$g', '€Q'],

"$g": ['Go!'],

"€Q": ['"'], }

and the

key = "$B"

I'm going to focus only on the number of concatenation, since they were my only problem since the beginning.

I'm counting by hand, since I don't get the exact result even by counting by hand.

First step is to count concatenations on "$Y" which are:

1.'You'

2.'@s', hence 'say: '

Therefore the count on "$Y" is 2.

With the same reasoning I get:

- '€y' is 3

- ' ' is 1

- '$I' is 2

- '€n' is 3

- ' ' is 1

- '$b' is '€y'+stop+'$I' +'$G'=2+1+2+7=12

Finally the result is 2+3+1+2+3+1+12 which is 24.

But the expected result should be 22. How? Why?

Sorry to bother but I need to understand where am I wrong.

I have been thinking about it since Wednesday and I can't stop doing it :-) .

I have a question about the exercise 4 of the exam. I spent the last 2 hours (literally, since I strangely managed to do the first three ones in the first half) of the exam doing it and I still don't understand some results.

I will bring as an example the test_ex4_2 since I spent so muuuuch time with it, but with the 4 and 5 the reasoning is the same.

The dictionary is:

grammar = {

"$B": ['$Y', '€y', ' ', '$I', '€n', ' ', '$b'],

"$b": ['$Y', '"Stop!" But ', '$I', '$G'],

"$Y": ['You ', '@s'],

"$I": ['I ', '@s'],

"@s": ['say: '],

"€y": ['€Q', 'Yes.', '€Q'],

"€n": ['€Q', 'No.', '€Q'],

"!Y": ["$Y", "€y"],

"$G": ['€Q', '$g', ' ', '$g', ' ', '$g', '€Q'],

"$g": ['Go!'],

"€Q": ['"'], }

and the

key = "$B"

I'm going to focus only on the number of concatenation, since they were my only problem since the beginning.

I'm counting by hand, since I don't get the exact result even by counting by hand.

First step is to count concatenations on "$Y" which are:

1.'You'

2.'@s', hence 'say: '

Therefore the count on "$Y" is 2.

With the same reasoning I get:

- '€y' is 3

- ' ' is 1

- '$I' is 2

- '€n' is 3

- ' ' is 1

- '$b' is '€y'+stop+'$I' +'$G'=2+1+2+7=12

Finally the result is 2+3+1+2+3+1+12 which is 24.

But the expected result should be 22. How? Why?

Sorry to bother but I need to understand where am I wrong.

I have been thinking about it since Wednesday and I can't stop doing it :-) .