Image not available

750x562

hello.jpg

๐Ÿ—‘๏ธ ๐Ÿงต Deposit to Bills Algorithm

Anonymous 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,fifties,hundreds]
//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 No. 16300962

>>16300938
Obvious homework thread is obvious, OP.

Just learn what the modulus operator does. This is the purpose of this exercise.

Anonymous 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.

Image not available

471x843

so_far.png

Anonymous No. 16300980

This is what I have so far, it works, but will always give the highest denomination of bills. I need a way to break them to smaller constituent bills.

Anonymous No. 16300984

>homework thread