Post Reply 
How much money to add on a Metrocard
06-05-2014, 11:13 PM
Post: #1
How much money to add on a Metrocard
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 Smile 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:
   
Find all posts by this user
Quote this message in a reply
06-06-2014, 04:18 AM
Post: #2
RE: How much money to add on a Metrocard
This is a little shorter:
Code:
LBL "MTRCRD"
380
*
50
MOD
END

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
06-07-2014, 08:30 PM
Post: #3
RE: How much money to add on a Metrocard
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.
Find all posts by this user
Quote this message in a reply
06-09-2014, 06:15 PM
Post: #4
RE: How much money to add on a Metrocard
some of us can't solve Diophantine equations in crowded subways Smile

Also, when the MTA raises fares and changes the bonus, you'd have to re-derive your constants!
Find all posts by this user
Quote this message in a reply
06-09-2014, 09:53 PM
Post: #5
RE: How much money to add on a Metrocard
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
1.05 ÷ 0.4  = 2;  r = 0.25
0.4 ÷ 0.25  = 1;  r = 0.15
0.25 ÷ 0.15 = 1;  r = 0.1
0.15 ÷ 0.1  = 1;  r = 0.05
0.1 ÷ 0.05  = 2;  r = 0

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
2.5   = 2.5                    1     0
1.05  =            1.05        0     1
0.4   = 2.5  - 2 × 1.05        1    -2
0.25  = 1.05 - 2 × 0.4        -2     5
0.15  = 0.4  -     0.25        3    -7
0.1   = 0.25 -     0.15       -5    12
0.05  = 0.15 -     0.1         8   -19

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
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)