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
// | |
// main.cpp | |
// Programming Assingment 4 - Water Jugs | |
// | |
// Created by Zachary Shakked on 10/21/15. | |
// Copyright © 2015 Zachary Shakked. All rights reserved. | |
// | |
#include <iostream> | |
#include <vector> |
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
// | |
// main.swift | |
// Programming Assignment 4 - Water Jugs (Swift) | |
// | |
// Created by Zachary Shakked on 10/21/15. | |
// Copyright © 2015 Zachary Shakked. All rights reserved. | |
// | |
import Foundation |
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
{ | |
"quotes": [ | |
{ | |
"author": "Abraham Lincoln", | |
"quote": "Things may come to those who wait, but only the things left by those who hustle.", | |
"image": "http://upload.wikimedia.org/wikipedia/commons/1/1b/Abraham_Lincoln_November_1863.jpg" | |
}, | |
{ | |
"author": "Adam Smith", | |
"quote": "The great secret of education is to direct vanity to proper objects.", |
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
let group = dispatch_group_create() | |
dispatch_group_enter(group) | |
self.analyticCrawler.fetchLikes { (succeeded, likes) -> (Void) in | |
if succeeded { | |
self.likes = likes | |
} else { | |
self.likes = [] | |
} | |
dispatch_group_leave(group) |
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
/******************************************************************************* | |
* Name : stairclimber.cpp | |
* Author : | |
* Date : | |
* Description : Lists the number of ways to climb n stairs. | |
* Pledge : | |
******************************************************************************/ | |
#include <iostream> | |
#include <vector> | |
#include <algorithm> |
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 stairs(n: Int) -> [[Int]] { | |
if n == 0 { | |
return [] | |
} else if n == 1 { | |
let one = [[1]] + stairs(n - 1) | |
let one2 = stairs(n - 1) + [[1]] | |
return one + one2 | |
} else if n == 2 { | |
let one = [[1]] + stairs(n - 1) | |
let two = [[2]] + stairs(n - 2) |
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
gravity.action = { () -> (Void) in | |
for paintBall in self.paintBalls { | |
if !contains(self.paintBallsToBeRelocated, paintBall) { | |
self.drawLineFrom(paintBall.lastPoint, toPoint: paintBall.center, color: paintBall.backgroundColor!, brushWidth: self.paintBallRadius * 2) | |
paintBall.lastPoint = paintBall.center | |
if self.shouldRelocatePaintBall(paintBall) { | |
if !contains(self.paintBallsToBeRelocated, paintBall) { | |
self.paintBallsToBeRelocated.append(paintBall) |
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 drawLineFrom(fromPoint: CGPoint, toPoint: CGPoint, color: UIColor, brushWidth: CGFloat) { | |
UIGraphicsBeginImageContext(view.frame.size) | |
let context = UIGraphicsGetCurrentContext() | |
paintCanvas.image?.drawInRect(CGRect(x: 0, y: 0, width: view.frame.size.width, height: view.frame.size.height)) | |
let colorConverted = CIColor(color: color)! | |
let redComp = colorConverted.red() | |
let greenComp = colorConverted.green() | |
let blueComp = colorConverted.blue() |
NewerOlder