3 ms·
The different sizes make it possible to select a given denomination without either doing an O(n) lookup, or having to keep your wallet sorted.
by abstractbill 15y ago
The different sizes make it possible to select a given denomination without either doing an O(n) lookup, or having to keep your wallet sorted.
- staunch 15y agoWhat sort of barbarian programmer doesn't sort his bills? Unthinkable.
- abstractbill 15y agoHaving different sized bills is kind of like keeping your money in a visual/tactile hash-table. An array is the wrong data structure for your wallet!
- Harkins 15y agoThe kind that profiles. The common case to optimize for may be insertion (especially with US $1 notes) rather than withdrawl. Semi-sorting by putting all change at the front while withdrawing for payment from the large bills at the rear is a decent tradeoff.
- underwater 15y agoThat's what I've found myself having to do. I've never had to have a sorting strategy before living in the US. The lack of distinction between notes is frustrating. I love it when Americans tell me they have colored notes too. I still can't understand the preference for one dollar notes. Whenever I use a washing or vending machine I need to flatten out and align a dollar bill or insert dozens of quarters. Every few weeks I have to buy a couple of rolls of quarters from the bank. I paid a cashier with dollar coins yesterday and she did a double take and inspected each coin.
- nakkiel 15y agoYou actually got me to realize how natural it is for me to sort my bank notes. I also put older notes on the top of the stack so that they get out of it first.
- varikin 15y agoI can't be bothered to manually sort something. Tell me when I can just call wallet.sort().