#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdint.h>

#define NUMS 48
#define POW 28

int main(int argc, char **argv){
	//285 Wed. Dec 30, 2015 12 61 54 38 36 22
	FILE *in;
	char linestring[128];
	char buf[16];
	uint32_t nums[NUMS];
	uint32_t power[POW];
	uint32_t count1, count2, count3;
	uint32_t number = 0;
	//fopen("numbers.txt");
	memset ((void*) nums, '\0', sizeof(uint32_t)*NUMS);
	memset ((void*) power, '\0', sizeof(uint32_t)*POW);
	if( ( in = fopen( "numbers.txt", "r" ) ) != NULL ) {
		while( fgets(linestring, sizeof(linestring), in) != NULL){
			memset ((void*) buf, '\0', sizeof(buf));
			//count2 = 0;
			count1 = 0;
			for(count2=0; count1 < 5; count2++){
				if(linestring[count2] == ' ')
					count1++;
			}
			//count2++;
			for(count1=1; count1<7; count1++){
				//count3 = 0;
				memset ((void*) buf, '\0', sizeof(buf));
				for(count3 = 0; linestring[count2] != ' '; count3++){
					buf[count3] = linestring[count2];
					count2++;
				}
				count2++;

				number = atoi((const char *)buf);
printf("%u ", number);
				if(count1 < 6){
					nums[number]++;
				}else{
					//printf("here\n");
					power[number]++;
				}
			}
printf("\n");
			//while(linestring[count2] != ' ' && linestring[count2] != NULL){
				
			//}
		}
	}

printf("NUMS\n");
	for(count1=1; count1<NUMS; count1++){
		printf("\t%u: %u\n", count1, nums[count1]);

	}
printf("POWER\n");
	for(count1=1; count1<POW; count1++){
		printf("\t%u: %u\n", count1, power[count1]);
	}

	fclose(in);
	return 0;
}
