Updoots
This commit is contained in:
1 parent
1ef0d29c9f
commit
4819b63b8d
17 files changed
+329
-29
No files matched your search
+33
@@ -0,0 +1,33 @@
|
||||
seeds: 79 14 55 13
|
||||
|
||||
seed-to-soil map:
|
||||
50 98 2
|
||||
52 50 48
|
||||
|
||||
soil-to-fertilizer map:
|
||||
0 15 37
|
||||
37 52 2
|
||||
39 0 15
|
||||
|
||||
fertilizer-to-water map:
|
||||
49 53 8
|
||||
0 11 42
|
||||
42 0 7
|
||||
57 7 4
|
||||
|
||||
water-to-light map:
|
||||
88 18 7
|
||||
18 25 70
|
||||
|
||||
light-to-temperature map:
|
||||
45 77 23
|
||||
81 45 19
|
||||
68 64 13
|
||||
|
||||
temperature-to-humidity map:
|
||||
0 69 1
|
||||
1 0 69
|
||||
|
||||
humidity-to-location map:
|
||||
60 56 37
|
||||
56 93 4
|
||||
@@ -0,0 +1,33 @@
|
||||
seeds: 79 14 55 13
|
||||
|
||||
seed-to-soil map:
|
||||
50 98 2
|
||||
52 50 48
|
||||
|
||||
soil-to-fertilizer map:
|
||||
0 15 37
|
||||
37 52 2
|
||||
39 0 15
|
||||
|
||||
fertilizer-to-water map:
|
||||
49 53 8
|
||||
0 11 42
|
||||
42 0 7
|
||||
57 7 4
|
||||
|
||||
water-to-light map:
|
||||
88 18 7
|
||||
18 25 70
|
||||
|
||||
light-to-temperature map:
|
||||
45 77 23
|
||||
81 45 19
|
||||
68 64 13
|
||||
|
||||
temperature-to-humidity map:
|
||||
0 69 1
|
||||
1 0 69
|
||||
|
||||
humidity-to-location map:
|
||||
60 56 37
|
||||
56 93 4
|
||||
@@ -0,0 +1,11 @@
|
||||
"#include <stdio.h>",
|
||||
"#include <stdlib.h>",
|
||||
"#include "libs/fileLoader.h"",
|
||||
"",
|
||||
"int main()",
|
||||
"{",
|
||||
" char *filename = "input";",
|
||||
" struct OpenFile *o_file = load_file_to_mem(filename);",
|
||||
"",
|
||||
" return 0;",
|
||||
"}",
|
||||
@@ -0,0 +1,65 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <strings.h>
|
||||
#include "libs/fileLoader.h"
|
||||
#include "structs.h"
|
||||
|
||||
#define MAX_STR_LEN 1024
|
||||
|
||||
const char *SEED_TXT = "seeds";
|
||||
const char *SEEDTOSOIL_TXT = "seed-to-soil map:";
|
||||
const char *SOILTOFERI_TXT = "soil-to-fertilizer map";
|
||||
const char *FERTITOWATER_TXT = "fertilizer-to-water map";
|
||||
const char *WATERTOLIGHT_TXT = "water-to-light map";
|
||||
const char *LIGHTTOTEMP_TXT = "light-to-temperature map";
|
||||
const char *TEMPTOHUMID_TXT = "temperature-to-humidity map";
|
||||
const char *HUMIDTOLOC_TXT = "humidity-to-location map";
|
||||
|
||||
Almanac *parseFile(OpenFile *file)
|
||||
{
|
||||
Almanac *data = (Almanac *)malloc(sizeof(Almanac));
|
||||
for (int iterator = 0; iterator < file->fileSize; iterator++)
|
||||
{
|
||||
// Initialize the data
|
||||
data->seeds = (Seeds *)malloc(sizeof(Seeds));
|
||||
data->seedtosoil = (SeedToSoilMap *)malloc(sizeof(SeedToSoilMap));
|
||||
data->soiltoferti = (SoilToFertiMap *)malloc(sizeof(SoilToFertiMap));
|
||||
data->ferttowater = (FertiToWaterMap *)malloc(sizeof(FertiToWaterMap));
|
||||
data->watertplight = (WaterToLightMap *)malloc(sizeof(WaterToLightMap));
|
||||
data->lighttotemp = (LightToTempMap *)malloc(sizeof(LightToTempMap));
|
||||
data->temptohumid = (TempToHumidMap *)malloc(sizeof(TempToHumidMap));
|
||||
data->humidtoloc = (HumidToLocMap *)malloc(sizeof(HumidToLocMap));
|
||||
|
||||
const char DELIM[2] = ":";
|
||||
char *token;
|
||||
char *save_ptr;
|
||||
|
||||
for (int i = 0; i < file->fileSize; i++)
|
||||
{
|
||||
char *tmpString = (char *)malloc(MAX_STR_LEN);
|
||||
if (file->fileData[i] == '\n')
|
||||
{
|
||||
token = strtok_r(tmpString, DELIM, &save_ptr);
|
||||
continue;
|
||||
}
|
||||
tmpString[i] = file->fileData[i];
|
||||
}
|
||||
|
||||
// const char NEWLN_DELIM[2] = "\n";
|
||||
// char *line_token;
|
||||
// char *line_save_ptr;
|
||||
|
||||
// line_token = strtok_r(file->fileData, NEWLN_DELIM, &line_save_ptr);
|
||||
// while (line_token != NULL)
|
||||
// {
|
||||
// if (strcmp(line_token, SEED_TXT) == 0)
|
||||
// {
|
||||
// printf("We looking at seeds");
|
||||
// }
|
||||
|
||||
// line_token = strtok_r(NULL, file->fileData, &line_save_ptr);
|
||||
// }
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef fileparser
|
||||
#define fileparser
|
||||
#include "structs.h"
|
||||
#include "parser.h"
|
||||
#include "libs/fileLoader.h"
|
||||
|
||||
Almanac *parseFile(OpenFile *file);
|
||||
|
||||
#endif
|
||||
Executable
BIN
Binary file not shown.
@@ -0,0 +1,23 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "structs.h"
|
||||
#include "libs/fileLoader.h"
|
||||
#include "parser.h"
|
||||
|
||||
#define testing
|
||||
|
||||
#ifdef testing
|
||||
#define FNAME "input_test"
|
||||
#else
|
||||
#define FNAME "input"
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
char *filename = FNAME;
|
||||
struct OpenFile *o_file = load_file_to_mem(filename);
|
||||
|
||||
Almanac *data = parseFile(o_file);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "libs/fileLoader.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
char *filename = "input";
|
||||
struct OpenFile *o_file = load_file_to_mem(filename);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,72 @@
|
||||
#ifndef structybois
|
||||
#define structybois
|
||||
|
||||
typedef struct Maps
|
||||
{
|
||||
int *nums;
|
||||
} Maps;
|
||||
|
||||
typedef struct Seeds
|
||||
{
|
||||
Maps *nums;
|
||||
} Seeds;
|
||||
|
||||
typedef struct SeedToSoilMap
|
||||
{
|
||||
Maps *first;
|
||||
Maps *second;
|
||||
} SeedToSoilMap;
|
||||
|
||||
typedef struct SoilToFertiMap
|
||||
{
|
||||
Maps *first;
|
||||
Maps *second;
|
||||
Maps *third;
|
||||
} SoilToFertiMap;
|
||||
|
||||
typedef struct FertiToWaterMap
|
||||
{
|
||||
Maps *first;
|
||||
Maps *second;
|
||||
Maps *third;
|
||||
Maps *fourth;
|
||||
} FertiToWaterMap;
|
||||
|
||||
typedef struct WaterToLightMap
|
||||
{
|
||||
Maps *irst;
|
||||
Maps *second;
|
||||
} WaterToLightMap;
|
||||
|
||||
typedef struct LightToTempMap
|
||||
{
|
||||
Maps *first;
|
||||
Maps *second;
|
||||
Maps *third;
|
||||
} LightToTempMap;
|
||||
|
||||
typedef struct TempToHumidMap
|
||||
{
|
||||
Maps *first;
|
||||
Maps *second;
|
||||
} TempToHumidMap;
|
||||
|
||||
typedef struct HumidToLocMap
|
||||
{
|
||||
Maps *first;
|
||||
Maps *second;
|
||||
} HumidToLocMap;
|
||||
|
||||
typedef struct Almanac
|
||||
{
|
||||
Seeds *seeds;
|
||||
SeedToSoilMap *seedtosoil;
|
||||
SoilToFertiMap *soiltoferti;
|
||||
FertiToWaterMap *ferttowater;
|
||||
WaterToLightMap *watertplight;
|
||||
LightToTempMap *lighttotemp;
|
||||
TempToHumidMap *temptohumid;
|
||||
HumidToLocMap *humidtoloc;
|
||||
} Almanac;
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user