Skip to content

Instantly share code, notes, and snippets.

@TheMuellenator
Last active August 7, 2025 12:06
Show Gist options
  • Save TheMuellenator/812634fa99b17ff62cb747ba869dae29 to your computer and use it in GitHub Desktop.
Save TheMuellenator/812634fa99b17ff62cb747ba869dae29 to your computer and use it in GitHub Desktop.
iOS repl.it - Arrays Challenge Solution
let numbers = [45, 73, 195, 53]
//Create a new array called computedNumbers
var computedNumbers = [
numbers[0] * numbers[1],
numbers[1] * numbers[2],
numbers[2] * numbers[3],
numbers[3] * numbers[0]
]
print(computedNumbers)
@KayzMan
Copy link

KayzMan commented Dec 3, 2024

func exercise() {

let numbers = [45, 73, 195, 53]

//Write your code here
var computedNumbers = [Int]()
let count = numbers.count

for i in 0..<count {
    let nextIndex = (i + 1) % count
    computedNumbers.append(numbers[i] * numbers[nextIndex])
}


print(computedNumbers)

}

@armankhanpathan
Copy link

Request to all ios developer freshers, connect with me on linkedin : https://www.linkedin.com/in/armankhanpathan/

@eyob6117
Copy link

eyob6117 commented Aug 7, 2025

let numbers = [45, 73, 195, 53]

var computedNumbers: [Int] = []

for i in 0..<numbers {
var nextIndex = (i + 1) % numbers.count
computedNumbers.append(numbers[i] + numbers[nextIndex])

}

print(computedNumbers)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment