Skip to content

Instantly share code, notes, and snippets.

@langrenfengzi
Created May 25, 2015 12:12
Show Gist options
  • Save langrenfengzi/e67f7fd50cb2d392b43d to your computer and use it in GitHub Desktop.
Save langrenfengzi/e67f7fd50cb2d392b43d to your computer and use it in GitHub Desktop.
How much did you spend on subway in a month in BeiJing
function monthlyCost(price){
var sum = 0;
var n = 23;
var d08,d05;
d08 = price * 0.8;
d05 = price * 0.5;
for(var i=0;i<n*2;i++){
sum += price;
if(sum>=100 && price > d08){
price = d08;
console.info((i/2)+" day 80%");
}else if(sum >= 150 && price > d05){
price = d05;
console.info((i/2)+" day 50%");
}
}
console.info("one month cost " + sum);
}
@langrenfengzi
Copy link
Author

Now it's monthlyCost(7), about 232. :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment