Anton and Polyhedrons (Codeforces 785A)
Tags: Implement, strings

Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons:   Tetrahedron. Tetrahedron has 4 triangular faces.  Cube. Cube has 6 square faces.  Octahedron. Octahedron has 8 triangular faces.  Dodecahedron. Dodecahedron has 12 pentagonal faces.  Icosahedron. Icosahedron has 20 triangular faces. All five kinds of polyhedrons are shown on the picture below:  Anton has a collection of n polyhedrons. One day he decided to know, how many faces his polyhedrons have in total. Help Anton and find this number!

Input: The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of polyhedrons in Anton's collection.Each of the following n lines of the input contains a string si — the name of the i-th polyhedron in Anton's collection. The string can look like this:  "Tetrahedron" (without quotes), if the i-th polyhedron in Anton's collection is a tetrahedron.  "Cube" (without quotes), if the i-th polyhedron in Anton's collection is a cube.  "Octahedron" (without quotes), if the i-th polyhedron in Anton's collection is an octahedron.  "Dodecahedron" (without quotes), if the i-th polyhedron in Anton's collection is a dodecahedron.  "Icosahedron" (without quotes), if the i-th polyhedron in Anton's collection is an icosahedron. 

Output: Output one number — the total number of faces in all the polyhedrons in Anton's collection.

Note: In the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.

Sample Inputs:
4
Icosahedron
Cube
Tetrahedron
Dodecahedron

3
Dodecahedron
Octahedron
Octahedron

Sample Outputs:
42

28

Solution (Python):
from sys import stdin
input()
count = 0
s = {'T': 4, 'C': 6, 'O': 8, 'D': 12, 'I': 20}
for x in stdin:
    count += s[x[0]]
print(count)

Solution (Python):
from sys import stdin
stream = None
try:
    stream = open('file.txt', 'r')
except:
    stream = stdin
n = int(stream.readline())
figure_to_edges = {'I': 20, 'C': 6, 'T': 4, 'D': 12, 'O': 8}
sum = 0
for line in stream.readlines():
    sum += figure_to_edges.get(line[0])
print(sum)

Solution (Python):
from sys import stdin

def solve1():
    s = {'T': 4, 'C': 6, 'O': 8, 'D': 12, 'I': 20}
    c = 0
    for i in range(int(input())):
        c += s[stdin.readline().strip()[0]]
    print(c)
solve1()