Skip to content

Instantly share code, notes, and snippets.

View voidnerd's full-sized avatar
:octocat:
Debugging

Ndifreke Friday voidnerd

:octocat:
Debugging
View GitHub Profile
@voidnerd
voidnerd / helpers.c
Last active August 25, 2022 12:13
cs50 Problem Set 4 - Filter (less) Solution
#include "helpers.h"
#include <math.h>
// Convert image to grayscale
void grayscale(int height, int width, RGBTRIPLE image[height][width])
{
float rgbGray;
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++) {
#include <stdio.h>
int main(void)
{
int num1 = -1, num2 = -1;
int result;
char key;
printf("Enter two numbers: ");
scanf("%d,%d", &num1, &num2);
@voidnerd
voidnerd / tideman.c
Created April 29, 2020 13:37
cs50 Problem Set 3 - Tideman Solution
#include <cs50.h>
#include <stdio.h>
#include <string.h>
// Max number of candidates
#define MAX 9
// preferences[i][j] is number of voters who prefer i over j
int preferences[MAX][MAX];
@voidnerd
voidnerd / runoff.c
Created April 26, 2020 23:44
CS50 Problem Set 3 - Runoff
#include <cs50.h>
#include <stdio.h>
#include <string.h>
// Max voters and candidates
#define MAX_VOTERS 100
#define MAX_CANDIDATES 9
// preferences[i][j] is jth preference for voter i
int preferences[MAX_VOTERS][MAX_CANDIDATES];
@voidnerd
voidnerd / plurality.c
Created April 19, 2020 21:06
CS50's Problem Set 3 - Plurality
#include <cs50.h>
#include <stdio.h>
#include <string.h>
// Max number of candidates
#define MAX 9
// Candidates have name and vote count
typedef struct
{
@voidnerd
voidnerd / substitution.c
Created April 19, 2020 21:04
CS50's Problem Set 2 - Substitution
#include <stdio.h>
#include <ctype.h>
#include <cs50.h>
#include <string.h>
#include <stdlib.h>
bool isAlpha(string key);
bool hasDuplicates(string key);
int main(int argc, string argv[])
@voidnerd
voidnerd / caesar.c
Last active April 19, 2020 21:05
CS50's Problem Set 2 - Caesar Cipher
#include <stdio.h>
#include <ctype.h>
#include <cs50.h>
#include <string.h>
#include <stdlib.h>
bool isNumber(char number[]);
int main(int argc, string argv[])
{
@voidnerd
voidnerd / readability.c
Last active April 19, 2020 21:05
CS50's Problem Set 2 - Readablity
#include <stdio.h>
#include <cs50.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
int main(void)
{
string text = get_string("Text:");
@voidnerd
voidnerd / mario.c
Created April 11, 2020 02:41
A solution for Harvard / edX CS50 week 1 Mario World 1-1
#include <cs50.h>
#include <stdio.h>
int main(void)
{
int n;
do {
n = get_int("height: ");
}while(n < 1 || n > 8);
@voidnerd
voidnerd / credit.c
Last active April 11, 2020 02:38
A solution for Harvard / edX CS50 week 1 luhn algorithm credit card verification assignment
#include <stdio.h>
#include <cs50.h>
#include <math.h>
int main(void) {
long card_no;
do{
card_no = get_long("Card Number: ");
}while(card_no < 1);