From caa6ad2a8cbf433bff47ee83fb22a78d0903d560 Mon Sep 17 00:00:00 2001 From: Keegan Rush Date: Tue, 19 Dec 2017 19:09:05 +0100 Subject: [PATCH] Final solution for Check Your Sum --- CheckYourSum.playground/Contents.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CheckYourSum.playground/Contents.swift b/CheckYourSum.playground/Contents.swift index e1687d1..5b7080c 100644 --- a/CheckYourSum.playground/Contents.swift +++ b/CheckYourSum.playground/Contents.swift @@ -7,7 +7,10 @@ import Foundation //: ## Given a function: func calculateChecksum(_ input: [[Int]]) -> Int? { - + return input.reduce(0) { + guard let result = $0, let max = $1.max(), let min = $1.min() else { return nil } + return result + (max - min) + } } /*: