void print_headings()
{
	printf(, );
	printf(, );
	printf(, );
	printf(, );
	printf();
}

double calculate_entropy(int ones, int zeros)
{
	double result = 0;

	int total = ones + zeros;
	result -= (double) ones / total * log2((double) ones / total);
	result -= (double) zeros / total * log2((double) zeros / total);

	if (result != result) { 
		result = 0;
	}

	return result;
}

void print_entropy(char *word)
{
	int ones = 0;
	int zeros = 0;

	int i;
	for (i = 0; word[i]; i++) {
		char c = word[i];

		switch (c) {
			case '0':
				zeros++;
				break;
			case '1':
				ones++;
				break;
		}
	}

	double entropy = calculate_entropy(ones, zeros);
	printf(, entropy);
}

void print_word(int n, char *word)
{
	printf(, n);

	printf(, strlen(word));

	print_entropy(word);

	if (n < 10) {
		printf(, word);
	} else {
		printf(, );
	}

	printf();
}

int main(int argc, char *argv[])
{
	print_headings();

	char *last_word = malloc(2);
	strcpy(last_word, );

	char *current_word = malloc(2);
	strcpy(current_word, );

	print_word(1, last_word);
	int i;
	for (i = 2; i <= 37; i++) {
		print_word(i, current_word);

		char *next_word = malloc(strlen(current_word) + strlen(last_word) + 1);
		strcpy(next_word, current_word);
		strcat(next_word, last_word);

		free(last_word);
		last_word = current_word;
		current_word = next_word;
	}

	free(last_word);
	free(current_word);
	return 0;
}