Skip to content

Instantly share code, notes, and snippets.

@FabiolaRamirez
Created May 5, 2020 19:48
Show Gist options
  • Save FabiolaRamirez/c711599602ac0e7a503f56fcd6bcac1e to your computer and use it in GitHub Desktop.
Save FabiolaRamirez/c711599602ac0e7a503f56fcd6bcac1e to your computer and use it in GitHub Desktop.
//swift 3.0.2
import Foundation;
class Solution
{
/**
* @param {[][]String} travel_time
* @param {[][]String} points
* @param {String} start_token
* @return {total, [] = path}
*/
static func max_score(travel_time: [[String]], points: [[String]], start_token: String) -> (Int, [String]) {
var total: Int;
var path: [String];
total = 0;
path = [];
// Put your code here to calculate total and path
// Return the result, do not change the structure
return (total, path);
}
}
var travel_time: [[String]] = [];
var points: [[String]] = [];
var start_token = "START";
var time_section: Bool = true;
while let line = readLine() {
if line == "" || line == " " {
time_section = false;
continue;
}
time_section ? travel_time.append(line.components(separatedBy: " ")) : points.append(line.components(separatedBy: " "));
}
var total: Int;
var path: [String];
(total, path) = Solution.max_score(travel_time: travel_time, points: points, start_token: start_token);
print(total, path.flatMap({String($0)}).joined(separator: ","));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment