8000 Develop by sir-gon · Pull Request #694 · sir-gon/algorithm-exercises-js · GitHub
[go: up one dir, main page]

Skip to content

Develop #694

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/eslint-code-scanning.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22.x
node-version: 24.x

- name: Install ESLint
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
strategy:
matrix:
os: ["ubuntu-24.04", "macos-14", "windows-2022"]
node-version: [18.x, 20.x, 22.x]
node-version: [20.x, 22.x, 24.x]
# See supported Node.js release schedule
# at https://nodejs.org/en/about/releases/
permissions:
Expand All @@ -43,7 +43,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22.x
node-version: ${{ matrix.node-version }}

- name: Install ESLint
run: |
Expand Down
10 changes: 2 additions & 8 deletions .github/workflows/markdown-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,14 @@ jobs:
name: Markdown Lint
runs-on: ubuntu-24.04

strategy:
matrix:
node-version: [22.x]
# See supported Node.js release schedule
# at https://nodejs.org/en/about/releases/

steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

- name: Set up Node.js ${{ matrix.node-version }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
node-version: 24.x

- name: Install dependencies
run: npm install -g markdownlint-cli
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22.x
node-version: 24.x

- name: Install dependencies
run: npm ci --verbose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ on: # yamllint disable-line rule:truthy
workflow_dispatch:

jobs:
build:
test:
name: NodeJS Jest CI Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-24.04", "macos-14", "windows-2022"]
node-version: [18.x, 20.x, 22.x]
node-version: [20.x, 22.x, 24.x]
# See supported Node.js release schedule
# at https://nodejs.org/en/about/releases/

Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/prettier-json.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: Prettier JSON Lint

on: # yamllint disable-line rule:truthy
push:
branches: ['main']
pull_request:
# The branches below must be a subset of the branches above
branches: ['main']
workflow_dispatch:

jobs:
json-lint:
name: 'Prettier JSON Lint'
runs-on: ['ubuntu-24.04']
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 24.x

- name: Install Prettier
run: |
npm install -g prettier@3.5.3

- name: Prettier LINT / Style JSON
run: >
prettier --check ./src/**/*.json
2 changes: 1 addition & 1 deletion .prettierrc → .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
singleQuote: true
quoteProps: preserve
useTabs: false
printWidth: 80
tabWidth: 2
trailingComma: none
parser: typescript
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ WORKDIR ${WORKDIR}

RUN apk add --update --no-cache make nodejs npm \
&& apk add --update --no-cache yamllint \
&& npm install -g --ignore-scripts markdownlint-cli
&& npm install -g --ignore-scripts markdownlint-cli \
&& npm install -g --ignore-scripts prettier

# [!TIP] Use a bind-mount to "/app" to override following "copys"
# for lint and test against "current" sources in this stage
Expand All @@ -39,7 +40,7 @@ COPY ./package-lock.json ${WORKDIR}/package-lock.json
COPY ./Makefile ${WORKDIR}/

# code linting conf
COPY ./.prettierrc ${WORKDIR}/
COPY ./.prettierrc.yaml ${WORKDIR}/
COPY ./.prettierignore ${WORKDIR}/
COPY ./eslint.config.js ${WORKDIR}/
COPY ./.babelrc ${WORKDIR}/
Expand Down
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,31 @@ dependencies:
test -x ./node_modules || npm install --verbose
@echo "################################################################################"

lint/json:
prettier --check ./src/**/*.json

lint/markdown:
markdownlint '**/*.md' --ignore node_modules && echo '✔ Your code looks good.'

lint/yaml:
yamllint --stric . && echo '✔ Your code looks good.'

lint: lint/markdown lint/yaml test/styling test/static
lint: lint/markdown lint/yaml lint/json test/styling test/static

test/static: dependencies
${NPM} run lint

test/styling: dependencies
${NPM} run style:check

format: dependencies
format/sources: dependencies
${NPM} run style:format

format/json:
prettier --write ./src/**/*.json

format: format/sources format/json

test: env dependencies
${NPM} run jest:ci

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,70 +3,30 @@
"title": "Sample Test Case 0",
"n": 5,
"queries": [
[
1,
2,
100
],
[
2,
5,
100
],
[
3,
4,
100
]
[1, 2, 100],
[2, 5, 100],
[3, 4, 100]
],
"expected": 200
},
{
"title": "Sample Test Case 1",
"n": 10,
"queries": [
[
1,
5,
3
],
[
4,
8,
7
],
[
6,
9,
1
]
[1, 5, 3],
[4, 8, 7],
[6, 9, 1]
],
"expected": 10
},
{
"title": "Sample Test Case 3",
"n": 10,
"queries": [
[
2,
6,
8
],
[
3,
5,
7
],
[
1,
8,
1
],
[
5,
9,
15
]
[2, 6, 8],
[3, 5, 7],
[1, 8, 1],
[5, 9, 15]
],
"expected": 31
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,56 @@
[
{"title": "Own 0", "input": [1, 2, 3, 4, 5], "d_rotations": 1, "expected": [2, 3, 4, 5, 1]},
{"title": "Own 1", "input": [2, 3, 4, 5, 1], "d_rotations": 1, "expected": [3, 4, 5, 1, 2]},
{"title": "Own 2", "input": [3, 4, 5, 1, 2], "d_rotations": 1, "expected": [4, 5, 1, 2, 3]},
{"title": "Own 3", "input": [4, 5, 1, 2, 3], "d_rotations": 1, "expected": [5, 1, 2, 3, 4]},
{"title": "Own 4", "input": [5, 1, 2, 3, 4], "d_rotations": 1, "expected": [1, 2, 3, 4, 5]},
{"title": "Sample Test case 0", "input": [1, 2, 3, 4, 5], "d_rotations": 4, "expected": [5, 1, 2, 3, 4]},
{"title": "Sample Test case 1", "input": [41, 73, 89, 7, 10, 1, 59, 58, 84, 77, 77, 97, 58, 1, 86, 58, 26, 10, 86, 51], "d_rotations": 10, "expected": [77, 97, 58, 1, 86, 58, 26, 10, 86, 51, 41, 73, 89, 7, 10, 1, 59, 58, 84, 77]},
{"title": "Sample Test case 2", "input": [33, 47, 70, 37, 8, 53, 13, 93, 71, 72, 51, 100, 60, 87, 97], "d_rotations": 13, "expected": [87, 97, 33, 47, 70, 37, 8, 53, 13, 93, 71, 72, 51, 100, 60]}
{
"title": "Own 0",
"input": [1, 2, 3, 4, 5],
"d_rotations": 1,
"expected": [2, 3, 4, 5, 1]
},
{
"title": "Own 1",
"input": [2, 3, 4, 5, 1],
"d_rotations": 1,
"expected": [3, 4, 5, 1, 2]
},
{
"title": "Own 2",
"input": [3, 4, 5, 1, 2],
"d_rotations": 1,
"expected": [4, 5, 1, 2, 3]
},
{
"title": "Own 3",
"input": [4, 5, 1, 2, 3],
"d_rotations": 1,
"expected": [5, 1, 2, 3, 4]
},
{
"title": "Own 4",
"input": [5, 1, 2, 3, 4],
"d_rotations": 1,
"expected": [1, 2, 3, 4, 5]
},
{
"title": "Sample Test case 0",
"input": [1, 2, 3, 4, 5],
"d_rotations": 4,
"expected": [5, 1, 2, 3, 4]
},
{
"title": "Sample Test case 1",
"input": [
41, 73, 89, 7, 10, 1, 59, 58, 84, 77, 77, 97, 58, 1, 86, 58, 26, 10, 86,
51
],
"d_rotations": 10,
"expected": [
77, 97, 58, 1, 86, 58, 26, 10, 86, 51, 41, 73, 89, 7, 10, 1, 59, 58, 84,
77
]
},
{
"title": "Sample Test case 2",
"input": [33, 47, 70, 37, 8, 53, 13, 93, 71, 72, 51, 100, 60, 87, 97],
"d_rotations": 13,
"expected": [87, 97, 33, 47, 70, 37, 8, 53, 13, 93, 71, 72, 51, 100, 60]
}
]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[
{"title": "Sample input 0", "input": [4, 3, 1, 2], "expected": 3},
{"title": "Sample input 1", "input": [2, 3, 4, 1, 5], "expected": 3},
{"title": "Sample input 2", "input": [1, 3, 5, 2, 4, 6, 7], "expected": 3}
{ "title": "Sample input 0", "input": [4, 3, 1, 2], "expected": 3 },
{ "title": "Sample input 1", "input": [2, 3, 4, 1, 5], "expected": 3 },
{ "title": "Sample input 2", "input": [1, 3, 5, 2, 4, 6, 7], "expected": 3 }
]
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
[
{
"title": "Test Case 0-0",
"input": [2, 1, 5, 3, 4],
"expected": "3"
},
{
"title": "Test Case 0-1",
"input": [2, 5, 1, 3, 4],
"expected": "Too chaotic"
},
{
"title": "Test Case 1-1",
"input": [5, 1, 2, 3, 7, 8, 6, 4],
"expected": "Too chaotic"
},
{
"title": "Test Case 1-2",
"input": [1, 2, 5, 3, 7, 8, 6, 4],
"expected": "7"
},
{
"title": "Test Case 2",
"input": [1, 2, 5, 3, 4, 7, 8, 6],
"expected": "4"
}
]
{
"title": "Test Case 0-0",
"input": [2, 1, 5, 3, 4],
"expected": "3"
},
{
"title": "Test Case 0-1",
"input": [2, 5, 1, 3, 4],
"expected": "Too chaotic"
},
{
"title": "Test Case 1-1",
"input": [5, 1, 2, 3, 7, 8, 6, 4],
"expected": "Too chaotic"
},
{
"title": "Test Case 1-2",
"input": [1, 2, 5, 3, 7, 8, 6, 4],
"expected": "7"
},
{
"title": "Test Case 2",
"input": [1, 2, 5, 3, 4, 7, 8, 6],
"expected": "4"
}
]
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[
{
"title": "Sample Test Case 2",
"input": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
"input": [
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
],
"r": 1,
"expected": 161700
}
Expand Down
Loading
0