<commit_before>#include <stdio.h>
#include <string.h>
#include "list.h"

#define MAXCHAR 1000

void parse(char *str, char *temp) {
  char *old;
  int posx, posy;
  memset(temp, 0, sizeof temp);
  /* char *tempp = *temp; */
  while (*str!='@') {
    str ++;
  }
  str+=2;
  old=str;
  while (*str!=',') {
    str++;
  }
  strncpy(temp, old, str-old);
  posx = atoi(temp);

  str++;
  old=str;
  while(*str!=':') {
    str++;
  }
  strncpy(temp, old, str-old);
  posy = atoi(temp);

  str+=2;
  old=str;

  printf("posx: %d\n", posx);
  printf("posy: %d\n", posy);

  /* printf("temp %s\n", temp); */
  printf("%s\n", str);
}

int main() {
  FILE *fd;
  char str[MAXCHAR];
  char temp[10];

  List *lseen;

  int fabric[1000][1000];
  int i, j=0;

  char *filename = "input.txt";

  for(i = 0; i < 1000; i++) {
    for(j = 0; j < 1000; j++) {
      fabric[i][j] = 0;
    }
  }
  fd = fopen(filename, "r");
  if(fd == NULL) {
    printf("error opening: %s\n", filename);
  }

  // save all lines to array
  while(fgets(str, MAXCHAR, fd) != NULL) {
    parse(str, temp);
  }

  fclose(fd);

  return 0;<commit_msg>day3 pt 1<commit_after>#include <stdio.h>
#include <string.h>
#include "list.h"

#define MAXCHAR 1000

void parse(char *str, int fabric[1000][1000]) {
  char *old;
  char temp[10];
  int posx, posy, width, height;
  int i,j=0;
  memset(temp, 0, sizeof temp);
  /* char *tempp = *temp; */
  while (*str!='@') {
    str ++;
  }
  str+=2;
  old=str;
  while (*str!=',') {
    str++;
  }
  strncpy(temp, old, str-old);
  posx = atoi(temp);
  memset(temp, 0, sizeof temp);

  str++;
  old=str;
  while(*str!=':') {
    str++;
  }
  strncpy(temp, old, str-old);
  posy = atoi(temp);
  memset(temp, 0, sizeof temp);

  str+=2;
  old=str;

  while(*str!='x') {
    str++;
  }

  strncpy(temp, old, str-old);
  width = atoi(temp);
  memset(temp, 0, sizeof temp);

  str++;
  old=str;

  while(*str!='\0') {
    str++;
  }

  strncpy(temp, old, str-old);
  height = atoi(temp);

  //fyll i själva arrayen
  /* printf("posx: %d\n", posx); */
  /* printf("posy: %d\n", posy); */
  /* printf("width: %d\n", width); */
  /* printf("height: %d\n", height); */
  for(i=0; i < height; i++) {
    for(j=0; j < width; j++) {
      fabric[(i+posy)][(j+posx)] ++;
    }
  }

  /* printf("temp %s\n", temp); */
  /* printf("%s\n", str); */
}

int main() {
  FILE *fd;
  char str[MAXCHAR];

  List *lseen;

  int fabric[1000][1000];
  int i, j, claims=0;

  char *filename = "input.txt";

  for(i = 0; i < 1000; i++) {
    for(j = 0; j < 1000; j++) {
      fabric[i][j] = 0;
    }
  }
  fd = fopen(filename, "r");
  if(fd == NULL) {
    printf("error opening: %s\n", filename);
  }

  // save all lines to array
  while(fgets(str, MAXCHAR, fd) != NULL) {
    parse(str, fabric);
  }

  for(i = 0; i < 1000; i++) {
    for(j = 0; j < 1000; j++) {
      if(fabric[i][j] >= 2) {
        claims ++;
      }
      /* printf("%d", fabric[i][j]); */
    }
    /* printf("\n"); */
  }

  printf("Claimed squares: %d\n", claims);

  fclose(fd);

  return 0;
{'fraction_non_alphanumeric': 0.23327841845140032, 'fraction_numerical': 0.02899505766062603, 'mean_word_length': 2.62291169451074, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 8, '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': '4456246', 'n_tokens_mistral': 1399, 'n_tokens_neox': 1295, 'n_words': 301}