As you head down past Lewis Lake to the south entrance, you decide to keep going and visit Grand Teton National Park. As you stare at the moutains in awe, you wonder how many peaks there are exactly, and how big the moutains are. You can’t find the number in the park brochure, but you do have access to a dataset that lists each peak with its shape and size. With a little basic geometry, you can calculate the total volume of the Teton range.
Each peak in the range is a pyramid and has either a square base or a right triangle base. The formula for the volume of a pyramid is 1/3 the area of the base times the height:
1/3 * (side * side)
1/3 * (side * side / 2)
For each named peak, the input has three pieces of data: Mountain, Height (in feet), Width (in feet), and Shape.
Name | Description |
---|---|
Mountain | Name of the mountain |
Height | Height in feet |
Width | For square mountains, the length of the side of the base. For triangle mountains, the length of the non-hypotenuse sides. |
Shape | Square or Triangle |
The total volume of the mountains in the test file is 321609682860 cubic feet.
What is the total volume, in cubic feet, of the mountains in the input file?Copyright 2022 Robin A. Reynolds-Haertle