diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 0000000..a1ba71c --- /dev/null +++ b/INSTALL.md @@ -0,0 +1 @@ +### Installation Instructions: \ No newline at end of file diff --git a/README.md b/README.md index 4fed924..e01bc64 100644 --- a/README.md +++ b/README.md @@ -1 +1,15 @@ -# Git Lab 1 +# Christopher Holley +## **RESOURCES** +- 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 diff --git a/gitignore b/gitignore new file mode 100644 index 0000000..e69de29 diff --git a/old.txt b/old.txt new file mode 100644 index 0000000..e69de29 diff --git a/problem1.py b/problem1.py new file mode 100644 index 0000000..5360fbb --- /dev/null +++ b/problem1.py @@ -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]) \ No newline at end of file diff --git a/problem2.js b/problem2.js new file mode 100644 index 0000000..c208804 --- /dev/null +++ b/problem2.js @@ -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]); + } +} \ No newline at end of file diff --git a/styles.css b/styles.css new file mode 100644 index 0000000..4314469 --- /dev/null +++ b/styles.css @@ -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; +} diff --git a/website.html b/website.html new file mode 100644 index 0000000..9863b35 --- /dev/null +++ b/website.html @@ -0,0 +1,17 @@ + + + +
+ + + + +