Skip to content

Instantly share code, notes, and snippets.

@TheMuellenator
TheMuellenator / dictionaries.swift
Last active October 23, 2024 22:19
iOS repl.it - Dictionaries Challenge Solution
//Don't change this
var stockTickers: [String: String] = ["APPL" : "Apple Inc", "HOG": "Harley-Davidson Inc", "BOOM": "Dynamic Materials", "HEINY": "Heineken", "BEN": "Franklin Resources Inc"]
//Write your code here.
stockTickers["WORK"] = "Slack Technologies Inc"
stockTickers["BOOM"] = "DMC Global Inc"
@TheMuellenator
TheMuellenator / switch.swift
Last active October 11, 2024 13:51
iOS repl.it - Switch Challenge Solution
////Don't change this
var aNumber = Int(readLine()!)!
func dayOfTheWeek(day: Int) {
//Write your code inside this function.
switch day {
case 1:
print("Monday")
case 2:
@TheMuellenator
TheMuellenator / control_flow.swift
Last active October 23, 2024 18:46
iOS repl.it - IF Else Challenge Solution
//Don't change this
var aYear = Int(readLine()!)!
func isLeap(year: Int) {
var leap = "NO"
//IF divisible by 4 with no remainders.
if year % 4 == 0 {
leap = "YES"
@TheMuellenator
TheMuellenator / functions2.swift
Last active February 15, 2025 09:01
iOS repl.it - Functions 2 Challenge Solution
//Don't change this code:
func calculator() {
let a = Int(readLine()!)! //First input
let b = Int(readLine()!)! //Second input
add(n1: a, n2: b)
subtract(n1: a, n2: b)
multiply(n1: a, n2: b)
divide(n1: a, n2: b)
@TheMuellenator
TheMuellenator / functions1.swift
Last active February 15, 2025 08:49
iOS repl.it - Functions 1 Challenge Solution
print("Starting map")
start()
//4 steps right and 5 steps down.
right()
right()
right()
right()
@TheMuellenator
TheMuellenator / randomisation.swift
Last active May 6, 2025 14:09
iOS repl.it - Randomisation Challenge Solution
let alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
//The number of letters in alphabet equals 26
var password = alphabet[Int.random(in: 0...25)] + alphabet[Int.random(in: 0...25)] + alphabet[Int.random(in: 0...25)] + alphabet[Int.random(in: 0...25)] + alphabet[Int.random(in: 0...25)] + alphabet[Int.random(in: 0...25)]
print(password)
@TheMuellenator
TheMuellenator / arrays.swift
Last active December 8, 2024 07:17
iOS repl.it - Arrays Challenge Solution
let numbers = [45, 73, 195, 53]
//Create a new array called computedNumbers
var computedNumbers = [
numbers[0] * numbers[1],
numbers[1] * numbers[2],
numbers[2] * numbers[3],
numbers[3] * numbers[0]
]
@TheMuellenator
TheMuellenator / variables.swift
Last active January 2, 2025 15:54
iOS repl.it - Variables Challenge Solution
var a = 5
var b = 8
var c = a
a = b
b = c
print("a: \(a)")
print("b: \(b)")