<commit_before>function generatePhoneNumbers(amount, start, end) {
	var numbers = [], i;
	for (i = 0; i < amount; i++) {
		numbers[i] = String(Math.floor(Math.random() * (end - start)) + start + 1);
	}
	return numbers;
}

function calculateScore(numbers) {

	var l = numbers.length;
	var array = [];
	var i, j, k, thisNumber, len;
	var sortedNumbers;

	// Store the numbers to an array of objects
	for (i = 0; i < l; i++) {
		array[i] = {}
		array[i].num = numbers[i];
		array[i].score = 0;
	}

	// Start counting
	for (i = 0; i < l; i++) {
		thisNumber = array[i].num;
		len = thisNumber.length;
		for (j = 0; j < len; j++) {
			thisChar = thisNumber.charAt(j);

			// Check for the amount of occurences
			for (k = 0; k < thisNumber.length; k++) {
				if (k != j && thisChar === thisNumber.charAt(k)) {
					array[i].score += 0.5;
				}
			}

			// Check for adjacency
			if (thisChar === thisNumber.charAt(j - 1) || thisChar === thisNumber.charAt(j + 1)) {
				array[i].score += 2;
			}
		}
	}

	sortedNumbers = array.sort( compare );
	return sortedNumbers;
}

function compare(a, b) {
	if (a.score > b.score)
		return -1;
	if (a.score < b.score)
		return 1;
	return 0;
}
<commit_msg>Improve algorithm by decreasing redundancy, compressing scale and improving performance<commit_after>function generatePhoneNumbers(amount, start, end) {
	var numbers = [], i;
	for (i = 0; i < amount; i++) {
		numbers[i] = String(Math.floor(Math.random() * (end - start)) + start + 1);
	}
	return numbers;
}

function calculateScore(numbers) {

	var l = numbers.length;
	var array = [];
	var i, j, k, thisNumber, len, tempAr;
	var sortedNumbers;

	// Store the numbers to an array of objects
	for (i = 0; i < l; i++) {
		array[i] = {}
		array[i].num = numbers[i];
		array[i].score = 0;
	}

	// Start counting
	for (i = 0; i < l; i++) {
		thisNumber = array[i].num;
		len = thisNumber.length;
		tempAr = [];
		for (j = 0; j < len; j++) {
			thisChar = thisNumber.charAt(j);

			// Only calculate each number once
			if (tempAr.indexOf(thisChar) === -1) {
			
				// Check for the amount of occurences
				for (k = (j + 1); k < thisNumber.length; k++) {
					if (thisChar === thisNumber.charAt(k)) {
						array[i].score += 1;
					}
				}
			}
			
			// Check for adjacency
			if (thisChar === thisNumber.charAt(j + 1)) {
				array[i].score += 2;
			}

			tempAr.push(thisChar);
			
		}
	}

	sortedNumbers = array.sort( compare );
	return sortedNumbers;
}

function compare(a, b) {
	if (a.score > b.score)
		return -1;
	if (a.score < b.score)
		return 1;
	return 0;
}

{'fraction_non_alphanumeric': 0.1699960830395613, 'fraction_numerical': 0.01135918527222875, 'mean_word_length': 2.8290854572713644, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 5, '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': '4972017', 'n_tokens_mistral': 1099, 'n_tokens_neox': 945, 'n_words': 268}