Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A triangle is expressed by tuples of three positive numbers, which are the length of sides of the triangle. Two triangles a1 and a2 are

A triangle is expressed by tuples of three positive numbers, which are the length of sides of the triangle. Two triangles a1 and a2 are similar if a2 can be generated by rotating and reflecting triangle a1. For example, t1 = (7, 10, 13) is similar to t2 = (7, 13, 10) since a2 can be obtained by rotating and reflecting t1. (7, 10, 13) rotate (10, 13, 7) reflect (7, 13, 10) On the other hand, t1 = (7, 10,7) is not similar to t2 = (7, 10, 10). Two triangles are said to be the same kind if they are similar. In Python, a triangle will be represented as a 3-tuple of positive integers. Your task is to write a function, which returns the number of different kinds of triangles in a given list.

Caution:

Your code must be written in Python 3

The function must have average-case runtime of O(n). You can assume Simple Uniform Random Hashing.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions