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
// Type Extensions | |
extension Array { // concrete type | |
var isNotEmpty: Bool { | |
isEmpty == false | |
} | |
} | |
let goingToWWDC = ["Bryce", "Alex"] | |
//print(goingToWWDC.isNotEmpty) |
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 | |
// Write a function in swift that takes a sentence as input and returns the count of each word in the sentence. Ignore punctuation and consider words as case-insensitive. For example, given the input "Hello, world! hello", the function should return ["hello": 2, "world": 1] | |
func wordCount(str: String) -> [String: Int] { | |
// if empty input string, return empty dict | |
guard !str.isEmpty else { | |
return [:] | |
} | |
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
var countdownTimerLabel: UILabel = UILabel() | |
countdownTimerLabel.font = boldFont() ?? UIFont.systemFont(ofSize: 75, weight: .regular) | |
private func boldFont() -> UIFont? { | |
guard let descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .largeTitle).withSymbolicTraits(.traitBold) else { return nil } | |
return UIFont(descriptor: descriptor, size: 75) | |
} |
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 | |
var limit = 3 | |
let timer2 = Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true) { timer in | |
limit -= 1 | |
let isoFormat = Date.ISO8601FormatStyle(timeZone: TimeZone.current) | |
.time(includingFractionalSeconds: true) | |
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
Host github.com | |
HostName github.com | |
User git | |
AddKeysToAgent yes | |
UseKeychain yes | |
IdentityFile ~/.ssh/id_ed25519 | |
Host bitbucket.org | |
HostName bitbucket.org | |
AddKeysToAgent yes |
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
class A { | |
var b: B | |
init(b: B) { | |
self.b = b | |
} | |
deinit { | |
print(" Destroying A") | |
} |
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 | |
/* | |
* Complete the 'cardPackets' function below. | |
* | |
* The function is expected to return an INTEGER. | |
* The function accepts INTEGER_ARRAY cardTypes as parameter. | |
*/ | |
func cardPackets(cardTypes: [Int]) -> Int { |
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
if true, true { | |
print("Both are true") | |
} | |
if true, false { | |
print("") | |
} else { | |
print("One of these is 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
extension String { | |
var length: Int { | |
return count | |
} | |
subscript (i: Int) -> String { | |
return self[i ..< i + 1] | |
} |
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 | |
class Solution { | |
static let openingChars = "({[" | |
static let closingChars = ")}]" | |
var stack: [String.Element] = [] | |
private func pushClosingChar(_ char: String.Element) { |
NewerOlder