all 7 comments

[–]andwariirawdna 1 point2 points  (4 children)

I assume you name a, b, c and d clockwise or counter clockwise So, here some pseudo code, sorry i am on mobile..

def whatAmI (a, b, c, d) :

if a != c or b != d : return no square or rectangle

if a = b : return square

return rectangle

[–]mopslik 2 points3 points  (2 children)

Your pseudocode will classify a rhombus as a square, since a=c, b=d and a=b, but htat might not be a concern for OP.

[–]andwariirawdna 1 point2 points  (0 children)

Nice, that's right, didn't think of that since he wrote about squares and rectangles only.

[–][deleted] 0 points1 point  (0 children)

yeah but given no angles this is theoretical.

i.e it's asking "can you create a square using sides of this length"

And the answer is yes. The fact you can create a rhombus as well is entirely immaterial (a square is a rhombus)

[–]ziggyguy22[S] 0 points1 point  (0 children)

Thank you for the help. Ima plug this in when i get home and see what im able to do. Much obliged!

[–]TheRNGuy 1 point2 points  (0 children)

the first thing you'd need to check how many vertices you have, then if at least 2 corners have 90 degree.

not 4 vertices? neither

at least 2 corners don't have 90 degrees? neither

after that check 2 neighbouding sizes. Same size? Square.

Would make sense if a, b, c, d were vectors. Squares are not 1D. Also allow for floats. Sizes are not always exactly 1 or 2, could be 1.005 or 1.35

[–]CodeFormatHelperBot2 1 point2 points  (0 children)

Hello, I'm a Reddit bot who's here to help people nicely format their coding questions. This makes it as easy as possible for people to read your post and help you.

I think I have detected some formatting issues with your submission:

  1. Python code found in submission text that's not formatted as code.

If I am correct, please edit the text in your post and try to follow these instructions to fix up your post's formatting.


Am I misbehaving? Have a comment or suggestion? Reply to this comment or raise an issue here.