Skip to content

Commit

Permalink
chore: prepare day 4 5 6 7
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexAegis committed Dec 6, 2024
1 parent 5d93156 commit 22e0da0
Show file tree
Hide file tree
Showing 61 changed files with 1,236 additions and 4 deletions.
124 changes: 124 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion solutions/typescript/2024/02/src/p1.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { describe, expect, it } from 'vitest';
import packageJson from '../package.json' assert { type: 'json' };
import { p1 } from './p1.js';

describe('2024 01 p1', () => {
describe('2024 02 p1', () => {
describe('the input', () => {
it('should solve the input', async () => {
const resources = await loadTaskResources(packageJson.aoc);
Expand Down
2 changes: 1 addition & 1 deletion solutions/typescript/2024/02/src/p2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { describe, expect, it } from 'vitest';
import packageJson from '../package.json' assert { type: 'json' };
import { p2 } from './p2.js';

describe('2024 01 p2', () => {
describe('2024 02 p2', () => {
describe('the input', () => {
it('should solve the input', async () => {
const { input } = await loadTaskResources(packageJson.aoc);
Expand Down
2 changes: 1 addition & 1 deletion solutions/typescript/2024/03/src/p1.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { describe, expect, it } from 'vitest';
import packageJson from '../package.json' assert { type: 'json' };
import { p1 } from './p1.js';

describe('2024 01 p1', () => {
describe('2024 03 p1', () => {
describe('the input', () => {
it('should solve the input', async () => {
const resources = await loadTaskResources(packageJson.aoc);
Expand Down
2 changes: 1 addition & 1 deletion solutions/typescript/2024/03/src/p2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { describe, expect, it } from 'vitest';
import packageJson from '../package.json' assert { type: 'json' };
import { p2 } from './p2.js';

describe('2024 01 p2', () => {
describe('2024 03 p2', () => {
describe('the input', () => {
it('should solve the input', async () => {
const { input } = await loadTaskResources(packageJson.aoc);
Expand Down
39 changes: 39 additions & 0 deletions solutions/typescript/2024/04/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# managed-by-autotool
# Add files here to ignore them from prettier formatting

# node
node_modules
package-lock.json
pnpm-lock.yaml
yarn.lock

# build artifacts
dist
public/build
build
.svelte-kit
.vercel
typedoc
**/.vitepress/cache

# test artifacts
coverage
.vscode/chrome
.nyc_output
vite.config.ts.*
vitest.config.ts.*

# turbo
.turbo

# rust
target
*.lock

# python
.pytest_cache

# others
.cache
.benchmark
CHANGELOG.md
6 changes: 6 additions & 0 deletions solutions/typescript/2024/04/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// managed-by-autotool

import eslintConfigCore from '@alexaegis/eslint-config-core';
import eslintConfigVitest from '@alexaegis/eslint-config-vitest';

export default [...eslintConfigCore, ...eslintConfigVitest];
82 changes: 82 additions & 0 deletions solutions/typescript/2024/04/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"name": "@alexaegis/advent-of-code-2024-04",
"description": "Advent of Code 2024 04 solutions",
"version": "1.0.0",
"license": "mit",
"private": true,
"archetype": {
"platform": "node",
"framework": "adventofcode",
"language": "ts"
},
"keywords": [
"advent-of-code",
"javascript",
"js",
"managed-by-autotool",
"ts",
"typescript"
],
"type": "module",
"aoc": {
"day": 3,
"year": 2024
},
"scripts": {
"lint:depcheck": "turbo run lint:depcheck_ --concurrency 16 --filter @alexaegis/advent-of-code-2024-04",
"lint:depcheck_": "depcheck",
"lint:es": "turbo run lint:es_ --concurrency 16 --filter @alexaegis/advent-of-code-2024-04",
"lint:es_": "eslint --max-warnings=0 --fix --no-error-on-unmatched-pattern .",
"lint:format": "turbo run lint:format_ --concurrency 16 --filter @alexaegis/advent-of-code-2024-04",
"lint:format_": "prettier --cache-location .cache/prettier --plugin prettier-plugin-svelte --plugin prettier-plugin-tailwindcss --check .",
"lint:md": "turbo run lint:md_ --concurrency 16 --filter @alexaegis/advent-of-code-2024-04",
"lint:md_": "remark --frail --no-stdout --silently-ignore .",
"lint:tsc": "turbo run lint:tsc_ --concurrency 16 --filter @alexaegis/advent-of-code-2024-04",
"lint:tsc_": "tsc --noEmit",
"test": "turbo run test_ --concurrency 16 --cache-dir .cache/turbo --filter @alexaegis/advent-of-code-2024-04",
"test_": "vitest --passWithNoTests --coverage --run",
"test:watch": "vitest --passWithNoTests --coverage",
"all": "BUILD_REASON='publish' turbo run all_ --concurrency 16 --filter @alexaegis/advent-of-code-2024-04",
"bench": "tsx src/bench.ts",
"build": "turbo run build-lib_ --concurrency 16 --cache-dir .cache/turbo --filter @alexaegis/advent-of-code-2024-04",
"build-lib_": "vite build",
"format": "turbo run format_ --concurrency 16 --filter @alexaegis/advent-of-code-2024-04",
"format_": "prettier --cache-location .cache/prettier --plugin prettier-plugin-svelte --plugin prettier-plugin-tailwindcss --write .",
"p1": "RUN=1 NODE_NO_WARNINGS=1 tsx src/p1.ts",
"p1:example": "RUN=1 NODE_NO_WARNINGS=1 RESOURCE=example.1.txt tsx src/p1.ts",
"p2": "RUN=1 NODE_NO_WARNINGS=1 tsx src/p2.ts",
"p2:example": "RUN=1 NODE_NO_WARNINGS=1 RESOURCE=example.2.txt tsx src/p2.ts"
},
"exports": {
"./bench": {
"types": "./src/bench.ts",
"import": "./dist/bench.js",
"default": "./dist/bench.js"
},
"./p1": {
"types": "./src/p1.ts",
"import": "./dist/p1.js",
"default": "./dist/p1.js"
},
"./p2": {
"types": "./src/p2.ts",
"import": "./dist/p2.js",
"default": "./dist/p2.js"
},
"./package.json": "./package.json",
"./readme": "./readme.md"
},
"dependencies": {
"@alexaegis/advent-of-code-lib": "workspace:^"
},
"devDependencies": {
"@alexaegis/eslint-config-vitest": "^0.12.0",
"@alexaegis/ts": "^0.12.0",
"@alexaegis/vite": "^0.12.0",
"@alexaegis/vitest": "^0.12.0",
"@types/node": "^22.10.1",
"benny": "^3.7.1",
"vite": "^6.0.1",
"vitest": "^2.1.6"
}
}
5 changes: 5 additions & 0 deletions solutions/typescript/2024/04/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# [Day 4](https://adventofcode.com/2024/day/4)

## [Part One](https://adventofcode.com/2024/day/4#part1)

## [Part Two](https://adventofcode.com/2024/day/4#part2)
18 changes: 18 additions & 0 deletions solutions/typescript/2024/04/src/bench.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { loadTaskResources } from '@alexaegis/advent-of-code-lib';
import { defaultBench } from '@alexaegis/advent-of-code-lib/benchmark';
import { add } from 'benny';
import packageJson from '../package.json' assert { type: 'json' };
import { p1 } from './p1.js';
import { p2 } from './p2.js';

await defaultBench(
'2024 - Day 4',
add('Part One', async () => {
const { input } = await loadTaskResources(packageJson.aoc);
return () => p1(input);
}),
add('Part Two', async () => {
const { input } = await loadTaskResources(packageJson.aoc);
return () => p2(input);
}),
);
27 changes: 27 additions & 0 deletions solutions/typescript/2024/04/src/p1.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { loadTaskResources } from '@alexaegis/advent-of-code-lib';
import { describe, expect, it } from 'vitest';
import packageJson from '../package.json' assert { type: 'json' };
import { p1 } from './p1.js';

describe('2024 04 p1', () => {
describe('the input', () => {
it('should solve the input', async () => {
const resources = await loadTaskResources(packageJson.aoc);
expect(p1(resources.input)).toEqual(179834255);
});
});

describe('example 1', () => {
it('should be solved', async () => {
const resources = await loadTaskResources(packageJson.aoc, 'example.1.txt');
expect(p1(resources.input)).toEqual(161);
});
});

describe('example 2', () => {
it('should be solved', async () => {
const resources = await loadTaskResources(packageJson.aoc, 'example.2.txt');
expect(p1(resources.input)).toEqual(161);
});
});
});
8 changes: 8 additions & 0 deletions solutions/typescript/2024/04/src/p1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { task } from '@alexaegis/advent-of-code-lib';
import packageJson from '../package.json' assert { type: 'json' };

export const p1 = (_input: string): number => {
return 0;
};

await task(p1, packageJson.aoc); // 0 ~0.09ms
27 changes: 27 additions & 0 deletions solutions/typescript/2024/04/src/p2.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { loadTaskResources } from '@alexaegis/advent-of-code-lib';
import { describe, expect, it } from 'vitest';
import packageJson from '../package.json' assert { type: 'json' };
import { p2 } from './p2.js';

describe('2024 04 p2', () => {
describe('the input', () => {
it('should solve the input', async () => {
const { input } = await loadTaskResources(packageJson.aoc);
expect(p2(input)).toEqual(80570939);
});
});

describe('example 1', () => {
it('should be solved', async () => {
const { input } = await loadTaskResources(packageJson.aoc, 'example.1.txt');
expect(p2(input)).toEqual(161);
});
});

describe('example 2', () => {
it('should be solved', async () => {
const { input } = await loadTaskResources(packageJson.aoc, 'example.2.txt');
expect(p2(input)).toEqual(48);
});
});
});
8 changes: 8 additions & 0 deletions solutions/typescript/2024/04/src/p2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { task } from '@alexaegis/advent-of-code-lib';
import packageJson from '../package.json' assert { type: 'json' };

export const p2 = (_input: string): number => {
return 0;
};

await task(p2, packageJson.aoc); // 0 ~0.09ms
1 change: 1 addition & 0 deletions solutions/typescript/2024/04/src/parse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const parse = (input: string): string[] => input.lines();
Loading

0 comments on commit 22e0da0

Please sign in to comment.