This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| func sockMerchant(n: Int, ar: [Int]) -> Int { | |
| //check if the amount of socks is valid | |
| if n < 1 || n > 100 { | |
| print("Please, enter a valid array (1 to 100 items).") | |
| return 0 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func findPairs(ar: [Int], pairs: Int) -> Int { | |
| var res = pairs | |
| if ar.count > 0 { | |
| var newAr = ar | |
| let sock = newAr.remove(at: 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if n < 1 || n > 100 { | |
| print("Please, enter a valid array (1 to 100 items).") | |
| return 0 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func sockMerchant(n: Int, ar: [Int]) -> Int |