From 9de23878737fb57c7d39482909af64f746a3fd62 Mon Sep 17 00:00:00 2001 From: james-gates-0212 Date: Wed, 27 Mar 2024 11:34:57 -0700 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20commit=20lint=E2=99=BB=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 +++ commitlint.config.js | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3ff495c..89f63e0 100644 --- a/README.md +++ b/README.md @@ -63,11 +63,14 @@ e.g. ```bash add adopt +apply build chore +config docs feat fix +init refactor remove style diff --git a/commitlint.config.js b/commitlint.config.js index 5e991ed..cd9ebe4 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -52,7 +52,21 @@ const config = { 'type-enum': [ 2, 'always', - ['add', 'adopt', 'build', 'chore', 'docs', 'feat', 'fix', 'refactor', 'remove', 'style'], + [ + 'add', + 'adopt', + 'apply', + 'build', + 'chore', + 'config', + 'docs', + 'feat', + 'fix', + 'init', + 'refactor', + 'remove', + 'style', + ], ], }, }; From 3a6a3976fd4bb1a6bdf4ee0a868e5e75d1edfd60 Mon Sep 17 00:00:00 2001 From: james-gates-0212 Date: Wed, 27 Mar 2024 11:35:25 -0700 Subject: [PATCH 2/4] =?UTF-8?q?add:=20bracket=20combinations=F0=9F=91=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + bracket-combinations/README.md | 16 ++++++++++++++++ bracket-combinations/solution.js | 27 +++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 bracket-combinations/README.md create mode 100644 bracket-combinations/solution.js diff --git a/README.md b/README.md index 89f63e0..e10dc31 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # 📓JavaScript Assessments +- [Bracket Combinations](bracket-combinations) - [Calculate the sum of the numbers in a nested array](calculate-the-sum-of-the-numbers-in-a-nested-array) - [Convert string to group](convert-string-to-group) - [Delete Overlapping Intervals](delete-overlapping-intervals) diff --git a/bracket-combinations/README.md b/bracket-combinations/README.md new file mode 100644 index 0000000..5db7cd3 --- /dev/null +++ b/bracket-combinations/README.md @@ -0,0 +1,16 @@ +# Bracket Combinations + +Have the function `BracketCombinations(num)` read `num` which will be an integer greater than or equal to zero, and return the number of valid combinations that can be formed with num pairs of parentheses. For example, if the input is 3, then the possible combinations of 3 pairs of parenthesis, namely: `()()()`, are `()()()`, `()(())`, `(())()`, `((()))`, and `(()())`. There are 5 total combinations when the input is 3, so your program should return 5. + +## Examples + +```javascript +BracketCombinations(2); // should == 2 +BracketCombinations(3); // should == 5 +``` + +## Execute + +```bash +node solution.js +``` diff --git a/bracket-combinations/solution.js b/bracket-combinations/solution.js new file mode 100644 index 0000000..5f02c75 --- /dev/null +++ b/bracket-combinations/solution.js @@ -0,0 +1,27 @@ +function BracketCombinations(num) { + if (num === 0) { + return 1; + } + // By Doing sum search i found a formula that can achieve what this problem want + // called Catalan number (Catalan Formula) + // where catalan formula is ==> (2n!) / (n+1)! n! + + // first i will calculate the factorial of the num + let factorial = (n) => { + let k = 1; + for (var i = n; i >= 2; i--) { + k *= i; + } + return k; + }; + + // formula going down + const result = factorial(2 * num) / (factorial(num + 1) * factorial(num)); + return result; +} + +(() => { + [2, 3, 5, 8].forEach((num) => { + console.log(JSON.stringify(num), '==', BracketCombinations(num)); + }); +})(); From 57ec5345a614cca64856244ef46bd915f2cb9da7 Mon Sep 17 00:00:00 2001 From: james-gates-0212 Date: Wed, 27 Mar 2024 11:45:57 -0700 Subject: [PATCH 3/4] =?UTF-8?q?add:=20github=20workflows=F0=9F=9A=A7?= =?UTF-8?q?=E2=9C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/auto-assign.yml | 19 +++++++ .github/workflows/codeql.yml | 84 +++++++++++++++++++++++++++++++ .github/workflows/proof-html.yml | 11 ++++ 3 files changed, 114 insertions(+) create mode 100644 .github/workflows/auto-assign.yml create mode 100644 .github/workflows/codeql.yml create mode 100644 .github/workflows/proof-html.yml diff --git a/.github/workflows/auto-assign.yml b/.github/workflows/auto-assign.yml new file mode 100644 index 0000000..83ac74b --- /dev/null +++ b/.github/workflows/auto-assign.yml @@ -0,0 +1,19 @@ +name: Auto Assign +on: + issues: + types: [opened] + pull_request: + types: [opened] +jobs: + run: + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + steps: + - name: 'Auto-assign issue' + uses: pozil/auto-assign-issue@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + assignees: james-gates-0212 + numOfAssignee: 1 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..9b54107 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,84 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + schedule: + - cron: '43 9 * * 6' + +jobs: + analyze: + name: Analyze + # Runner size impacts CodeQL analysis time. To learn more, please see: + # - https://gh.io/recommended-hardware-resources-for-running-codeql + # - https://gh.io/supported-runners-and-hardware-resources + # - https://gh.io/using-larger-runners + # Consider using larger runners for possible analysis time improvements. + runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} + timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} + permissions: + # required for all workflows + security-events: write + + # only required for workflows in private repositories + actions: read + contents: read + + strategy: + fail-fast: false + matrix: + language: [ 'javascript-typescript' ] + # CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ] + # Use only 'java-kotlin' to analyze code written in Java, Kotlin or both + # Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v3 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/proof-html.yml b/.github/workflows/proof-html.yml new file mode 100644 index 0000000..be7dac3 --- /dev/null +++ b/.github/workflows/proof-html.yml @@ -0,0 +1,11 @@ +name: Proof HTML +on: + push: + workflow_dispatch: +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: anishathalye/proof-html@v1.1.0 + with: + directory: ./ From 8787e016292fc8b497ed3546ddc2892ad73151b0 Mon Sep 17 00:00:00 2001 From: james-gates-0212 Date: Wed, 27 Mar 2024 11:49:11 -0700 Subject: [PATCH 4/4] =?UTF-8?q?chore:=20upgrade=20readme=20for=20github=20?= =?UTF-8?q?workflows=F0=9F=9A=A7=F0=9F=9A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index e10dc31..ffc09ef 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,15 @@ # 📓JavaScript Assessments +Here are JavaScript Assessments. I hope it could helps you and your works. + +## 🔖Repository Status + +[![Auto Assign](https://github.com/james-gates-0212/js-assessments/actions/workflows/auto-assign.yml/badge.svg)](https://github.com/james-gates-0212/js-assessments/actions/workflows/auto-assign.yml) +[![CodeQL](https://github.com/james-gates-0212/js-assessments/actions/workflows/codeql.yml/badge.svg)](https://github.com/james-gates-0212/js-assessments/actions/workflows/codeql.yml) +[![Proof HTML](https://github.com/james-gates-0212/js-assessments/actions/workflows/proof-html.yml/badge.svg)](https://github.com/james-gates-0212/js-assessments/actions/workflows/proof-html.yml) + +## Table of contents + - [Bracket Combinations](bracket-combinations) - [Calculate the sum of the numbers in a nested array](calculate-the-sum-of-the-numbers-in-a-nested-array) - [Convert string to group](convert-string-to-group)