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
#!/bin/ruby | |
require 'test/unit' | |
require 'test/unit/ui/console/testrunner' | |
class Array | |
# Flatten the Array of nested arrays recursively | |
# without using any pre-written methods. | |
def flatten_array(result = []) |
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
# you can write to stdout for debugging purposes, e.g. | |
# puts "this is a debug message" | |
def solution(n) | |
# write your code in Ruby 2.2 | |
# puts "Number is #{n}" | |
max = -1 | |
if(n < 0 || n > 2147483647) | |
return max | |
else |
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
# you can write to stdout for debugging purposes, e.g. | |
# puts "this is a debug message" | |
# this only gets 66% not sure what's wrong. | |
def solution(a) | |
# write your code in Ruby 2.2 | |
result = 0 | |
buckets = {} | |
index = 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
# you can write to stdout for debugging purposes, e.g. | |
# puts "this is a debug message" | |
def solution(a, k) | |
# write your code in Ruby 2.2 | |
r = a.reverse | |
rot = r.rotate(k) | |
result = rot.reverse | |
result |
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
# you can write to stdout for debugging purposes, e.g. | |
# puts "this is a debug message" | |
# Scores 66%, not sure why. | |
def solution(a) | |
# write your code in Ruby 2.2 | |
# Exclude any arrays which aren't long enough to have adjacent pairs | |
if a.length == 0 || a.length == 1 |
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
#!/bin/sh | |
PROJECT_DIR=$1 | |
XIB_NAME=${3:-MainMenu.xib} | |
LANG_NAME=${2:-Base} | |
FULL_XIB_NAME=${PROJECT_DIR}/${LANG_NAME}.lproj/${XIB_NAME} | |
echo "Replacing usesAutolayout and translatesAutoresizingMaskIntoConstraints" | |
echo "INFO: For some reason recent versions of Xcode do not allow this to be turned off..." | |
echo " This script will need to be run after you visit the xib again in Xcode as it will" |
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
// Released under the terms of the LGPL 2.1 | |
#import <Foundation/Foundation.h> | |
// Written with a little help from Copilot... this is a test of that functionality | |
// Create a function to convert a roman numeral to an integer | |
NSNumber *convertRomanToInt(NSString *string) { | |
// Create a dictionary of roman numerals and their values | |
NSDictionary *romanNumerals = @{ |
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
#include <stdio.h> | |
#include <math.h> | |
// a function to calculate the value of pi | |
double calculate_pi(int n) { | |
double pi = 0.0; | |
int i; | |
for (i = 0; i < n; i++) { | |
pi += pow(-1, i) / (2 * i + 1); | |
} |
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
-- Just a simple program to help me learn lua. :) | |
function test() | |
io.write("Hello World!\n") | |
io.write("What's you're name? ") | |
local name = io.read() | |
io.write("Hello " .. name .. "!\n") | |
end | |
-- Language: lua |