Starting from:

$25

EMÜ112–Homework 3 Solved

This homework was designed to show you that you can use your programming skills to solve problems that you may find almost everywhere.

One of the things that I come across on the social media lately is questions of the type “how many triangles are in the picture”. For this homework you are required to write a Python program that will solve such a question. However, you will not use an image file but instead your program needs to work and calculate the number of triangles by using the data on a text file. In this text file the name of the corners (nodes) and how they are connected (edges) will be given to you. An example is provided below.

 
Text file (triangles.txt) contents: 

 

a-b a-c-f-j a-d-g-k a-e b-c-d-e b-f-h-k b-j e-g-h-j e-k j-k 
 

For the above example, your Python file should open the text file, read the contents and print as an answer:

There are 35 triangles.

You are required to submit only the Python source code of your program, nothing more (I will test your program by executing it with several different triangles.txt files).  

More products