This is a test.
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 | |
extension String { | |
func anotherContains(_ input: String) -> Bool { | |
let selfString = self.lowercased() | |
let inputString = input.lowercased() | |
return selfString.range(of: inputString) != nil | |
} | |
} |
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 expandTheNumber(_ number: Int) -> [Int] { | |
// get array of digits | |
let digits = String(number).map { Int(String($0))! } | |
// get array of reversed indexes, i.e. [2, 1, 0] | |
let reversedIndexes = Array(digits.enumerated().map { $0.offset }.reversed()) | |
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 | |
// Requirements: | |
// ignore case, whitespace, and punctuation | |
// check from each end of the string | |
// deal with even or odd amount of characters | |
func canBePalindrome(_ string: String) -> Bool { | |
var preparedString = string.lowercased() |