Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .gitignore
Empty file.
1 change: 1 addition & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### Installation Instructions:
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
# Git Lab 1
# Christopher Holley
## <ins>**RESOURCES**</ins>
- https://www.markdownguide.org/hacks/
- Github Copilot
- https://stackoverflow.com/questions/14907067/how-do-i-restart-a-program-based-on-user-input
- https://www.geeksforgeeks.org/how-to-read-command-line-arguments-in-node-js/#
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
- https://stackoverflow.com/questions/20864893/replace-all-non-alphanumeric-characters-new-lines-and-multiple-white-space-wit
- https://www.w3schools.com/html/html_form_input_types.asp
- https://www.w3schools.com/html/html_css.asp
- https://brand.ncssm.edu/fonts-and-colors
- https://stackoverflow.com/questions/15843391/div-height-set-as-percentage-of-screen
- https://dequeuniversity.com/rules/axe/4.4/color-contrast
- https://www.w3schools.com/jsref/jsref_split.asp
- https://stackoverflow.com/questions/1374126/how-to-extend-an-existing-javascript-array-with-another-array-without-creating
Empty file added gitignore
Empty file.
Empty file added old.txt
Empty file.
40 changes: 40 additions & 0 deletions problem1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import sys

def main(money_str):
"""
Prints out the minimum number of coins to make a dollar amount, i.e $4.42

Args:
money_str: A string of the form $X.YZ where X <= 100, and Y and Z are both integers 0 <= x <= 9

Returns:
None, has side effect of printing

Raises:
AssertationError if input is not valid, may also exit
"""
currency = [("dollar", "dollars", 100), ("quarter", "quarters", 25), ("dime", "dimes", 10), ("nickel", "nickels" , 5), ("penny", "pennies", 1)]
if len(money_str) != 1:
print("Exactly one argument is required: usage `python problem1.py \$X.YZ`")
exit(-1)
money = money_str[0]
assert money[0] == '$', "\nThe input should start with a dollar sign. Make sure to escape this if on linux."
dollars = money[1:] # remove $
dollars, cents = dollars.split('.')
assert len(cents) == 2, "\nThe cent amount should be two digits"
assert dollars.isdigit(), "\nThe dollar amount should be a number"
assert 0 <= int(dollars) <= 100, "\nThe dollar amount should be between 0 and 100"
assert 0 <= int(cents) <= 99, "\nThe cent amount should be between 0 and 99"
total = int(dollars) * 100 + int(cents)

current = 0
for name, plural_name, value in currency:
if total >= value:
count = total // value # find most whole number of currency that fits
total -= count * value # remove the amount of currency from the total
name = plural_name if count > 1 else name
print(f"{count} {name}")
current += count

if __name__ == "__main__":
main(sys.argv[1:][0])
40 changes: 40 additions & 0 deletions problem2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
let arguments = process.argv;
if (arguments.length < 3) {
console.log('ERROR: You must provide at least one string');
return;
}
arguments = arguments.slice(2);
split_arguments = []
for (let arg of arguments) {
// woah the "spead" operator is really neat
// split returns an array and ... (functionally) appends each element to split_arguments without another for loop
// probably equal to concat? this avoids a copy which totally doesn't matter here
split_arguments.push(...arg.split(" "));
}

// console.log(split_arguments);
// has key of lowercase word, value of [original case, number of occurances]
const word_map = new Map();

for (let word of split_arguments) {
// console.log(word);
word_lower = word.toLowerCase();

// only want to update occurances, not original case of word after we find a new word
if (!word_map.has(word_lower)) {
word_map.set(word_lower, [word, 1]);
}
else {
updated_count = word_map.get(word_lower);
updated_count[1] += 1
word_map.set(word_lower, updated_count)
}
}
//console.log(word_map);

for (let kv of word_map.entries()) {
occurances = kv[1];
if (occurances[1] > 1) {
console.log(occurances[0]);
}
}
19 changes: 19 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
body {
background: #346094;
}

div.form
{
text-align: center;
color: #b2b1b1;
}


input {
background-color: #8a8a8d;
color: #000;
font-size: xxx-large;
font-style: bold;
width: 80vw;
height: 23.33vh;
}
17 changes: 17 additions & 0 deletions website.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="styles.css">
<!-- https://webaim.org/resources/contrastchecker/ This is large text (i hope) -->
</head>
<body>
<div class="form">
<form>
<input type="text" name="username" placeholder="Enter username" ><br>
<input type="password" name="password" placeholder="Enter password"><br>
<input type="color" name="color" value="#00ff00"><br>
</form>
</div>
</body>
</html>