Skip to content

Commit

Permalink
chore: updated vscode settings
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexAegis committed Dec 12, 2023
1 parent 8cdfb3f commit e75a7bf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"dbaeumer.vscode-eslint",
"ipatalas.vscode-postfix-ts",
"ms-python.python",
"ms-python.autopep8",
"ms-python.vscode-pylance",
"rust-lang.rust-analyzer"
]
Expand Down
8 changes: 2 additions & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,15 @@
"svelte.enable-ts-plugin": true,
"terminal.integrated.windowsEnableConpty": true,
"prettier.documentSelectors": ["**/*.svelte"],
"vitest.commandLine": "npx vitest --coverage",
"vitest.enable": true,
"[python]": {
"editor.defaultFormatter": "ms-python.python",
"editor.defaultFormatter": "ms-python.autopep8",
"editor.tabSize": 4,
"editor.insertSpaces": true
},
"python.autoComplete.extraPaths": ["./solutions/python/", "./", "__pypackages__/3.11/lib"],
"python.analysis.extraPaths": ["__pypackages__/3.11/lib"],
"python.envFile": "${workspaceFolder}/.env",
"python.formatting.provider": "autopep8",
"python.formatting.autopep8Args": ["--aggressive", "--aggressive"],
"python.linting.enabled": true,
"autopep8.args": ["--aggressive", "--aggressive"],
"python.terminal.activateEnvironment": false,
"python.defaultInterpreterPath": ".venv3/bin/python",
"python.analysis.typeCheckingMode": "basic",
Expand Down
13 changes: 6 additions & 7 deletions solutions/typescript/2023/12/src/p2.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cartesianCombinations, task } from '@alexaegis/advent-of-code-lib';
import { task } from '@alexaegis/advent-of-code-lib';
import packageJson from '../package.json';

interface SprintLog {
Expand All @@ -15,12 +15,11 @@ interface SprintLog {
export const criteriaToRegExp = (criteria: number[]): RegExp =>
new RegExp('^\\.*' + criteria.map((brokenCount) => `#{${brokenCount}}`).join('\\.+') + '\\.*$');

function generateVariations(damagedLog: string, criteria: RegExp): string[] {
const variants = [...damagedLog].map((entry) => (entry === '?' ? ['#', '.'] : [entry]));
function calculateVariations(damagedLog: string, criteria: number[]): number {
const totalVariationCount = [...damagedLog].map((entry) => (entry === '?' ? 2 : 1)).product();
const minlen = criteria.sum() + criteria.length - 1;
// const variationCount = variants.map((ev) => ev.length).product();
return cartesianCombinations(...variants)
.map((combination) => combination.join(''))
.filter((combination) => criteria.test(combination));
return totalVariationCount ^ minlen;
}

export const p2 = (input: string): number =>
Expand All @@ -45,7 +44,7 @@ export const p2 = (input: string): number =>
.tap((a) => {
console.log(a);
})
.map((spring) => generateVariations(spring.log, spring.criteriaRegExp).length)
.map((spring) => calculateVariations(spring.log, spring.criteria))

.sum();

Expand Down

0 comments on commit e75a7bf

Please sign in to comment.