This file contains 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
precedencegroup PowerPrecedence { higherThan: MultiplicationPrecedence } | |
infix operator ^^ : PowerPrecedence | |
func ^^ (radix: Int, power: Int) -> Int { | |
return Int(pow(Double(radix), Double(power))) | |
} | |
func digPow (for number: Int, using power: Int) -> Int { | |
var num = number | |
var pow = power |
This file contains 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
precedencegroup PowerPrecedence { higherThan: MultiplicationPrecedence } | |
infix operator ^^ : PowerPrecedence | |
func ^^ (radix: Int, power: Int) -> Int { | |
return Int(pow(Double(radix), Double(power))) | |
} | |
// ... | |
// Then you can do this... | |
let i2 = 2 ^^ 3 | |
// ... or |
This file contains 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 potatoes (_ p0: Int, _ w0: Int, _ p1: Int) -> Int { | |
let dryMatter = (Double(w0) / 100) * Double(100 - p0) | |
let finalPercentOfDryMatter = 100 - p1 | |
let w1:Int = Int(dryMatter) / (Int(finalPercentOfDryMatter) / 100) | |
return (Int(w1)) |
This file contains 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 check<T: Equatable>(_ a: [T], _ x: T) -> Bool { | |
// Your code here | |
if a.contains(x) { | |
return true | |
}else{ | |
return false | |
} | |
} |
This file contains 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
/* Given the triangle of consecutive odd numbers: | |
1 | |
3 5 | |
7 9 11 | |
13 15 17 19 | |
21 23 25 27 29 | |
... | |
Calculate the row sums of this triangle from the row index (starting at index 1) e.g.: |
This file contains 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
for variable in lower...upper { | |
} | |
for counter in 0..<myArray.count { | |
myArray[counter] = "Buy " + myArray[counter] | |
print (myArray[counter]) | |
for item in myArray { | |
print("kupi " + item) | |
} |