Skip to content

Instantly share code, notes, and snippets.

View dasunsucharith's full-sized avatar
💻
Fullstack Web Developer

Dasun Sucharith dasunsucharith

💻
Fullstack Web Developer
View GitHub Profile
@dasunsucharith
dasunsucharith / caesar.c
Last active April 15, 2022 07:27
My solution to CS50 2022 psets-2 caesar
#include <stdlib.h>
#include <cs50.h>
#include <stdio.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. If your program
@dasunsucharith
dasunsucharith / readability.c
Last active April 15, 2022 07:28
My solution to CS50 2022 psets-2 readability
#include <cs50.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
int count_letters (string text);
int count_words (string text);
int count_sentences(string text);
@dasunsucharith
dasunsucharith / scrabble.c
Created April 15, 2022 07:20
My solution to CS50 2022 lab-2 scrabble
#include <ctype.h>
#include <cs50.h>
#include <stdio.h>
#include <string.h>
// Points assigned to each letter of the alphabet
int POINTS[] = {1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 1, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10};
// ASCII values for upercase letters
int uc_letters[] = {65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90};
@dasunsucharith
dasunsucharith / mario-less.c
Created April 15, 2022 07:23
My solution to CS50 2022 psets-1 mario-less
#include <cs50.h>
#include <stdio.h>
int main(void)
{
int h;
do
{
h = get_int("Height: ");
@dasunsucharith
dasunsucharith / mario.c
Created April 15, 2022 07:24
My solution to CS50 2022 psets-1 mario-more
#include <cs50.h>
#include <stdio.h>
int main(void)
{
int h;
do {
h = get_int("Height: ");
}
@dasunsucharith
dasunsucharith / cash.c
Created April 15, 2022 07:25
My solution to CS50 2022 psets-1 cash
#include <cs50.h>
#include <stdio.h>
int get_cents(void);
int calculate_quarters(int cents);
int calculate_dimes(int cents);
int calculate_nickels(int cents);
int calculate_pennies(int cents);
int main(void)
@dasunsucharith
dasunsucharith / credit.c
Created April 15, 2022 07:26
My solution to CS50 2022 psets-2 credit
#include <cs50.h>
#include <stdio.h>
//AMERX 15 STRT 34 OR 37
//MC 16 STRT 51, 52, 53, 54, 55
//VZA 13 OR 16 STRT 4
int main(void)
{
long creditNumber;
@dasunsucharith
dasunsucharith / substitution.c
Created April 15, 2022 18:10
My solution to CS50 2022 psets-2 substitution
#include <cs50.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
void substitution(string key);
void substitution_value(char position, string key);
int main(int argc, string argv[])
{
@dasunsucharith
dasunsucharith / plurality.c
Created April 19, 2022 00:20
My solution to CS50 2022 psets3 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
{
@dasunsucharith
dasunsucharith / runoff.c
Created April 21, 2022 15:41
My Solution to CS50 2022 psets-3 runoff
#include <cs50.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
// Max voters and candidates
#define MAX_VOTERS 100
#define MAX_CANDIDATES 9
// preferences[i][j] is jth preference for voter i