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 / log.sql
Created June 5, 2022 10:03
CS50 2022 Psets 7 Fiftyville mystery solution
-- Keep a log of any SQL queries you execute as you solve the mystery.
-- crime happened on july 28, 2021 and it took place on Humphrey Street
-- check the description of the crime in the cime scene reports table at the known day and place
select description from crime_scene_reports
where year=2021 and month = 7 and day = 28 and street = "Humphrey Street";
-- checking the interview stranscripts
@dasunsucharith
dasunsucharith / movies.sql
Created June 5, 2022 05:44
CS50 2022 psets 7 movies solution
-- In 1.sql, write a SQL query to list the titles of all movies released in 2008
select title from movies where year=2008;
-- In 2.sql, write a SQL query to determine the birth year of Emma Stone
select birth from people where name="Emma Stone";
-- In 3.sql, write a SQL query to list the titles of all movies with a release date on or after 2018, in alphabetical order.
@dasunsucharith
dasunsucharith / songs.sql
Created June 5, 2022 02:57
CS50 2022 Lab 7 Songs Solution
-- In 1.sql, write a SQL query to list the names of all songs in the database
SELECT name FROM songs;
-- In 2.sql, write a SQL query to list the names of all songs in increasing order of tempo.
SELECT name FROM songs ORDER BY tempo;
-- In 3.sql, write a SQL query to list the names of the top 5 longest songs, in descending order of length.
SELECT name FROM songs ORDER BY duration_ms DESC LIMIT 5;
-- In 4.sql, write a SQL query that lists the names of any songs that have danceability, energy, and valence greater than 0.75.
@dasunsucharith
dasunsucharith / dna.py
Created May 18, 2022 02:53
CS50 2022 psets6 dna problem solution
import csv
import sys
def main():
# TODO: Check for command-line usage
if len(sys.argv) != 3:
print("Usage: python dna.py data.csv sequence.txt")
exit()
@dasunsucharith
dasunsucharith / readability.py
Created May 18, 2022 02:52
CS50 2022 psets6 readability problem solution
# TODO
count_letter = 0
count_word = 1
count_sentence = 0
# getting input from user
text = input("Text: ")
text_length = len(text)
@dasunsucharith
dasunsucharith / credit.py
Created May 18, 2022 02:50
CS50 2022 psets6 credit problem solution
# TODO
import sys
def main():
# Get card number from the user
credit_card_number = get_credit_card_number()
@dasunsucharith
dasunsucharith / cash.py
Created May 18, 2022 02:49
CS50 2022 psets6 Cash Problem Solution
# TODO
from cs50 import get_float
# keep track of coins used
count = 0
while True:
change = get_float("Change owned: ")
if change > 0:
break
# round up to the nearest whole number
@dasunsucharith
dasunsucharith / mario.py
Created May 18, 2022 02:48
CS50 2022 Psets 6 Mario-more Problem Solution
# TODO
from cs50 import get_int
# get input from user until input is correct
while True:
try:
height = get_int("Height: ")
if (height >= 1) and (height <= 8):
break
except:
@dasunsucharith
dasunsucharith / mario.py
Created May 18, 2022 02:47
CS50 2022 Psets 6 Mario-less Problem Solution
# TODO
# get input from user until input is correct
while True:
try:
height = int(input("Height: "))
if (height >= 1) and (height <= 8):
break
except:
print("", end="")
@dasunsucharith
dasunsucharith / tournament.py
Created May 17, 2022 10:55
CS50 2022 Lab 6 Tournament Solution
# Simulate a sports tournament
import csv
import sys
import random
# Number of simluations to run
N = 1000