<commit_before>
function dollar_string(num)
{
	var s = num.toString();
	var decimal_idx = s.indexOf('.');
	if (decimal_idx > 0)
	{
		var num_decimals = s.substr(decimal_idx+1,s.length).length;

		if (num_decimals == 1)
		{
			s += '0';
		}
		else if (num_decimals > 2)
		{
			s = s.substr(0,decimal_idx+3);
		}
	}
	else
	{
		s += '.00';
	}

	return s;
}

function is_palindrome(num)
{
	var s = dollar_string(num).replace('.','');
	return s == s.split('').reverse().join('');
}

function calculate_tip_percent(total, original)
{
	total = parseFloat(total);
	original = parseFloat(original);
	var amt = (1. * total / original) - 1; 
	return dollar_string(amt * 100.);
}

function calculate_tip_dollar(total, original)
{
	total = parseFloat(total);
	original = parseFloat(original);
	return dollar_string(total - original);
}

function find_palintip(amount, target_tip_percent)
{
	var total = amount * (1 + target_tip_percent / 100.);

	var lower = total;
	var upper = total;
	while (!is_palindrome(lower))
	{
		lower -= .01;
	}

	while (!is_palindrome(upper))
	{
		upper += .01;
	}

	lower = dollar_string(lower)
	upper = dollar_string(upper)

	if (lower == upper)
	{
		return [lower];
	}

	return [lower, upper];
}

var bill = 54;
var tip = 20;

var totals = find_tipindrome(bill, tip);

for (var i=0; i<totals.length; i++)
{
	var total = totals[i];
	console.log("total: " + total + 
		", tip $: " + calculate_tip_dollar(total, bill) + 
		", tip %: " + calculate_tip_percent(total, bill));
}<commit_msg>switched from underscore to camel case<commit_after>
function dollarString(num)
{
	var s = num.toString();
	var decimalIdx = s.indexOf('.');
	if (decimalIdx > 0)
	{
		var numDecimals = s.substr(decimalIdx+1,s.length).length;

		if (numDecimals == 1)
		{
			s += '0';
		}
		else if (numDecimals > 2)
		{
			s = s.substr(0,decimalIdx+3);
		}
	}
	else
	{
		s += '.00';
	}

	return s;
}

function isPalindrome(num)
{
	var s = dollarString(num).replace('.','');
	return s == s.split('').reverse().join('');
}

function calculateTipPercent(total, original)
{
	total = parseFloat(total);
	original = parseFloat(original);
	var amt = (1. * total / original) - 1; 
	return dollarString(amt * 100.);
}

function calculateTipDollar(total, original)
{
	total = parseFloat(total);
	original = parseFloat(original);
	return dollarString(total - original);
}

function findPalintip(amount, targetTipPercent)
{
	var total = amount * (1 + targetTipPercent / 100.);

	var lower = total;
	var upper = total;
	while (!isPalindrome(lower))
	{
		lower -= .01;
	}

	while (!isPalindrome(upper))
	{
		upper += .01;
	}

	lower = dollarString(lower)
	upper = dollarString(upper)

	if (lower == upper)
	{
		return [lower];
	}

	return [lower, upper];
}

// var bill = 54;
// var tip = 20;

// var totals = find_tipindrome(bill, tip);

// for (var i=0; i<totals.length; i++)
// {
// 	var total = totals[i];
// 	console.log("total: " + total + 
// 		", tip $: " + calculate_tip_dollar(total, bill) + 
// 		", tip %: " + calculate_tip_percent(total, bill));
// }
{'fraction_non_alphanumeric': 0.17270929466051418, 'fraction_numerical': 0.017798286090969017, 'mean_word_length': 3.6549079754601226, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '7604672', 'n_tokens_mistral': 1258, 'n_tokens_neox': 1158, 'n_words': 257}