<commit_before>#include "stdio.h"

#define N 11


// o-rigin, r-esult
int o[N] = { 30, 90, 60, 50, 70, 10, 160, 20, 40, 100, 80 };
int r[N] = { 0 };

// a-rray
void print_a(int a[])
{
	int n = N;

	printf("a = [");
	for (int i = 0; i < n; ++i)
	{
		if (i>0)
			printf(",");

		printf("% 4d", a[i]);

	}
	printf("]\n");
}

void insert_sort_a(int a[])
{
	int n = N;
	int sorted_n = 0;

	for (int i = 0; i < n; ++i)
	{
		int to_insert = a[i]; // the "payload"
		int pos_to_put = i; // initial try to put at the end of sorted
		// look from the end of sorted
		for (int j = 0; j < sorted_n; ++j)
		{
			int end = sorted_n-1 - j; // reverse index
			// printf("Looking at end: a[%d] (= %d)\n",end, a[end] );
			//optimal case : payload just fits the end

			if ( a[end] <= to_insert )
			{
				// printf("optimal (%d <= %d): to_insert(= %d) is biggest, no shuffle\n",
				// 	a[end], to_insert,
				// 	to_insert);
				// pos_to_put = end+1; // put right after sorted end
				break; // 
			}
			else
			{
				//shifting right
				a[end+1] = a[end];
				pos_to_put -= 1;
			}
		}
		a[pos_to_put] = to_insert; // deliver payload


		sorted_n = sorted_n + 1;

		// printf("Sorted size: %d\n", sorted_n );
		print_a(o);

	}
}

int main(int argc, char const *argv[])
{
	print_a(o);
	insert_sort_a(o);
	//print_a(r);
	return 0;
}
<commit_msg>bubble<commit_after>#include "stdio.h"

#define N 11


// o-rigin, r-esult
int o[N] = { 30, 90, 60, 50, 70, 10, 160, 20, 40, 100, 80 };
int r[N] = { 0 };

// a-rray
void print_a(int a[])
{
	int n = N;

	printf("a = [");
	for (int i = 0; i < n; ++i)
	{
		if (i>0)
			printf(",");

		printf("% 4d", a[i]);

	}
	printf("]\n");
}

void insert_sort_a(int a[])
{
	int n = N;
	int sorted_n = 0;

	for (int i = 0; i < n; ++i)
	{
		int to_insert = a[i]; // the "payload"
		int pos_to_put = i; // initial try to put at the end of sorted
		// look from the end of sorted
		for (int j = 0; j < sorted_n; ++j)
		{
			int end = sorted_n-1 - j; // reverse index
			// printf("Looking at end: a[%d] (= %d)\n",end, a[end] );
			//optimal case : payload just fits the end

			if ( a[end] <= to_insert )
			{
				// printf("optimal (%d <= %d): to_insert(= %d) is biggest, no shuffle\n",
				// 	a[end], to_insert,
				// 	to_insert);
				// pos_to_put = end+1; // put right after sorted end
				break; // 
			}
			else
			{
				//shifting right
				a[end+1] = a[end];
				pos_to_put -= 1;
			}
		}
		a[pos_to_put] = to_insert; // deliver payload


		sorted_n = sorted_n + 1;

		// printf("Sorted size: %d\n", sorted_n );
		print_a(o);

	}
}

void bubble_sort_a(int a[])
{
	int n_passes = N; // each pass get one max
	for (int i = 0; i < n_passes; ++i)
	{
		int bubble = a[0]; // this bubble gets bigger along the line
		int run_len = N - i; // each run is getting shorter, the ending part get sorted
		for (int j = 0; j < run_len; ++j)
		{
			if (a[j] < bubble) // bubble shifts right
			{
				a[j-1] = a[j];
				a[j] = bubble;
			}
			else // found new bubble ( bigger than the old bubble )
			{
				bubble = a[j];
			}
			// print_a(a);
		}
		print_a(a);
	}
}
int main(int argc, char const *argv[])
{
	print_a(o);
	// insert_sort_a(o);
	bubble_sort_a(o);
	//print_a(r);
	return 0;
}

{'fraction_non_alphanumeric': 0.19236784485455113, 'fraction_numerical': 0.02564904598060682, 'mean_word_length': 2.327783558792924, 'pattern_counts': {'":': 0, '<': 16, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6864688', 'n_tokens_mistral': 1624, 'n_tokens_neox': 1382, 'n_words': 399}