How much money to add on a Metrocard - Printable Version +- HP Forums ( https://www.hpmuseum.org/forum)+-- Forum: HP Calculators (and very old HP Computers) ( /forum-3.html)+--- Forum: General Forum ( /forum-4.html)+--- Thread: How much money to add on a Metrocard ( /thread-1552.html) |

How much money to add on a Metrocard - John Ioannidis - 06-05-2014 11:13 PM
If you don't live in NYC, or don't visit often enough to keep a Metrocard, you may stop reading now. One of the manifestations of my OCD is that I must have a remainder on my Metrocard that's an integral number of rides. It's easy to do now if you just start with $50 (so $52.50 with the bonus), but if you happen to take PATH, it will leave you in a stepping-on-sidwalk-cracks type of situation Eventually they'll raise the fare again and maybe even change the bonus percentage, so the situation will worsen. Now, I happen to have an android phone in my pocket, but should I write an android app for it? God forbid! I wrote an HP41 program for my trusty go41cx emulator. It takes the remaining value on your card in the X register, and shows how much you should add to make it an integral multiple of the fare when you consider the bonus The fare (2.50, line 13) and bonus multiplier (1.05, line 8) are hardwired in the program, but changing it every few years by hand shouldn't be a problem. Enjoy: [attachment=758] RE: How much money to add on a Metrocard - Thomas Klemm - 06-06-2014 04:18 AM
This is a little shorter: Code: `LBL "MTRCRD"` Cheers Thomas RE: How much money to add on a Metrocard - Egan Ford - 06-07-2014 08:30 PM
I travel there monthly and always have a metrocard with a balance in my wallet, however I've been spared the OCD. I just check the balance, add a 20, and from time to time I hit zero spot on--small victories. BTW, if you find yourself with multiple cards or your card is fading fast, you can turn in to any attendant to combine or refresh. RE: How much money to add on a Metrocard - John Ioannidis - 06-09-2014 06:15 PM
some of us can't solve Diophantine equations in crowded subways Also, when the MTA raises fares and changes the bonus, you'd have to re-derive your constants! RE: How much money to add on a Metrocard - Thomas Klemm - 06-09-2014 09:53 PM
If you have an HP-42S you can use this program: u: how much you should add v: the remaining value on your card 1.05 u + v ≡ 0 (2.5) gcd(1.05, 2.5) = 0.05 Thus we multiply the equation by 20. w = 20 v (here we assume that w is an integer) 21 u + w ≡ 0 (50) 21 u ≡ -1w ≡ 49w (50) 21 ENTER 49 ENTER 50 XEQ 'CONG' 19 u ≡ 19 w (50) u ≡ 19 × 20 v (50) Here's how you can solve it manually. We use the Euclidean algorithm to calculate the gcd(1.05, 2.5): Code: `2.5 ÷ 1.05 = 2; r = 0.4` Thus gcd(1.05, 2.5) = 0.05. We know it can be expressed in this manner: 0.05 = 2.5 x + 1.05 y In this table we're keeping track of the multipliers x and y: Code: ` x y` And indeed: 2.5 × 8 - 1.05 × 19 = 0.05 or 2.5 × 8 = 1.05 × 19 + 0.05 For each 0.05 we have to add 19 × 1.05 to end up at an integer multiple of 2.5. But we never have to add more than 50 × 0.05 = 2.5. Thus we divide the remaining value on your card by 0.05 (or multiply by 20) and multiply that by 19 which is 380 altogether. From this we take the remainder after division by 50. Cheers Thomas |