Overview
| Comment: | 202405 -- download input, prepare skeleton |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
3ff4b256a55c5182adbc313f8505f85b |
| User & Date: | nnz on 2024-12-05 10:53:16.095 |
| Other Links: | manifest | tags |
Context
|
2024-12-05
| ||
| 10:53 | 202405 -- tiny mistake check-in: ab3c10d320 user: nnz tags: trunk | |
| 10:53 | 202405 -- download input, prepare skeleton check-in: 3ff4b256a5 user: nnz tags: trunk | |
|
2024-12-04
| ||
| 18:53 | added free() check-in: 292a60d81c user: nnz tags: trunk | |
Changes
Modified aoc2024.c
from [4bb9424853]
to [05aabc9e08].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#include <ctype.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "aocdailies.h"
#include "aocutils.h"
static size_t rcmap(unsigned size, unsigned row, unsigned col) {
return row * (size + 1) + col;
}
static bool masat(char *data, unsigned size, unsigned row, unsigned col, int drow, int dcol) {
int maxrow = (int)row + 3*drow;
int maxcol = (int)col + 3*dcol;
| > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
#include <ctype.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "aocdailies.h"
#include "aocutils.h"
void aoc202404(char *data, size_t len) {
(void)data; // unused argument
(void)len; // unused argument
printf("wip/n");
}
static size_t rcmap(unsigned size, unsigned row, unsigned col) {
return row * (size + 1) + col;
}
static bool masat(char *data, unsigned size, unsigned row, unsigned col, int drow, int dcol) {
int maxrow = (int)row + 3*drow;
int maxcol = (int)col + 3*dcol;
|
| ︙ | ︙ |
Modified aocdailies.c
from [0c5580f51d]
to [1d3de21cad].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#include <stddef.h>
#include "aocdailies.h"
aocfunc *aocselect(unsigned y, unsigned d) {
aocfunc *p;
switch (y * 100 + d) {
default: p = NULL; break;
case 202404: p = aoc202404; break;
case 202403: p = aoc202403; break;
case 202402: p = aoc202402; break;
case 202401: p = aoc202401; break;
#if 0
case 201525: p = aoc201525; break;
| > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#include <stddef.h>
#include "aocdailies.h"
aocfunc *aocselect(unsigned y, unsigned d) {
aocfunc *p;
switch (y * 100 + d) {
default: p = NULL; break;
case 202405: p = aoc202405; break;
case 202404: p = aoc202404; break;
case 202403: p = aoc202403; break;
case 202402: p = aoc202402; break;
case 202401: p = aoc202401; break;
#if 0
case 201525: p = aoc201525; break;
|
| ︙ | ︙ |
Modified aocdailies.h
from [78d65ea150]
to [624d10b25c].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #ifndef AOCDAILIES_H_INCLUDED #define AOCDAILIES_H_INCLUDED #include <stddef.h> typedef void aocfunc(char *, size_t); aocfunc *aocselect(unsigned, unsigned); aocfunc aoc202404; aocfunc aoc202403; aocfunc aoc202402; aocfunc aoc202401; #if 0 aocfunc aoc201525; | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #ifndef AOCDAILIES_H_INCLUDED #define AOCDAILIES_H_INCLUDED #include <stddef.h> typedef void aocfunc(char *, size_t); aocfunc *aocselect(unsigned, unsigned); aocfunc aoc202405; aocfunc aoc202404; aocfunc aoc202403; aocfunc aoc202402; aocfunc aoc202401; #if 0 aocfunc aoc201525; |
| ︙ | ︙ |
Modified aocutils.c
from [dc2d5534c7]
to [2b60469d03].
1 2 3 4 5 6 7 8 9 10 11 |
#include <stdio.h>
#include <stdlib.h>
#include "aocutils.h"
size_t text2array(unsigned **dst, const char *r) {
unsigned *a = malloc(512 * sizeof *a);
size_t na = 0, sa = 512;
char *err;
unsigned v;
for (;;) {
if (na == sa) {
| | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
#include <stdio.h>
#include <stdlib.h>
#include "aocutils.h"
size_t text2array(unsigned **dst, const char *r) {
unsigned *a = malloc(512 * sizeof *a);
size_t na = 0, sa = 512;
char *err;
unsigned v;
for (;;) {
if (na == sa) {
// grow the array (by golden ratio)
unsigned *tmp = realloc(a, ((13*sa) / 8) * sizeof *tmp);
if (!tmp) exit(EXIT_FAILURE);
a = tmp;
sa = (13*sa) / 8;
}
v = strtoul(r, &err, 10);
a[na++] = v;
|
| ︙ | ︙ | |||
37 38 39 40 41 42 43 |
int ch;
char *tmp = malloc(512);
size_t s = 512;
size_t r = 0;
while ((ch = fgetc(h)) != EOF) {
if (r == s) {
| | < | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
int ch;
char *tmp = malloc(512);
size_t s = 512;
size_t r = 0;
while ((ch = fgetc(h)) != EOF) {
if (r == s) {
// grow the array (by golden ratio)
char *ttmp = realloc(tmp, (13*s) / 8);
if (ttmp) {
tmp = ttmp;
s = (13*s) / 8;
} else {
free(tmp);
return 0;
|
| ︙ | ︙ |