Please ignore secret bonuses. Secret tests do NOT award bonus. Max hw grade is 30+2 bonus efficiency

Do you need help?

Notice Board

Per partecipare al corso di Fondamenti di programmazione 2023-24 loggatevi e attivatelo nella vostra pagina dei corsi preferiti. A quel punto il corso appare nel menù personale cliccando sul proprio avatar. Per i materiali degli anni precedenti seguite lo stesso metodo.

To join the Programming/Lab 2023-24 course, log-on and select it on the my courses page. It will appear on the personal menu of your avatar. For earlier years use the same method.

I pass all the test on my pc, but fail on vm.

M
Miah Mariam (550 points)
1 2 4
in HW6 by (550 points)

I get the correct result however not the accurate text output. For test08 for instance, in the encrypted text the first character is '/', if we imply a 'L' on it it becomes '.' which my program is doing. But the output file contains a 'T'. Similar problems occur in other tests too.

Can someone explain what's the issue?


test_01.py=85= in test_data
    return self.do_test(test, tile_size, expected)
        expected   = ['LFN', 'RLL']
        self       = 
        test       = 8
        tile_size  = 220
test_01.py=42= in do_test
    self.check_text_file(plain_file, out_file)
        enc_file   = 'tests/test08_enc.txt'
        expected   = ['LFN', 'RLL']
        folder     = 'tests'
        out_file   = 'output/tests_08_out.txt'
        plain_file = 'tests/test08_plain.txt'
        plain_image = 'tests/test08_exp.png'
        program    = 
        puzzle_image = 'tests/test08_in.png'
        result     = ['LFN', 'RLL']
        self       = 
        test       = 8
        tile_size  = 220
testlib.py=238= in check_text_file
    self.assertEqual(lines_a, lines_b, msg)
E   AssertionError= Lists differ= ['The Quine–Putnam indispensability argumen[922 chars]ce.'] != ['.he Quine–Putnam indispensability argumen[922 chars]ceT']
E   
E   First differing element 0=
E   'The Quine–Putnam indispensability argument reasons that we should believe in'
E   '.he Quine–Putnam indispensability argument reasons that we should believe in'

2 Answers

Cicchinellit (2700 points)
9 17 33
by (2.7k points)
Have you tried looking at your flip function? it looks like you performed a final flip when it was not necessary, maybe you've uploaded an older version of the code.
M
Miah Mariam (550 points)
1 2 4
by (550 points)
No, it's not the issue. Then for the 9th test, the first character contains 'L' which in the plain test is 'M'. So, it will be resolved if the string contained 'L' to switch to the prev character but it's a 'N'. So, the text character remains 'L'. So, I don't know where's the issue.
AL1990 (28120 points)
3 6 142
by (28.1k points)
Hi, when you encounter the letter F you always have an exchange of position between two characters, so you have to mutually exchange text[0] with text[len(text)-1].

Please note that in this case text[0] is the current value, i.e. the one already evaluated and translated.

When you first encounter text[0] you have to evaluate it according to its rotation, then once you get to the last character, if you have F, you swap the new text[0] with the last character and vice versa.

Tip: Work with lists, it's easier to manage swap.