Skip to content

Instantly share code, notes, and snippets.

@zenzora
Created March 21, 2017 16:48
Show Gist options
  • Save zenzora/5c4b7e0d761d4f7efca15dfc11e9400d to your computer and use it in GitHub Desktop.
Save zenzora/5c4b7e0d761d4f7efca15dfc11e9400d to your computer and use it in GitHub Desktop.
New amount to add to NYC metrocards to avoid having leftover credit (current as of 3/20/17)
Inspired by an out of date article found here http://gothamist.com/2015/01/25/metrocard_math_fare_hike.php
What amount should you put on your metro card to avoid having money left over (bonus start at 5.50)
http://web.mta.info/nyct/fare/FaresatAGlance.htm
Amount you add: 7.86
Amount on card with bonus: 8.25
Rides: 3.0
Remaining: 0.01
Amount you add: 28.81
Amount on card with bonus: 30.25
Rides: 11.0
Remaining: 0.0
Amount you add: 31.43
Amount on card with bonus: 33.0
Rides: 12.0
Remaining: 0.0
Amount you add: 34.05
Amount on card with bonus: 35.75
Rides: 13.0
Remaining: 0.01
Amount you add: 36.67
Amount on card with bonus: 38.5
Rides: 14.0
Remaining: 0.01
--- Python code I used to come up with this ---
import math
costPerRide = 2.75
buying = 5.50
while(buying < 50):
withbonus = buying * 1.05
remainder = (withbonus % costPerRide) * costPerRide
if remainder < .01:
print "Amount you add: " + str(buying)
print "Amount on card with bonus: " + str(round(withbonus,2))
print "Rides: " + str(math.floor(withbonus/costPerRide))
print "Remaining: " + str(round(remainder,2))
print ""
buying += .01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment