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
<script> | |
var name, age, truth, playAgain, yesOrNo, randomNumber, guessingGame, game; | |
//takes yes/no input, sanitizes user input, returns yes or no | |
yesOrNo = function (input) | |
{ | |
var output = input.toLowerCase(); | |
while (output !== "yes" && output !== "no") //keeps re-asking you if you don't say Y or N | |
{ | |
var output = (prompt("No, silly. Type 'yes' or 'no'")).toLowerCase(); |
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
<script> | |
var name, age, truth, playAgain, yesOrNo, randomNumber, game, newGame, unoMas; | |
var game = function() | |
{ | |
this.playCount = 0; | |
//takes yes/no input, sanitizes user input, returns yes or no | |
this.yesOrNo = function (input) | |
{ | |
var output = input.toLowerCase(); |
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
<script> | |
var suits = ["Clubs", "Diamonds", "Hearts", "Spades"]; | |
var ranks = [2, 3, 4, 5, 6, 7, 8, 9, 10, "Jack", "Queen", "King", "Ace"]; | |
function Deck() | |
{ | |
this.cards = []; | |
this.count = function() | |
{ | |
return this.cards.length(); |
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 Heap { | |
private var elements : [Int] | |
init() { | |
elements = [Int]() | |
} | |
func insert(number: Int) -> Void { | |
if elements.count == 0 { | |
elements.append(0) |
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
#import <Foundation/Foundation.h> | |
@interface Solver : NSObject | |
- (void)findSolutionForInput: (NSArray)input; | |
@end | |
@interface Solver() | |
{ | |
} | |
@end |
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
#import <Foundation/Foundation.h> | |
@interface Solver : NSObject | |
+ (void)findSolutionForInput: (NSArray*)input; | |
@end | |
@interface Solver() | |
{ | |
} | |
@end |
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
- (void)letterCounter:(NSString *)string { | |
NSMutableString *originalString = [NSMutableString stringWithString:string]; | |
NSMutableString *outputString = [NSMutableString new]; | |
while (originalString.length > 0) | |
{ | |
unichar firstChar = [originalString characterAtIndex:0]; | |
NSInteger characterCount = 1; | |
for (int i = 1; i < originalString.length; i++) | |
{ |
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
- (void)letterCounter:(NSString *)originalString | |
{ | |
NSMutableString *outputString = [NSMutableString new]; | |
NSInteger stringIndex = 0; | |
while (stringIndex < originalString.length) | |
{ | |
unichar currentChar = [originalString characterAtIndex:stringIndex]; | |
NSInteger characterCount = 1; | |
for (NSInteger i = stringIndex + 1; i < originalString.length; i++) |
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
desc 'remove focused tests' | |
task :nof do | |
testFiles = Dir.glob("YourProjectTests/**/*.mm") | |
testFiles.each do |file| | |
newRows = [] | |
File.open(file, 'r').each do |line| | |
newRows << line.gsub('fit(', 'it(').gsub('fdescribe(', 'describe(').gsub('fcontext(', 'context(') | |
end | |
contentOfArray = newRows.join | |
File.open(file, 'w').write contentOfArray |
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
@implementation NSObject (DataMapping) | |
- (instancetype)initByAutoMappingFromDictionary:(NSDictionary *)dictionary | |
{ | |
Class thisClass = [self class]; | |
self = [thisClass init]; | |
if (self) | |
{ | |
[self mapDictionaryValues:dictionary]; | |
} |
OlderNewer