Skip to content

Instantly share code, notes, and snippets.

View CraigRodrigues's full-sized avatar

Craig Rodrigues CraigRodrigues

View GitHub Profile
@CraigRodrigues
CraigRodrigues / dictionary.c
Created September 8, 2016 00:10
CS50 Problem Set 5 - Mispellings
/**
* dictionary.c
*
* Computer Science 50
* Problem Set 5
*
* Implements a dictionary's functionality.
*/
#include <stdbool.h>
@CraigRodrigues
CraigRodrigues / palindrome.c
Created August 12, 2016 01:01
Project Euler 4 - Largest Palindrome Product
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
bool isPalindrome(int num);
int main(void)
{
@CraigRodrigues
CraigRodrigues / circular_array.c
Created August 4, 2016 12:48
HackerRank - Algorithms - Warmup - Circular Array Rotation
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
// https://www.hackerrank.com/challenges/circular-array-rotation
int main(void)
{
int n, k, q;
@CraigRodrigues
CraigRodrigues / timeconversion.c
Created August 4, 2016 12:17
HackerRank - Algorithms - Warmup - Time Conversion
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>
int main(void)
{
@CraigRodrigues
CraigRodrigues / triplets.c
Last active August 3, 2016 14:43
HackerRank - Algorithms - Warmup - Compare the Triplets
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>
int main(){
int alice_score = 0;
@CraigRodrigues
CraigRodrigues / greedy.c
Created August 3, 2016 02:40
CS50 Pset1 - Greedy
#include <stdio.h>
#include <cs50.h>
#include <math.h>
/** Write a program that first asks the user how much change is owed
and then spits out the minimum number of coins with which said change
can be made.*/
int main(void)
{
@CraigRodrigues
CraigRodrigues / reverse.c
Last active July 9, 2016 14:22
Reverse String - Write a function that takes a string as input and returns the string reversed.
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
char* reverseString(char* s) {
int length = 0, i = 0;
length = strlen(s);
char temp[1];
@CraigRodrigues
CraigRodrigues / degree.c
Last active July 8, 2016 21:01
[2016-06-27] Challenge #273 [Easy] Getting a degree (with bonus)
/**
* degree.c
*
* Reddit Daily Programmer Challenge #273 [EASY]
* Getting a degree
*
* https://www.reddit.com/r/dailyprogrammer/comments/4q35ip/20160627_challenge_273_easy_getting_a_degree/
*
*/
@CraigRodrigues
CraigRodrigues / bag.c
Last active July 7, 2016 17:01
[2016-06-20] Challenge #272 [Easy] What's in the bag?
#include <cs50.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main (void)
{
int tilecount[] = { 9, 2, 2, 4, 12, 2, 3, 2, 9, 1, 1, 4, 2, 6, 8, 2, 1, 6,
4, 6, 4, 2, 2, 1, 2, 1, 0, 0, 0, 0, 2 };
@CraigRodrigues
CraigRodrigues / RPS.js
Last active June 22, 2016 20:55
Codecademy Javascript Unit 2 - Rock, Paper, Scissors
var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "rock";
} else if (computerChoice <= 0.67) {
computerChoice = "paper";
} else {
computerChoice = "scissors";
} console.log("Computer: " + computerChoice);