<commit_before>#include <stdio.h>
#include "common.h"

/*

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.

Find the largest palindrome made from the product of two 3-digit numbers.

*/

/* function to reverse the order of digits in int using some fancy base 10 arithmetic magic */
int reverse(int n){
	int r = 0;
	while(n > 0){
		r = 10*r + n % 10;
		n = n/10;
	}
	return r;
}

/* function to check if an int is a palindrome, no more no less */
bool is_palindrome(int n){
	int m = reverse(n);
	if(m == n){
		return true;
	} else {
		return false;
	}	
}

/* nested loops, counting downwards, inner loop breaks if product is smaller than largest palindrome so far, otherwise checks if product is palindrome */
void problem_004(void){
	int largest_palindrome = 0;
	int product;
	int j,k;	
	for(j = 999; j >= 100; j--){
		for(k = 999; k >= 100; k--){
			product = j*k;
			if(product <= largest_palindrome){
				break;
			} else if(is_palindrome(product)) {
				largest_palindrome = product;				
			}
		}
	}
	printf("%i",largest_palindrome);	<commit_msg>edited comment to reflect changes in code<commit_after>#include <stdio.h>
#include "common.h"

/*

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.

Find the largest palindrome made from the product of two 3-digit numbers.

*/

/* function to reverse the order of digits in int using some fancy base 10 arithmetic magic */
int reverse(int n){
	int r = 0;
	while(n > 0){
		r = 10*r + n % 10;
		n = n/10;
	}
	return r;
}

/* function to check if an int is a palindrome, uses bool type from common.h */
bool is_palindrome(int n){
	int m = reverse(n);
	if(m == n){
		return true;
	} else {
		return false;
	}	
}

/* nested loops, counting downwards, inner loop breaks if product is smaller than largest palindrome so far, otherwise checks if product is palindrome */
void problem_004(void){
	int largest_palindrome = 0;
	int product;
	int j,k;	
	for(j = 999; j >= 100; j--){
		for(k = 999; k >= 100; k--){
			product = j*k;
			if(product <= largest_palindrome){
				break;
			} else if(is_palindrome(product)) {
				largest_palindrome = product;				
			}
		}
	}
	printf("%i",largest_palindrome);	
{'fraction_non_alphanumeric': 0.1137051448335495, 'fraction_numerical': 0.0311284046692607, 'mean_word_length': 3.3091247672253257, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '6459015', 'n_tokens_mistral': 927, 'n_tokens_neox': 797, 'n_words': 305}