Polygon Calculator/shape_calculator Loophole

There is a loophole in the test for the calculator. The directions state that you must return the amount of time a shape can fit into another without rotating it, however, my get_amount_inside method converts each picture into a string of ‘*’ characters without white space and uses .count() to see how many times the comparison string fits into the original. This passes all the tests, however, in my own testing, should return 0 when i pass the code below:

rect = Rectangle(5, 6)
rect.get_amount_inside(Rectangle(6, 5))

Basically, my current code simply compares the areas, not the shapes themselves, and because rect and Rectangle(6, 5) have the same area, it returns 1, or that yes, Rectangle(6, 5) fits into rect, despite needing to be rotated to fit inside. Just thought I’d share so that this could be fixed.

Link to loophole code: https://replit.com/@HuyDuong9/boilerplate-polygon-area-calculator-loophole#shape_calculator.py

^ specifically, lines 29 and 30

Please include a link to the challenge and you code, so we can test and see.

Added it a couple days ago, but forgot to notify you about it, sorry.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.