<commit_before>function DebtProto(){this.snowball=0,this.getMinPayment=function(){return"percent"===this.minpaymenttype?Math.max(Math.round(this.balance*this.minpayment),1):this.minpayment},this.getPayment=function(){return(this.makeMin||null===this.payment)&&(this.payment=this.getMinPayment()),this.payment},this.update=function(){this.balance=this.balance*(1+this.rate/12)-this.getPayment(),this.balance=Math.round(this.balance),this.balance<this.payment&&("dollar"===this.getminpaymenttype&&this.balance<this.minpayment&&(this.minpayment=this.balance),this.snowball=this.payment-this.balance,this.payment=this.balance),this.balance<=0&&(this.balance=0,this.minpayment=0,this.snowball=this.payment,this.payment=0)}}function Debt(a,b,c,d,e){this.name=a,this.balance=b,this.rate=c,this.payment="dollar"===e?d:d*b,this.makeMin=!0,this.minpayment=d,this.minpaymenttype=e,$.extend(this,new DebtProto)}function avalanche(a,b){var c=a.reduce(function(a,b){return a+b.snowball},0);if(c>0){var d=a.filter(function(a){return 0==a.snowball});if(a.forEach(function(a){a.snowball=0}),d.length>0){var e=b(d);e.payment=e.payment+c,e.makeMin=!1}}}function sumBalances(a){return a.reduce(function(a,b){return a+b.balance},0)}function sumMinpayments(a){return a.reduce(function(a,b){return a+b.getMinPayment()},0)}function sumPayments(a){return a.reduce(function(a,b){return a+b.getPayment()},0)}function totalAccounts(a){return a.reduce(function(a,b){return a+Math.min(b.balance,1)},0)}function lowestBalance(a){return a.reduce(function(a,b){return null==a?b:a.balance>b.balance?b:a.balance===b.balance&&a.rate<b.rate?b:a})}function highestRate(a){return a.reduce(function(a,b){return null==a?b:a.rate<b.rate?b:a.rate===b.rate&&a.balance>b.balance?b:a})}function usingMethod(a,b){var c=totalAccounts(a);"undefined"!=typeof b&&(b(a).makeMin=!1);for(var d={balances:[["year","balance","minimum payment"],[0,sumBalances(a),sumMinpayments(a)]],accounts:[["month","number of debts"],[0,c]],totalPaid:0,months:0},e=1,f=sumBalances(a);f>0;f=sumBalances(a)){a.forEach(function(a){a.update()}),e%12===0&&d.balances.push([e/12,f,sumMinpayments(a)]);var g=totalAccounts(a);if(g!==c&&(d.accounts.push([e,g]),c=g),d.totalPaid=d.totalPaid+sumPayments(a),"undefined"!=typeof b&&avalanche(a,b),e++,e>500)break}return e%12!=0&&d.balances.push([e/12,sumBalances(a),sumMinpayments(a)]),d.months=e,d}function getResults(a){var b=JSON.parse(JSON.stringify(a));b.forEach(function(a){$.extend(a,new DebtProto)});var c=JSON.parse(JSON.stringify(a));c.forEach(function(a){$.extend(a,new DebtProto)});var d=JSON.parse(JSON.stringify(a));d.forEach(function(a){$.extend(a,new DebtProto)});var e={highestRate:usingMethod(b,highestRate),lowestBalance:usingMethod(c,lowestBalance),justPayments:usingMethod(d)};return e}function getTimeString(a){var b=Math.floor(a/12),c=a-12*b;return b+" years "+c+" months"}function generateRow(a){var b="<input type='text' name='name' value='"+a.name+"' required />",c="<span class='input-dollar'>$</span><input type='number' name='balance' class='input-dollar' min='0' value='"+a.balance+"' required />",d="<input type='number' name='rate' class='input-percent' min='0' max='100' step='0.01' value='"+100*a.rate+"' required /><span class='input-percent'>%</a>",e="<input type='number' name='minpayment' min='0' value='";e+="percent"===a.minpaymenttype?100*a.minpayment:a.minpayment,e+="' required />";var f="<select name='minpaymenttype'><option value='dollar'"+("dollar"===a.minpaymenttype?" selected":"")+">dollar</option><option value='percent'"+("percent"===a.minpaymenttype?" selected":"")+">percent</option></select>",g="<tr><td>"+b+"</td><td>"+c+"</td><td>"+d+"</td><td>"+e+"</td><td>"+f+"</td></tr>";return g}function make(a,b){$("#"+a+"-total-paid").append("$"+b.totalPaid+" in "+getTimeString(b.months)),c3.generate({bindto:"#"+a+"-balance-chart",data:{x:"year",rows:b.balances,type:"spline"},axis:{x:{label:{text:"year",position:"outer-center"}},y:{label:{text:"dollars",position:"outer-middle"}}}}),c3.generate({bindto:"#"+a+"-account-chart",data:{x:"month",rows:b.accounts,type:"area-step"},axis:{x:{label:{text:"month",position:"outer-center"}},y:{label:{text:"number of debts",position:"outer-middle"}}},line:{step:{type:"step-after"}}})}$(document).ready(function(){$("#addRowButton").click(function(){var a=generateRow(new Debt("",0,0,0,0,"dollar"));$("#debt-table tbody").append(a)}),$("#removeRowButton").click(function(){$("#debt-table tbody tr").last().remove()});var a;if(hasKey("name")&&hasKey("balance")&&hasKey("rate")&&hasKey("minpayment"))a=getObjectArray(),a.forEach(function(a){$.extend(a,new DebtProto),a.name=decodeURIComponent(a.name.replace(/\+/g," ")),a.rate=a.rate/100,a.balance=parseInt(a.balance),"percent"===a.minpaymenttype?(a.minpayment=a.minpayment/100,a.payment=a.payment*a.minpayment):(a.minpayment=parseInt(a.minpayment),a.payment=a.minpayment),a.makeMin=!0});else{a=new Array;var b=new Debt("mortgage",15e4,.03,750,"dollar"),c=new Debt("car loan",2e4,.1,250,"dollar"),d=new Debt("credit card 1",5e3,.2,.04,"percent"),e=new Debt("credit card 2",100,.01,.04,"percent");a=[b,c,d,e]}for(var f=0;f<a.length;f++){var g=a[f];$("#debt-table").append(generateRow(g))}var h=getResults(a);make("highest-rate",h.highestRate),make("lowest-balance",h.lowestBalance),make("just-payments",h.justPayments)});<commit_msg>Update avalanche.min.js<commit_after>function DebtProto(){this.getMinPayment=function(){var a;return a="percent"===this.minpaymenttype?Math.max(Math.round(this.balance*this.minpayment),1):this.minpayment,Math.min(a,this.balance)},this.update=function(){return this.balance=this.balance*(1+this.rate/12),this.balance=Math.round(this.balance),this.pay(this.getMinPayment())},this.pay=function(a){var b=0;return this.balance=this.balance-a,this.balance<=0&&(b=-this.balance,this.balance=0,this.minpayment=0),b}}function Debt(a,b,c,d,e){this.name=a,this.balance=b,this.rate=c,this.minpayment=d,this.minpaymenttype=e,$.extend(this,new DebtProto)}function avalanche(a,b,c){var d=c-sumMinpayments(a);for(d+=payDebts(a);d>0;)if(a=getDebtsWithBalances(a),a.length>0){var e=b(a);d=e.pay(d)}else d=0}function payDebts(a){return a.reduce(function(a,b){return a+b.update()},0)}function getDebtsWithBalances(a){return a.filter(function(a){return a.balance>0})}function sumBalances(a){return a.reduce(function(a,b){return a+b.balance},0)}function sumMinpayments(a){return a.reduce(function(a,b){return a+b.getMinPayment()},0)}function totalAccounts(a){return a.reduce(function(a,b){return a+Math.min(b.balance,1)},0)}function lowestBalance(a){return a.reduce(function(a,b){return null==a?b:a.balance>b.balance?b:a.balance===b.balance&&a.rate<b.rate?b:a})}function highestRate(a){return a.reduce(function(a,b){return null==a?b:a.rate<b.rate?b:a.rate===b.rate&&a.balance>b.balance?b:a})}function usingMethod(a,b){for(var c=totalAccounts(a),d=sumMinpayments(a),e={balances:[["month","balance","minimum payment"],[0,sumBalances(a),sumMinpayments(a)]],accounts:[["month","number of debts"],[0,c]],totalPaid:0,months:0},f=1,g=sumBalances(a);g>0&&f<=500;g=sumBalances(a),f++){"undefined"!=typeof b?avalanche(a,b,d):payDebts(a),f%12===0&&e.balances.push([f,g,sumMinpayments(a)]);var h=totalAccounts(a);h!==c&&(e.accounts.push([f,h]),c=h),"undefined"!=typeof b?d<sumBalances(a)?e.totalPaid=e.totalPaid+d:e.totalPaid=e.totalPaid+sumBalances(a):e.totalPaid=e.totalPaid+sumMinpayments(a)}return e.balances.push([f,sumBalances(a),sumMinpayments(a)]),e.months=f,e}function getResults(a){var b=JSON.parse(JSON.stringify(a));b.forEach(function(a){$.extend(a,new DebtProto)});var c=JSON.parse(JSON.stringify(a));c.forEach(function(a){$.extend(a,new DebtProto)});var d=JSON.parse(JSON.stringify(a));d.forEach(function(a){$.extend(a,new DebtProto)});var e={highestRate:usingMethod(b,highestRate),lowestBalance:usingMethod(c,lowestBalance),justPayments:usingMethod(d)};return e}function getTimeString(a){var b=Math.floor(a/12),c=a-12*b;return b+" years "+c+" months"}function generateRow(a){var b="<input type='text' name='name' value='"+a.name+"' required />",c="<span class='input-dollar'>$</span><input type='number' name='balance' class='input-dollar' min='0' value='"+a.balance+"' required />",d="<input type='number' name='rate' class='input-percent' min='0' max='100' step='0.01' value='"+100*a.rate+"' required /><span class='input-percent'>%</a>",e="<input type='number' name='minpayment' min='0' value='";e+="percent"===a.minpaymenttype?100*a.minpayment:a.minpayment,e+="' required />";var f="<select name='minpaymenttype'><option value='dollar'"+("dollar"===a.minpaymenttype?" selected":"")+">dollar</option><option value='percent'"+("percent"===a.minpaymenttype?" selected":"")+">percent</option></select>",g="<tr><td>"+b+"</td><td>"+c+"</td><td>"+d+"</td><td>"+e+"</td><td>"+f+"</td></tr>";return g}function make(a,b){$("#"+a+"-total-paid").append("$"+b.totalPaid.toLocaleString()+" in "+getTimeString(b.months)),c3.generate({bindto:"#"+a+"-balance-chart",data:{x:"month",rows:b.balances,type:"spline"},axis:{x:{label:{text:"month",position:"outer-center"}},y:{label:{text:"dollars",position:"outer-middle"}}}}),c3.generate({bindto:"#"+a+"-account-chart",data:{x:"month",rows:b.accounts,type:"area-step"},axis:{x:{label:{text:"month",position:"outer-center"}},y:{label:{text:"number of debts",position:"outer-middle"}}},line:{step:{type:"step-after"}}})}$(document).ready(function(){$("#addRowButton").click(function(){var a=generateRow(new Debt("",0,0,0,0,"dollar"));$("#debt-table tbody").append(a)}),$("#removeRowButton").click(function(){$("#debt-table tbody tr").last().remove()});var a;if(hasKey("name")&&hasKey("balance")&&hasKey("rate")&&hasKey("minpayment"))a=getObjectArray(),a.forEach(function(a){$.extend(a,new DebtProto),a.name=decodeURIComponent(a.name.replace(/\+/g," ")),a.rate=a.rate/100,a.balance=parseInt(a.balance),"percent"===a.minpaymenttype?a.minpayment=a.minpayment/100:a.minpayment=parseInt(a.minpayment)});else{a=new Array;var b=new Debt("credit card 1",3e3,.13,.04,"percent"),c=new Debt("credit card 2",8e3,.16,.04,"percent");a=[b,c]}for(var d=0;d<a.length;d++){var e=a[d];$("#debt-table").append(generateRow(e))}var f=getResults(a);make("highest-rate",f.highestRate),make("lowest-balance",f.lowestBalance),make("just-payments",f.justPayments)});
{'fraction_non_alphanumeric': 0.26151603498542275, 'fraction_numerical': 0.017201166180758017, 'mean_word_length': 15.439297124600639, 'pattern_counts': {'":': 4, '<': 67, '<?xml version=': 0, '>': 67, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5961064', 'n_tokens_mistral': 3964, 'n_tokens_neox': 3829, 'n_words': 238}