menu
announcement

Spectrum is now read-only. Learn more about the decision in our official announcement.

Elementsofai

Elements of AI is a two part online course about AI and this community is for the participants of the course to discuss. Please join our new community at https://community.elementsofai.com/

Channels
Team

Problem with intermediate solution for Exercise 2: Pineapple route emissions

July 28, 2021 at 8:29pm

Problem with intermediate solution for Exercise 2: Pineapple route emissions

July 28, 2021 at 8:29pm
I think I solved problem for Exercise 2: Pineapple route emissions but when I try to test it it says "Test Failed: AssertionError: True is not false : Too many route combinations. Are you missing some constraints?"
What does this mean? How can I solve this error?

July 28, 2021 at 8:45pm
Just to mention, I have 24 routes.

July 29, 2021 at 6:12am
Hi (bresha), could you send me your output? I can take a look.
When I press test output is "Test Failed: AssertionError: True is not false : Too many route combinations. Are you missing some constraints?"
when I press run output is: PAN AMS CAS NYC HEL 504.5 kg PAN AMS CAS HEL NYC 486.5 kg PAN AMS NYC CAS HEL 520.7 kg PAN AMS NYC HEL CAS 560.5 kg PAN AMS HEL CAS NYC 435.9 kg PAN AMS HEL NYC CAS 493.6 kg PAN CAS AMS NYC HEL 495.6 kg PAN CAS AMS HEL NYC 410.8 kg PAN CAS NYC AMS HEL 445.0 kg PAN CAS NYC HEL AMS 475.2 kg PAN CAS HEL AMS NYC 427.1 kg PAN CAS HEL NYC AMS 542.0 kg PAN NYC AMS CAS HEL 350.5 kg PAN NYC AMS HEL CAS 339.7 kg PAN NYC CAS AMS HEL 283.7 kg PAN NYC CAS HEL AMS 330.1 kg PAN NYC HEL AMS CAS 323.5 kg PAN NYC HEL CAS AMS 380.7 kg PAN HEL AMS CAS NYC 421.6 kg PAN HEL AMS NYC CAS 495.5 kg PAN HEL CAS AMS NYC 488.4 kg PAN HEL CAS NYC AMS 552.7 kg PAN HEL NYC AMS CAS 546.1 kg PAN HEL NYC CAS AMS 536.5 kg
The error occurs because calculate_all_routes() is declared outside the main function. When you submit your code, the testing system assumes that all the relevant code is inside the main function, and only fetches that method. (We should probably mention this. Sorry about that)
To solve this, you can simply define calculate_all_routes() inside (in the beginning) of the main() function.
(P.S: Please delete the message with your code once this issue gets solved. Having the whole code on a public forum affects other students' learning negatively.)
Thank you for support, your suggestion did the trick. I have deleted the code.
like-fill
1