V2NY3ZVOW5CKNQ7ZUYNVBLKHVVRIKXYJYBA7EPJ5JNBD52YSNEUQC
J5ZDIONDNUHFQESBKVHJY6SOMOMY5G27NNWYXKENBI4PKM2Y2M6AC
MWXORZD2D5X2IYAVRSYG4YWR2YN5N4VP6V2LV2VOF7SBXK24NSMQC
PPSVYG6ZWHZG2VE43TTNXQGNYV2TGGJLNCTSTZZUO2RYY6VP65QAC
4C6H6ZYD4SVDHKIXD76SSFYE32V3GTY75WO6OVXZTL5JA3I3XL5AC
### Final versionInstead of strings I use the following node structure for storing items:```zigconst SnailItem = union(enum) { num: u6, pair: *SnailNumber,}const SnailNumber = struct { left: ?SnailItem, right: ?SnailItem, parent: ?SnailNumber,}```
### Final version
Instead of strings I use the following node structure for storing items:
```zig
const SnailItem = union(enum) {
num: u6,
pair: *SnailNumber,
}
const SnailNumber = struct {
left: ?SnailItem,
right: ?SnailItem,
parent: ?SnailNumber,
```
The first step is parsing the string to this, every other manipulation is doneon the `SnailNumber`. First part drops down to 10ms, second part is ~200ms.
The first step is parsing the string to this, every other manipulation is done
on the `SnailNumber`. First part drops down to 10ms, second part is ~200ms.
more than 255k hits for chache items with my imput. Runs ~70ms on the rpi4.
more than 255k hits for chache items with my input. Runs ~70ms on the rpi4.
row/col state before changing them, but it is bearable.
row/col state before changing them, but it is bearable. Running time is ~250ms.
This way every coordinate is comes as Coord{ .x = value / grid_cols, .y = value% grid_cols}. Might worth a try.
This way every coordinate is comes as Coord{ .x = value / grid_cols, .y = value
% grid_cols}. Might worth a try.
This way every coordinate is comes as `Coord{ .x = value / grid_cols, .y = value% grid_cols}`. Might worth a try.
This way every coordinate is comes as `Coord{ .x = value / grid_cols, .y = value
% grid_cols}`. Might worth a try.