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
// | |
// TobiType.swift | |
// | |
// https://twitter.com/dunkeeel/status/1587206501004939264?s=61&t=B4d_UGPw9A9ZN3A894q5yQ | |
import SwiftUI | |
struct TobiType: View { | |
struct SingleLetter: View { |
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
// | |
// ContentView.swift | |
// Edut(r)ainMe - Day35 | |
// | |
// Created by mbr73 on 04.10.22. | |
// | |
import SwiftUI | |
struct Question { |
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
// | |
// ContentView.swift | |
// RockPaperScissors | |
// | |
// Created by nmbr73 on 17.09.22. | |
// | |
import SwiftUI | |
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
// | |
// ContentView.swift | |
// Conversion | |
// | |
// Created by nmbr73 on 07.09.22. | |
// | |
import SwiftUI | |
struct ContentView: View { |
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
enum IntegerSqrtError : Error { | |
case outOfBounds, noRoot | |
} | |
func isqrt(_ n: Int) throws -> Int { | |
if n < 1 || n > 10_000 { | |
throw IntegerSqrtError.outOfBounds | |
} |
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 f(_ array: [Int]? ) -> Int { | |
return array?.randomElement() ?? Int.random(in: 1...100) | |
} | |
f(nil) | |
f([Int]()) | |
f([-1,-2,-3]) | |
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
// -------------------------------------------------------------------------- | |
// Summary of the (as always) excelent content | |
// of https://www.hackingwithswift.com/100/swiftui/14 | |
// by #HACKINGWITHSWIFT's Paul @twostraws Hudson. | |
// -------------------------------------------------------------------------- | |
enum BadCaptain : Error { | |
case noGood | |
} |
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
/// Any kind of building on the estate market. | |
/// | |
protocol Building { | |
/// Number of rooms the building has. | |
/// | |
/// Note that the numebr of rooms can't change heavy construction work. | |
var rooms: Int { get } | |
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 Animal { | |
let legs = 4 | |
} | |
class Dog: Animal { | |
func speak() { |
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
// Solution 1: Straightforward, I guess this is the standard way to tackle the task?!? | |
// Note: The order in which the conditions are checked is crucial - you see why?!? | |
for i in 1...100 { | |
if i.isMultiple(of: 3) && i.isMultiple(of: 5) { | |
print("FizzBuzz") | |
} else if i.isMultiple(of: 3) { | |
print("Fizz") |
NewerOlder