๐๏ธ ๐งต Deposit to Bills Algorithm
Anonymous at Sun, 28 Jul 2024 21:44:38 UTC No. 16300938
Ok /sci/ I am requesting your assistance. I am trying to make a function that converts a total deposit into constituent bills. Cents will not be in this function. I just need to wrap my head around it.
Examples of what I need:
Deposit = 253
bills = deposit_to_bills(253)//returns an array of bills where each index represents a different bill count
//[ones,twos,fives,tens,twentys,fif
//if there is no bill, the value shall be false, if there is, that section of the array will be the number
Bills could be 2 hundreds, 1 fifty, and 3 ones.
//[3,false,false,false,false,1,2]
//this is the style returned
Bills could ALSO be 5 fifties, 3 ones.
Bills could ALSO be 1 hundred, 7 twenties, 1 ten, and 3 ones
I have yet to wrap my head around an algorithm for this, and I hope someone can help. I'm trying to replicate a standard bank deposit, but need to generate random bills for each deposit. I've been banging my head against a wall for the past hour and still can't get it to work.
Thanks in advance!
Anonymous at Sun, 28 Jul 2024 21:55:06 UTC No. 16300962
>>16300938
Obvious homework thread is obvious, OP.
Just learn what the modulus operator does. This is the purpose of this exercise.
Anonymous at Sun, 28 Jul 2024 21:57:10 UTC No. 16300967
>>16300962
This is not a homework thread, I am trying to make a game. % works fine, but I also need randomness so it isn't always the same bills for the same deposit.
Anonymous at Sun, 28 Jul 2024 22:10:21 UTC No. 16300984
>homework thread