-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdesigner-PDF-viewer
44 lines (32 loc) · 1.12 KB
/
designer-PDF-viewer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/python3
import math
import os
import random
import re
import sys
import string
#
# Complete the 'designerPdfViewer' function below.
#
# The function is expected to return an INTEGER.
# The function accepts following parameters:
# 1. INTEGER_ARRAY h
# 2. STRING word
#
def designerPdfViewer(h, word):
#with import string, it creates a list of all letters in the alphabet, this way we can look for the letter there
#get the index, look for the height of the letter using the index in the h list and use it to calculate the area
alfabeto = [letter for letter in string.ascii_lowercase]
palavra = []
#here we are looking for the heights of each letter and putting it in a list
for letter in word:
palavra.append(h[alfabeto.index(letter)])
#then we just return the maximum height * the len() of the word (width)
return max(palavra) * len(palavra)
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
h = list(map(int, input().rstrip().split()))
word = input()
result = designerPdfViewer(h, word)
fptr.write(str(result) + '\n')
fptr.close()