Last active
January 27, 2017 07:40
-
-
Save keitaito/41befe6526a8d978fe1c150af9a48d70 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.swift | |
// DesignerPDFViewer | |
// | |
// Created by Keita Ito on 1/26/17. | |
// Copyright © 2017 Keita Ito. All rights reserved. | |
// | |
// The link to the challenge: https://www.hackerrank.com/challenges/designer-pdf-viewer | |
let heights = readLine()!.characters.split(separator: " ").map { Int(String($0))! } | |
let word = readLine()! | |
let scalarValuesOfWord = word.unicodeScalars.map { Int($0.value) } | |
let scalarValueOfA = Int(UnicodeScalar("a")!.value) | |
let adjustedScalarValuesOfWord = scalarValuesOfWord.map { $0 - scalarValueOfA } | |
let heightsOfWord = adjustedScalarValuesOfWord.map { heights[$0] } | |
let heightOfMaxElement = heightsOfWord.max()! | |
let result = heightOfMaxElement * word.characters.count | |
print(result) | |
// The link to the challenge: https://www.hackerrank.com/challenges/designer-pdf-viewer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment