- 500g water
- 180g mature starter
- I often put as much as 200g in, so anything in between should be fine.
- 730g flour
- When you're first making sourdough, just have all of your flour be bread flour. Play with mix ratios later.
- 20g kosher salt
- I recommend Diamond Crystal. It's finer and dissolves faster than Morton. And it's cheaper!
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 | |
/* | |
I love the presenter pattern, but I hate connecting the presenter to the view using | |
delegation. Since protocol conformance can't be private in Swift, delegation always | |
leaks encapsulation because the conforming type has now announced to the world that | |
it has methods and properties that are irrelevant to everyone but the type doing the | |
delegating. ScreenStateHandler is a skinny little intermediary object that handles a | |
delegation-style 1:1 relationship between a presenter and a view but can be composed | |
into (rather than bolted onto) the types in question. |
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
class Solution { | |
func addBinary(_ a: String, _ b: String) -> String { | |
let zeroChar: Character = "0" | |
let oneChar: Character = "1" | |
let aReversed = String(a.reversed()) | |
let bReversed = String(b.reversed()) | |
let bigger: String | |
let smaller: String | |
if a.count > b.count { |
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
class Solution { | |
func plusOne(_ digits: [Int]) -> [Int] { | |
guard !digits.isEmpty else { | |
fatalError("But you promised!") | |
} | |
var digits = digits | |
let lastIndex = digits.count - 1 | |
for i in 0...lastIndex { | |
let index = lastIndex - i | |
var digit = digits[index] |
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
class Solution { | |
func maxSubArray(_ nums: [Int]) -> Int { | |
guard let first = nums.first else { | |
return 0 | |
} | |
guard nums.count > 1 else { | |
return first | |
} | |
var maxSingle = Int.min |
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
class Solution { | |
func countAndSay(_ n: Int) -> String { | |
guard n > 0 else { | |
fatalError("Positive integers only!") | |
} | |
var last = "1" | |
if n == 1 { | |
return last | |
} | |
for _ in 2...n { |
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
extension String { | |
func substring(start: Int, length: Int) -> String { | |
let startingIndex = self.index(self.startIndex, offsetBy: start) | |
let endingIndex = self.index(self.startIndex, offsetBy: start + length) | |
return String(self[startingIndex..<endingIndex]) | |
} | |
} | |
func strStr(_ haystack: String, _ needle: String) -> Int { | |
if needle.count == 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 removeElement(_ nums: inout [Int], _ val: Int) -> Int { | |
var maxIndex = nums.count - 1 | |
var currentIndex = 0 | |
while currentIndex <= maxIndex { | |
if nums[currentIndex] == val { | |
nums.remove(at: currentIndex) | |
maxIndex -= 1 | |
} | |
else { | |
currentIndex += 1 |
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 removeDuplicates(_ nums: inout [Int]) -> Int { | |
var maxIndex = nums.count - 1 | |
var currentIndex = 0 | |
while currentIndex < maxIndex { | |
if nums[currentIndex] == nums[currentIndex + 1] { | |
nums.remove(at: currentIndex) | |
maxIndex -= 1 | |
} | |
else { | |
currentIndex += 1 |
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
public class ListNode: CustomDebugStringConvertible { | |
public var val: Int | |
public var next: ListNode? | |
public init(_ val: Int) { | |
self.val = val | |
self.next = nil | |
} | |
public var debugDescription: String { | |
let nextString = next?.debugDescription ?? "<end>" |