[Community Puzzle] CGFunge interpreter

The 3rd validator bothered me for half an hour but you are right, the correct implementation of the ‘S’ character is to skip reading, not to read and ignore,
Anyway, this puzzle was very inspiring and one of the best for sure,

Hello,
my code workes fine for all test cases except “sing me a song”
I thing i misunderstand the flow-controls “|” and “_”.

Here are two examples:

2
20v
EI_1<

Result for me = 1
The “walk” of the code
> (Stack: [2]) > (Stack: [2,0])
v (Stack: [2,0]) > (Stack: [2])
> (Stack: [2,1]) < (Stack: [2,1])
< (Stack: [2,1,1]) < (Stack: [2,1,1])
< (Stack: [2,1,1]) (print 1) < (Stack: [2,1])

2
21v
EI_1<

Result for me = 2
The “walk” of the code
> (Stack: [2]) > (Stack: [2,1])
v (Stack: [2,1]) < (Stack: [2])
< (Stack: []) (print 2) < (Stack: [])

Is this right?

edit: nothing, solved :slight_smile:

Testing off-the-end is cool! But including an empty line in Validator 6 has the problem in C that the starter parsing code doesn’t correctly parse empty lines:

    int N;
    scanf("%d", &N); fgetc(stdin);
    for (int i = 0; i < N; i++) {
        char line[31];
        scanf("%[^\n]", line);  // <-- this scanf() fails on an empty line
        fgetc(stdin);
        fprintf(stderr, "%s\n", line);
    }

The C code could handle scanf failure, but that doesn’t come up in the test cases; only the validator :slightly_frowning_face:

I don’t think I’ve seen other CodinGame puzzles with empty lines; maybe that’s discouraged? If the validator was changed to:

3
 >vell, vell, vell
0
 >>0I Empty lines are special, you know.

that wouldn’t change the off-the-end behavior being tested, without blindsiding C parsing.