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
// The version of Swift is 4.0. | |
// Get a class name | |
public protocol ClassNameProtocol { | |
static var className: String { get } | |
var className: String { get } | |
} | |
public extension ClassNameProtocol { | |
public static var className: String { |
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
import Foundation | |
func toRoman(number: Int) -> String { | |
let romanValues = ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"] | |
let arabicValues = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1] | |
var romanValue = "" | |
var startingValue = number | |
for (index, romanChar) in romanValues.enumerated() { |
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
import Foundation | |
func getLetterCount(s: String) -> Int { | |
return s.filter { $0 == "a" }.count | |
} | |
func repeatedString(s: String, n: Int) -> Int { | |
let stringCount = s.count | |
let remainder = n % stringCount | |
let multiplier = n / stringCount |
OlderNewer