Compare commits
No commits in common. "5617a4e9ec8f2f580e0c8e93ad8c977ddf0b9c7e" and "4944681eef4acfa1347a4ffec1148ab5e756bf7b" have entirely different histories.
5617a4e9ec
...
4944681eef
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +0,0 @@
|
|||||||
*.jar
|
|
2
README.md
Executable file → Normal file
2
README.md
Executable file → Normal file
@ -14,10 +14,10 @@ Project only takes into consideration the USA's cent system.
|
|||||||
Completed:
|
Completed:
|
||||||
|
|
||||||
- PHP
|
- PHP
|
||||||
- Kotlin
|
|
||||||
|
|
||||||
Planned:
|
Planned:
|
||||||
|
|
||||||
|
- Kotlin
|
||||||
- Bash
|
- Bash
|
||||||
- Python
|
- Python
|
||||||
- Node.js
|
- Node.js
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# 2024-03-30 Hyperling
|
|
||||||
# Compile the .kt file and run the compiled binary.
|
|
||||||
|
|
||||||
# Move to the file location.
|
|
||||||
DIR="$(dirname -- "${BASH_SOURCE[0]}")"
|
|
||||||
cd $DIR
|
|
||||||
|
|
||||||
# Compile the script.
|
|
||||||
kotlinc spare_change.kt -include-runtime -d spare_change.kt.jar
|
|
||||||
|
|
||||||
# Run the executable.
|
|
||||||
chmod 755 ./spare_change.kt.jar
|
|
||||||
java -jar spare_change.kt.jar
|
|
||||||
rm -rfv ./spare_change.kt.jar
|
|
@ -1,10 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# 2024-03-30 Hyperling
|
|
||||||
# Run the program as a shell language.
|
|
||||||
|
|
||||||
# Move to the file location.
|
|
||||||
DIR="$(dirname -- "${BASH_SOURCE[0]}")"
|
|
||||||
cd $DIR
|
|
||||||
|
|
||||||
# Run the program.
|
|
||||||
kotlinc -script ./spare_change.kts
|
|
@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
// 2024-03-30 Hyperling
|
|
||||||
// Creating a Kotlin version which needs compiled then run.
|
|
||||||
*/
|
|
||||||
|
|
||||||
fun main() {
|
|
||||||
var pennies: Int
|
|
||||||
var nickels: Int
|
|
||||||
var dimes: Int
|
|
||||||
var quarters: Int
|
|
||||||
var maxPennies: Int = 0
|
|
||||||
var maxNickels: Int = 0
|
|
||||||
var maxDimes: Int = 0
|
|
||||||
var maxQuarters: Int = 0
|
|
||||||
|
|
||||||
println("Got any spare change?")
|
|
||||||
|
|
||||||
for (change in 1..99) {
|
|
||||||
quarters = change / 25
|
|
||||||
var remainder = change % 25
|
|
||||||
|
|
||||||
dimes = remainder / 10
|
|
||||||
remainder = remainder % 10
|
|
||||||
|
|
||||||
nickels = remainder / 5
|
|
||||||
remainder = remainder % 5
|
|
||||||
|
|
||||||
pennies = remainder / 1
|
|
||||||
|
|
||||||
if (quarters > maxQuarters) {
|
|
||||||
maxQuarters = quarters
|
|
||||||
println("Change ${change}c required $maxQuarters quarter(s).")
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dimes > maxDimes) {
|
|
||||||
maxDimes = dimes
|
|
||||||
println("Change ${change}c required $maxDimes dime(s).")
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nickels > maxNickels) {
|
|
||||||
maxNickels = nickels
|
|
||||||
println("Change ${change}c required $maxNickels nickel(s).")
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pennies > maxPennies) {
|
|
||||||
maxPennies = pennies
|
|
||||||
println("Change ${change}c required $maxPennies penny(ies).")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print("The optimum amount is $maxQuarters quarter(s), $maxDimes dime(s)")
|
|
||||||
println(", $maxNickels nickel(s), and $maxPennies pennies.")
|
|
||||||
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
// 2024-03-30 Hyperling
|
|
||||||
// Creating a Kotlin version which can be run via command line.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var pennies = 0
|
|
||||||
var nickels = 0
|
|
||||||
var dimes = 0
|
|
||||||
var quarters = 0
|
|
||||||
var maxPennies = 0
|
|
||||||
var maxNickels = 0
|
|
||||||
var maxDimes = 0
|
|
||||||
var maxQuarters = 0
|
|
||||||
|
|
||||||
println("Got any spare change?")
|
|
||||||
|
|
||||||
for (change in 1..99) {
|
|
||||||
quarters = change / 25
|
|
||||||
var remainder = change % 25
|
|
||||||
|
|
||||||
dimes = remainder / 10
|
|
||||||
remainder = remainder % 10
|
|
||||||
|
|
||||||
nickels = remainder / 5
|
|
||||||
remainder = remainder % 5
|
|
||||||
|
|
||||||
pennies = remainder / 1
|
|
||||||
|
|
||||||
if (quarters > maxQuarters) {
|
|
||||||
maxQuarters = quarters
|
|
||||||
println("Change ${change}c required $maxQuarters quarter(s).")
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dimes > maxDimes) {
|
|
||||||
maxDimes = dimes
|
|
||||||
println("Change ${change}c required $maxDimes dime(s).")
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nickels > maxNickels) {
|
|
||||||
maxNickels = nickels
|
|
||||||
println("Change ${change}c required $maxNickels nickel(s).")
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pennies > maxPennies) {
|
|
||||||
maxPennies = pennies
|
|
||||||
println("Change ${change}c required $maxPennies penny(ies).")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print("The optimum amount is $maxQuarters quarter(s), $maxDimes dime(s)")
|
|
||||||
println(", $maxNickels nickel(s), and $maxPennies pennies.")
|
|
Loading…
x
Reference in New Issue
Block a user