Skip to content

Instantly share code, notes, and snippets.

View Edmundworks's full-sized avatar

Edmund Cuthbert Edmundworks

View GitHub Profile
from cs50 import get_float
# Get positive float from user
while True:
change = get_float("Change owed: ")
if change > 0:
break
# declare counters
quarters, dimes, nickels, pennies = 0, 0, 0, 0
# make total
for i in range(100)
if i % 3 == 0 and i % 5 == 0:
print("FizzBuzz")
elif i % 3 == 0:
print("Fizz")
elif i % 5 == 0:
print("Buzz")
else print i
// Program prints numbers 1-100
// For multiples of 3 print Fizz
// For multiples of 5 print buzz
// For multiples of BOTH print FizzBuzz
// Make an array of ints
// Make a for loop that prints the ith int in the array up until i = 100
// Add if array[i] % 3 != 0 then print buzz
// Add same for % 5
// Add for both
#include <cs50.h>
#include <stdio.h>
#include <math.h>
//notes to self, it works for entering numbers as pennies ie 85 for $0.85
//need to take input as float and convert to int
//need to prompt user again if input is negative or not a number
//need to remove printf of each coin so output is just total
int main(void)
#include <cs50.h>
#include <stdio.h>
#include <math.h>
int main(void)
{
int change = get_int("change owed: ");
int quarter_count = 0;
quarter_count = ((change - (change % 25)) / 25);
{
int n;
do
n = get_int("change owed: ");
while (n < 0);
int quarter_counter = 0;
int dime_counter = 0;
int nickel_counter = 0;
int penny_counter = 0;
@Edmundworks
Edmundworks / coin2
Created June 27, 2018 10:04
coin 2
cases when the amount cannot be made up:
amount < min-denomination
smallest-remainder-of-amount / min-denom is not an integer
actually the above isn't right - if the coins were say 71, 4 and 3 and the amount was 75
@Edmundworks
Edmundworks / coin
Created June 26, 2018 11:52
Coin Change
https://leetcode.com/problems/coin-change/description/
cond (> amount min-denom)
coin-iter
else
-1))
define coin-iter
if (> amount max-denom
@Edmundworks
Edmundworks / SICP Lec2A
Created June 17, 2018 14:54
Working through Lec2A
define (sum term A next B)
(IF (> A B)
0
(+ (term A)
(sum term
(next A)
next
B))))
define (sum-int A B)
@Edmundworks
Edmundworks / pascals
Last active May 29, 2018 20:59
SICP 1.12
(define (pascal row col)
cond (> col row) 0))
(= col row) 1))
(> col row) 1))
else (+ (pascal (- row 1) (- col 1)
(pascal (- row 1) col))))))