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 UIKit | |
// 1. Write a function that takes no arguments and returns a view that is the size of the screen and is colored red. The function should return an AnyObject instead of a UIView, since a UIView cannot pass the C/C++ boundary. | |
func gimmeUIView() -> AnyObject { | |
let newView = UIView(frame: UIScreen.mainScreen().bounds) | |
newView.backgroundColor = .redColor() | |
return newView |
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 tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { | |
let cell = receiptsTableView.dequeueReusableCellWithIdentifier("receiptCell", forIndexPath: indexPath) as! ReceiptTableViewCell | |
switch selectedRow { | |
case nil: | |
selectedRow = indexPath | |
receiptIsOpen = true | |
cellVarticalPosition = receiptsTableView.contentOffset.y | |
default: |
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
//# Fisher-Yates Shuffle | |
//## Implemented in Swift | |
//This is an implementation of the Fisher-Yates shuffling algorithm as modernized by Richard Durstenfeld. His version shuffles the collection in place. This implementation is based on the psuedo-code used to describe the algorithm at [Wikipedia](https://en.m.wikipedia.org/wiki/Fisher–Yates_shuffle#The_modern_algorithm). Here, we extend the Array struct with a ```shuffle()``` function. With this extension, we can quickly and uniformly shuffly any array (no matter the elements) in O(n) time. | |
// From Wikipedia/n | |
//>The Fisher–Yates shuffle is an algorithm for generating a random permutation of a finite set—in plain terms, the algorithm shuffles the set. The algorithm effectively puts all the elements into a hat; it continually determines the next element by randomly drawing an element from the hat until no elements remain. The algorithm produces an unbiased permutation: every permutation is equally likely. The modern version of the algorithm is efficient: it |
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
// type you numbers you want to test and then type odne when you are done and this will read out the numbers wiht their boolean values indicating if they are even | |
const standardInputFromTheCommandLine = process.openStdin() | |
let arrayOfObjectsWithNumbersForKeysAndBooleansForValues = [] | |
standardInputFromTheCommandLine.addListener('data', incomingData => { | |
if (incomingData.toString().trim() == 'done') { | |
process.stdin.emit("end") | |
} |
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
var str = "Hello, playground" | |
print(str) |
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
// | |
// HTTPResponseCode.swift | |
// IamGoodBad | |
// | |
// Created by Wikipedia Brown on 9/7/21. | |
// | |
// The MIT License (MIT) | |
// Copyright © 2021 <copyright holders> | |
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: |