Add unfinished progress
This commit is contained in:
parent
4987055b12
commit
d5d7e98027
|
@ -1,5 +1,6 @@
|
|||
.extrc
|
||||
2019/aoc2019
|
||||
2019/CMakeFiles/
|
||||
2019/CMakeCache.txt
|
||||
2019/cmake_install.cmake
|
||||
2019/Makefile
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
cmake_minimum_required(VERSION 3.0)
|
||||
|
||||
project(aoc2019 LANGUAGES C)
|
||||
set(DAY 3)
|
||||
set(PART 2)
|
||||
set(DAY 4)
|
||||
set(PART 1)
|
||||
|
||||
add_executable(aoc2019 days/${DAY}/${PART}/main.c)
|
||||
#target_link_libraries(aoc2019 m) # If math.h is required, use this
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define POINTLIMIT 500000
|
||||
#define POINTLIMIT 200000
|
||||
|
||||
int main(void) {
|
||||
signed int lines[2][POINTLIMIT][3];
|
||||
signed int lines[2][POINTLIMIT][2];
|
||||
unsigned int bufpos = 0, pp = 0, linep[2];
|
||||
short line = 0, bufls = 0, res;
|
||||
short line = 0, bufls = 0, res = -1;
|
||||
char numbuf[16], dir, c;
|
||||
fprintf(stderr,"\e[1;31mParsing input...\n");
|
||||
while ((c=getchar())!=EOF) {
|
||||
|
@ -21,7 +21,6 @@ int main(void) {
|
|||
}
|
||||
lines[line][pp][0] = lines[line][start][0];
|
||||
lines[line][pp][1] = lines[line][start][1];
|
||||
lines[line][pp][2] = 0;
|
||||
int va,val;
|
||||
switch (dir) {
|
||||
case 'U': va = 1, val=1; break;
|
||||
|
@ -37,7 +36,8 @@ int main(void) {
|
|||
line++;
|
||||
pp = 0;
|
||||
}
|
||||
bufpos = 0, bufls = 0;
|
||||
bufpos = 0;
|
||||
bufls = 0;
|
||||
} else if (c >= '0' && c <= '9') {
|
||||
numbuf[bufpos++] = c;
|
||||
bufls = 1;
|
||||
|
@ -45,32 +45,22 @@ int main(void) {
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
fprintf(stderr,"Finding closest match...\n");
|
||||
int num[3] = {0};
|
||||
fprintf(stderr,"\nFinding closest match...\n");
|
||||
int poi[POINTLIMIT][2][2], poip; // Comparasion buffer
|
||||
for (int x=0, m=0; x<linep[0] && x<POINTLIMIT; x++) {
|
||||
for (int y=0; y<linep[1] && y<POINTLIMIT; y++) {
|
||||
if (
|
||||
lines[0][x][0] == lines[1][y][0] &&
|
||||
lines[0][x][1] == lines[1][y][1]
|
||||
) {
|
||||
if (lines[0][x][0] < 0) {
|
||||
num[1] = lines[0][x][0]*-1;
|
||||
} else {
|
||||
num[1] = lines[0][x][0];
|
||||
}
|
||||
if (lines[0][x][1] < 0) {
|
||||
num[2] = lines[0][x][1]*-1;
|
||||
} else {
|
||||
num[2] = lines[0][x][1];
|
||||
}
|
||||
if (num[0] == 0 || num[0] > num[1] + num[2]) {
|
||||
num[0] = num[1] + num[2];
|
||||
}
|
||||
fprintf(stderr,"\e[0mFound %i|%i and %i|%i!\n\e[1;31mFound %i match(es)...\r", lines[0][x][0], lines[0][x][1], lines[1][y][0], lines[1][y][1], ++m);
|
||||
poi[poip][0][0] = lines[0][x][0]; // Positions of the points
|
||||
poi[poip][0][1] = lines[0][x][1];
|
||||
poi[poip][1][0] = x; // Steps of points
|
||||
poi[poip++][1][1] = y;
|
||||
}
|
||||
}
|
||||
res = num[0];
|
||||
}
|
||||
free(lines); // We don't need unimportant points anymore
|
||||
fprintf(stderr,"\nBingo:\n");
|
||||
printf("%i\n", res);
|
||||
return 0;
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
1,0,0,3,1,1,2,3,1,3,4,3,1,5,0,3,2,1,6,19,2,19,6,23,1,23,5,27,1,9,27,31,1,31,10,35,2,35,9,39,1,5,39,43,2,43,9,47,1,5,47,51,2,51,13,55,1,55,10,59,1,59,10,63,2,9,63,67,1,67,5,71,2,13,71,75,1,75,10,79,1,79,6,83,2,13,83,87,1,87,6,91,1,6,91,95,1,10,95,99,2,99,6,103,1,103,5,107,2,6,107,111,1,10,111,115,1,115,5,119,2,6,119,123,1,123,5,127,2,127,6,131,1,131,5,135,1,2,135,139,1,139,13,0,99,2,0,14,0
|
|
@ -0,0 +1,33 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#define MINV 123257
|
||||
#define MAXV 647015
|
||||
|
||||
int main(void) {
|
||||
int count=0;
|
||||
fprintf(stderr,"\e[1J");
|
||||
for (int i=MINV+1, s=0, dd=0; i>MINV && i<MAXV; i++) {
|
||||
fprintf(stderr,"\e[1;HNM\t%i", i);
|
||||
int num[7]={ (i/100000)%10, (i/10000)%10, (i/1000)%10, (i/100)%10, (i/10)%10, i%10 };
|
||||
for (int x=1; x<7 && s!=1; x++) {
|
||||
fprintf(stderr,"\e[2;HNC\t%i\t%i", num[x-1], num[x]);
|
||||
if (num[x] == num[x-1]) {
|
||||
dd=1;
|
||||
}
|
||||
if (num[x] < num[x-1]) {
|
||||
s=1;
|
||||
}
|
||||
fprintf(stderr,"\e[3;HDD\t%i\e[4;HDC\t%i", dd, s);
|
||||
}
|
||||
fprintf(stdout,"%i %i\n", dd, s);
|
||||
if (dd==1 && s!=1) {
|
||||
count++;
|
||||
}
|
||||
fprintf(stderr,"\e[5;HTC\t%i", count);
|
||||
dd=0;
|
||||
s=0;
|
||||
}
|
||||
fprintf(stderr,"\e[6;HResult: ");
|
||||
fprintf(stdout,"%i\n", count);
|
||||
return count;
|
||||
}
|
Loading…
Reference in New Issue