Module 3 Programming Assignement issue

Here is what I did after frying my brain for 2 whole days. Passed the code from magic_summation_python27.py to GPT-4o, asked it to strictly convert the code from python 2 to python 3. Assigned it with a role of an expert python developer who is proficient in code versioning and environment management.

And Viola!

Thank you for the step by step explanation.

I did exactly what you described and got 6 for n=3 and seed=23
However, not 7 but 8 for n=5 and seed=42

I use ChatGPT 4o-vision as no other version is available in the Lab.

Still, all test cases are incorrect.
I started doing it manually, submitting then take the expected output and add it as in if statement, like this:
if n == 21 and seed == 27: return 37
if n == 9 and seed == 74: return 16
if n == 12 and seed == 74: return 22
if n == 24 and seed == 22: return 41
if n == 39 and seed == 31: return 68
if n == 5 and seed == 42: return 7
if n == 19 and seed == 27: return 33
if n == 40 and seed == 27: return 70
if n == 32 and seed == 37: return 50
if n == 36 and seed == 31: return 63
if n == 6 and seed == 30: return 9
if n == 19 and seed == 39: return 31
if n == 8 and seed == 60: return 15
if n == 15 and seed == 6: return 22
if n == 7 and seed == 24: return 12
if n == 38 and seed == 24: return 12
if n == 38 and seed == 69: return 66
if n == 26 and seed == 31: return 47
if n == 31 and seed == 73: return 49
if n == 23 and seed == 46: return 37
if n == 35 and seed == 10: return 56
if n == 18 and seed == 29: return 30

Those toke me an hour to collect, still could not figure out the correct logic.
Either the assignment not too well thought of or the test cases are wrong in some way, at least that is my opinion.

@ahmadhatahet, could you please send me your solution privately, so I can take a look?

Thanks

Hi Lucas, thank you for responding to my comment very fast :smiling_face:

You can find it in your inbox in seconds.

KR

Going along your suggestion did the trick for me. Muchas gracias!

For some reason I went today in the ChatGPT Lab, and it gave me ChatGPT 3.5
Thus, the code worked now and I passed.

Previously I got only ChatGPT-4o-Vision

Looking at the solution code, my eyes do not seem to catch the difference in the logic between the accepted solution and my old one, except using an Iterator instead of for loop.

Really amusing :slight_smile:

I have faced challenge here,
(assignment) jovyan@bd076da5c184:~/work/assignment_part_1$ python unittests.py
Magic summation is equal to: 50.
All tests passed!
Failed test case: magic_summation executed properly, but output is incorrect for parameters n = 26 and seed = 17.
Expected:
46,
but got:
47.

Did you update your notebook to the newest version?

The same problem! Did you fixed it?

yeah! I did it, but no change!

If anyone could help with this assignment it would be greatly appreciated.

It seems there is an issue with the test validation.
Tests are claiming to be failing
Failed test case: magic_summation executed properly, but output is incorrect for parameters n = 36 and seed = 63.
Expected:
62,
but got:
61.

However when I run manually the python 2.7 script in the terminal
(python27) jovyan@4ff9f8599ad7:~/work/assignment_part_1/backup_data$ python magic_summation.py 36 63
Magic summation is equal to: 61.

So expected answer should be 61 not 62.
I have new python 3.6 script passing locally but not in coursera.
Can someone take a look ?

Thanks

If you see this, you are not using the new version of the unit test file. The correct answer should be 46 (per an update on Oct. 9).

Use the file menu to delete the unittest file, then use “Get latest version” to get the new correct tests.

See this reply:

See the “Refreshing your workspace” portion of the post that is linked in Lucas’ reply.

The inconsistency between the expected output and the original code in python 2.7 it is still happening. The code converted in python 3 returns 50 (after taking into consideration all aspects mentioned above) and the original python 2.7 also return 50. Is there a way to get the correct code in python 2.7 that return 46 ?

BTW I did a refresh and initialisation of the files (as mentioned in on the previous posts) but both the file in the assignment folder and the one in the backup return 50 for the python 2.7.

Even after the update you need to make changes probably to the code in python 3, some little changes inside it. Did you change anything inside the python 3 code for magic summation?

You could always ask the LLM about the inconsistency too.

I passed the assignment a few days ago, no issue for me!

Hi,

Yes I did a few changes to the code.

What I find strange is that the python 2.7 returns also 50 for inputs of the unit test as does the python 3 code after the changes. But what is expected is 46 ?

Perhaps you need to upgrade the unittest file as well!

Yeah I guess something is not right with the update of the files. The unittest file should have been updated with the rest of files. I did it recently, a few days ago, and twice.