Code cleanup

This commit is contained in:
Evan Burkey 2021-09-11 16:47:06 -07:00
parent 0a7aaec503
commit fc4cacf492
10 changed files with 125 additions and 81 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ compile_commands.json
.cache
build
.clangd
cmake-build-*

8
.idea/.gitignore generated vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

2
.idea/advent.iml generated Normal file
View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<module classpath="CMake" type="CPP_MODULE" version="4" />

4
.idea/misc.xml generated Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
</project>

8
.idea/modules.xml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/advent.iml" filepath="$PROJECT_DIR$/.idea/advent.iml" />
</modules>
</component>
</project>

7
.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/lib/libflint" vcs="Git" />
</component>
</project>

View File

@ -1,6 +1,5 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "input.h"

View File

@ -1,6 +1,5 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "set.h"
#include "input.h"
@ -25,10 +24,18 @@ static int part_two(char *input) {
is_santa = is_santa == 1 ? 0 : 1;
switch (*c) {
case '^': ++(*y); break;
case 'v': --(*y); break;
case '>': ++(*x); break;
case '<': --(*x); break;
case '^':
++(*y);
break;
case 'v':
--(*y);
break;
case '>':
++(*x);
break;
case '<':
--(*x);
break;
}
set_insert(houses, (void *) new_Point_p(*x, *y));
++c;
@ -49,10 +56,18 @@ static int part_one(char *input) {
while (*c != '\0') {
switch (*c) {
case '^': ++y; break;
case 'v': --y; break;
case '>': ++x; break;
case '<': --x; break;
case '^':
++y;
break;
case 'v':
--y;
break;
case '>':
++x;
break;
case '<':
--x;
break;
}
set_insert(houses, (void *) new_Point_p(x, y));
++c;