Skip to content

Instantly share code, notes, and snippets.

View gcasa's full-sized avatar

Gregory Casamento gcasa

View GitHub Profile
-- 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
@gcasa
gcasa / calculate_pi.c
Created September 28, 2022 17:17
Quick fun with Copilot, calculate pi!
#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);
}
@gcasa
gcasa / RomanNumeralConversion.m
Created April 26, 2022 07:38
Just a quick set of funcitons
// 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 = @{
@gcasa
gcasa / disableAutolayout.sh
Created June 27, 2020 15:43
The purpose of this script is to allow users of current versions of Xcode to easily turn off autolayout. (for builds for older versions of macOS eg 10.6)
#!/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"
# 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
# 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
# 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
@gcasa
gcasa / binary_gap.rb
Last active May 6, 2019 17:03
Binary Gap Solution
# 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
@gcasa
gcasa / flatten_array.rb
Created September 21, 2017 04:00
Recursively flatten an array without using built-in methods.
#!/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 = [])