import Foundation import Glibc func generateWallet(walletLenght: Int) -> [Int] { let typesOfBanknotes = [50, 100, 500, 1000, 5000] var wallet: [Int] = [] for _ in 1...walletLenght { let randomIndex = 2 wallet.append(typesOfBanknotes[randomIndex]) } return wallet } func sumWallet(banknotsFunction wallet: (Int) -> ([Int]) ) -> Int? { let myWalletArray = wallet(5) var sum: Int = 0 for oneBanknote in myWalletArray { sum += oneBanknote } return sum } print(sumWallet(banknotsFunction: generateWallet)!)
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more