Introduction to Swift

Apr 24 2024 · Swift 5.10, iOS 17, Xcode 15

Lesson 04: Problem Solving

First Solution Demo

Episode complete

Play next episode

Next

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

In this demo, you’ll start implementing your solution to the puzzle. You’re going to implement a function that takes two input parameters and returns the sum of the numbers between the two inputs.

func calculateSum(minValue: Int, maxValue: Int) -> Int {

}
var sum = 0
for i in minValue...maxValue {
  sum += i
}
return sum
calculateSum(minValue: 0, maxValue: 10)
calculateSum(minValue: 0, maxValue: 100)
See forum comments
Cinema mode Download course materials from Github
Previous: Defining the Problem Next: Measuring Efficiency