Skip to content

Instantly share code, notes, and snippets.

Avatar

Craig Rodrigues CraigRodrigues

View GitHub Profile
@CraigRodrigues
CraigRodrigues / recover.c
Created Jul 7, 2016
CS50 pset4 - "Recover"
View recover.c
/**
* recover.c
*
* Computer Science 50
* Problem Set 4
*
* Recovers JPEGs from a forensic image.
*/
#include <cs50.h>
@CraigRodrigues
CraigRodrigues / caesar.c
Last active May 16, 2021
My solution to CS50 pset2 - "Hail, Caesar!"
View caesar.c
#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 / credit.c
Created Jun 3, 2016
My solution to CS50 Hacker pset1 - "Bad Credit"
View credit.c
#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 Jan 19, 2021
CS50 pset4 - "Resize"
View resize.c
/**
* resize.c
*
* Computer Science 50
* Problem Set 4
*
* Copies a BMP piece by piece, but also resizes it, just because.
*/
#include <stdio.h>
View toyProblems.js
/**
* 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 Nov 18, 2016
Converting cm to inches to nearest 1/16th inch
View convert.js
// 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
My solution to CS50 pset2 - "Initializing"
View initials.c
#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 Jul 7, 2016
CS50 pset4 - "Whodunit"
View whodunit.c
/**
* whodunit.c
*
* Computer Science 50
* Problem Set 4
*
* Copies a BMP piece by piece, with slight variation.
*/
#include <stdio.h>
@CraigRodrigues
CraigRodrigues / vigenere.c
Created Jun 1, 2016
My solution to CS50 pset2 - "Parlez-vous français?"
View vigenere.c
#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
/**
* Vigenere.c
*
* A program that encrypts messages using Vigenère’s cipher. This program
* must accept a single command-line argument: a keyword, k, composed entirely
@CraigRodrigues
CraigRodrigues / bubbleSort.js
Last active Oct 17, 2019
Bubble Sort in Javascript
View bubbleSort.js
// Normal
const bubbleSort = function(array) {
let swaps;
do {
swaps = false;
for (let i = 0; i < array.length - 1; i++) {
if (array[i] > array[i + 1]) {
let temp = array[i + 1];
array[i + 1] = array[i];
array[i] = temp;