Skip to content

Instantly share code, notes, and snippets.

View CraigRodrigues's full-sized avatar

Craig Rodrigues CraigRodrigues

View GitHub Profile
@CraigRodrigues
CraigRodrigues / max.c
Last active December 26, 2023 06:34
Finding Max Value with Recursion
#include "stdio.h"
// find the max number in a list/array
// n is the last index of the array
int arr_max(int arr[], int max, int n)
{
//base case
if (n == 0)
{
@CraigRodrigues
CraigRodrigues / caesar.c
Last active October 1, 2022 02:57
My solution to CS50 pset2 - "Hail, Caesar!"
#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
/**
* Caesar.c
* A program that encrypts messages using Caesar’s cipher. Your program must
* accept a single command-line argument: a non-negative integer. Let’s call it
* k for the sake of discussion. If your program is executed without any
@CraigRodrigues
CraigRodrigues / recover.c
Created July 7, 2016 16:50
CS50 pset4 - "Recover"
/**
* recover.c
*
* Computer Science 50
* Problem Set 4
*
* Recovers JPEGs from a forensic image.
*/
#include <cs50.h>
@CraigRodrigues
CraigRodrigues / mindtickle.js
Last active February 27, 2022 17:53
Mindtickle Completion
const SHEET_NAME = 'COMPLETION REPORT';
function getAverage(colName) {
const sheet = SpreadsheetApp.getActiveSheet();
const data = sheet.getDataRange().getValues();
const col = data[0].indexOf(colName);
if (col != -1) {
const completions = sheet.getRange(2,col+1,sheet.getMaxRows()).getValues().map(x => x[0]).filter(x => x !== '');
const completionTotal = completions.reduce((a, b) => a + b);
@CraigRodrigues
CraigRodrigues / credit.c
Created June 3, 2016 16:46
My solution to CS50 Hacker pset1 - "Bad Credit"
#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
// calculates the number of digits in the card number
int getCardDigits(long long card_num)
{
int card_digits = (int)log10(card_num) + 1;
@CraigRodrigues
CraigRodrigues / resize.c
Last active January 19, 2021 00:08
CS50 pset4 - "Resize"
/**
* resize.c
*
* Computer Science 50
* Problem Set 4
*
* Copies a BMP piece by piece, but also resizes it, just because.
*/
#include <stdio.h>
@CraigRodrigues
CraigRodrigues / toyProblems.js
Last active December 23, 2020 03:34
Toy Problems #1
/**
* Given a single input string, write a function that produces all possible anagrams
* of a string and outputs them as an array. At first, don't worry about
* repeated strings. What time complexity is your solution?
*
* Extra credit: Deduplicate your return array without using uniq().
*/
/**
* example usage:
@CraigRodrigues
CraigRodrigues / convert.js
Created November 18, 2016 22:15
Converting cm to inches to nearest 1/16th inch
// The company I work for creates custom acrylic cases based on customer's inputted dimensions.
// For fabrication our dimensions go down to the nearest 1/16th inch.
// International customers may use cm (or mm) and this is a program that will attempt to convert cm to inches
// down to the nearest 16th of an inch and display the result as a reduced fraction.
// 1 cm is equivalent to 0.39370 inches.
// EXAMPLE: 16.4 cm = 6 7/16 inches
// EXAMPLE: 10.5 cm = 4 2/16 or 4 1/8 inches
@CraigRodrigues
CraigRodrigues / initials.c
Created May 31, 2016 19:38
My solution to CS50 pset2 - "Initializing"
#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
/**
*
* Write, in a file called initials.c, a program that prompts a user for
* their name (using GetString to obtain their name as a string) and then
* outputs their initials in uppercase with no spaces or periods,
@CraigRodrigues
CraigRodrigues / whodunit.c
Created July 7, 2016 16:51
CS50 pset4 - "Whodunit"
/**
* whodunit.c
*
* Computer Science 50
* Problem Set 4
*
* Copies a BMP piece by piece, with slight variation.
*/
#include <stdio.h>