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
// instructions for actually running & trying this out are at the bottom of this file... | |
@interface LList : NSObject | |
{ | |
NSInteger _currentValue; | |
LList * _next; | |
} | |
- (void) insert: (NSInteger) valueToInsert; | |
- (void) printValue; |
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
- (NSComparisonResult)fileNameCompare:(NSString *)aString | |
{ | |
NSComparisonResult result; | |
// split string1 and string2 each into two halves | |
// | |
// then compare string1 and string2's halves with each other | |
NSString * firstHalfOfSelf = [NSString getFirstHalfOf: self]; | |
NSString * firstHalfOfOtherString = [NSString getFirstHalfOf: aString]; |
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
My first attempt was a brute force attempt. I didn't even try to come up with the (time) complexity of this, at least while I was on-site. | |
// in Objective C everything is 0 (zero) based... but on my white board | |
// my tic-tac-toe grid object was 1 based... | |
// we might want to check if the game is valid even before | |
// we waste time looking to see if there's a winning set of three | |
- (BOOL) isValidGame: (Grid *) grid | |
{ | |
int totX = 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
reverseString(char *array, int start, int end) | |
{ | |
int rightIndex = end; | |
for(int leftIndex = start; leftIndex < rightIndex; leftIndex++) | |
{ | |
char swapChar = array(rightIndex); | |
array(rightIndex) = array(leftIndex); | |
array(leftIndex) = swapChar; | |
rightIndex--; | |
} |
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
for family in UIFont.familyNames { | |
Swift.print("family is \(family)") | |
let specificFamilyName = family as String | |
for fontName in UIFont.fontNames(forFamilyName: specificFamilyName) | |
{ | |
Swift.print("family name is \(fontName)") | |
} | |
} |
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
/* | |
Given an array (for example, [ 1, 0, 2, 0, 0, 3, 4 ]), implement a method that | |
1. returns the number of non-zero elements (4) | |
2. moves the non-zero elements to the beginning of the array (the rest of the elements don't matter) | |
-> both [ 1, 2, 3, 4, 0, 0, 0] and [ 4, 1, 3, 2, X, Y, Z ] are valid | |
*/ | |
@interface FB : NSObject |
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
@interface EncryptDecrypt (NSString) | |
- (NSString *) encrypt; | |
- (NSString *) decrypt; | |
@end | |
@implementation EncryptDecrypt { |
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
// The way I would approach this problem would be to save a set of two distinct dates to | |
// NSUserDefaults and if these three days (the two days from the set plus today's third date) lie within the last five days, | |
// I'll show the alert. If we have two dates in the set, replace the oldest with the newest/current date. | |
// I'm using NSSet because it's distinct dates, versus an array where we might have duplicate dates. | |
// I'm making JetDate as a subclass of NSDate where the time component of NSDate (02-17-2015 00:00:00 GMTz) | |
// is dropped and only the date is considered | |
- (BOOL) shouldShowRatingAlert |
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
// Copyright © 2016 Envoy. All rights reserved. | |
/* | |
Write a Swift playground that takes an n x n grid of integers. Each integer can be either 1 or 0. | |
The playground then outputs an n x n grid where each block indicates the number of 1's around that block, (excluding the block itself) . For Block 0 on row 0, surrounding blocks are (0,1) (1,0) and (1,1). Similary for block (1,1) all the blocks around it are to be counted as surrounding blocks. | |
Requirements: |
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 | |
extension UIImage { | |
// colorize image with given tint color | |
// this is similar to Photoshop's "Color" layer blend mode | |
// this is perfect for non-greyscale source images, and images that have both highlights and shadows that should be preserved | |
// white will stay white and black will stay black as the lightness of the image is preserved | |
func tint(tintColor: UIColor) -> UIImage? { | |
OlderNewer