Skip to content

Commit 971e1ff

Browse files
Merge pull request #11 from james-gates-0212/10-bracket-combinations
10 bracket combinations
2 parents bf1cdfc + 6803257 commit 971e1ff

File tree

7 files changed

+186
-1
lines changed

7 files changed

+186
-1
lines changed

.github/workflows/auto-assign.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Auto Assign
2+
on:
3+
issues:
4+
types: [opened]
5+
pull_request:
6+
types: [opened]
7+
jobs:
8+
run:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
issues: write
12+
pull-requests: write
13+
steps:
14+
- name: 'Auto-assign issue'
15+
uses: pozil/auto-assign-issue@v1
16+
with:
17+
repo-token: ${{ secrets.GITHUB_TOKEN }}
18+
assignees: james-gates-0212
19+
numOfAssignee: 1

.github/workflows/codeql.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ "main" ]
17+
pull_request:
18+
branches: [ "main" ]
19+
schedule:
20+
- cron: '43 9 * * 6'
21+
22+
jobs:
23+
analyze:
24+
name: Analyze
25+
# Runner size impacts CodeQL analysis time. To learn more, please see:
26+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
27+
# - https://gh.io/supported-runners-and-hardware-resources
28+
# - https://gh.io/using-larger-runners
29+
# Consider using larger runners for possible analysis time improvements.
30+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
31+
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
32+
permissions:
33+
# required for all workflows
34+
security-events: write
35+
36+
# only required for workflows in private repositories
37+
actions: read
38+
contents: read
39+
40+
strategy:
41+
fail-fast: false
42+
matrix:
43+
language: [ 'javascript-typescript' ]
44+
# CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ]
45+
# Use only 'java-kotlin' to analyze code written in Java, Kotlin or both
46+
# Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
47+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
48+
49+
steps:
50+
- name: Checkout repository
51+
uses: actions/checkout@v4
52+
53+
# Initializes the CodeQL tools for scanning.
54+
- name: Initialize CodeQL
55+
uses: github/codeql-action/init@v3
56+
with:
57+
languages: ${{ matrix.language }}
58+
# If you wish to specify custom queries, you can do so here or in a config file.
59+
# By default, queries listed here will override any specified in a config file.
60+
# Prefix the list here with "+" to use these queries and those in the config file.
61+
62+
# 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
63+
# queries: security-extended,security-and-quality
64+
65+
66+
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
67+
# If this step fails, then you should remove it and run the build manually (see below)
68+
- name: Autobuild
69+
uses: github/codeql-action/autobuild@v3
70+
71+
# ℹ️ Command-line programs to run using the OS shell.
72+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
73+
74+
# If the Autobuild fails above, remove it and uncomment the following three lines.
75+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
76+
77+
# - run: |
78+
# echo "Run, Build Application using script"
79+
# ./location_of_script_within_repo/buildscript.sh
80+
81+
- name: Perform CodeQL Analysis
82+
uses: github/codeql-action/analyze@v3
83+
with:
84+
category: "/language:${{matrix.language}}"

.github/workflows/proof-html.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Proof HTML
2+
on:
3+
push:
4+
workflow_dispatch:
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: anishathalye/proof-html@v1.1.0
10+
with:
11+
directory: ./

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# 📓JavaScript Assessments
22

3+
Here are JavaScript Assessments. I hope it could helps you and your works.
4+
5+
## 🔖Repository Status
6+
7+
[![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)
8+
[![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)
9+
[![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)
10+
11+
## Table of contents
12+
13+
- [Bracket Combinations](bracket-combinations)
314
- [Calculate the sum of the numbers in a nested array](calculate-the-sum-of-the-numbers-in-a-nested-array)
415
- [Convert string to group](convert-string-to-group)
516
- [Delete Overlapping Intervals](delete-overlapping-intervals)
@@ -63,11 +74,14 @@ e.g.
6374
```bash
6475
add
6576
adopt
77+
apply
6678
build
6779
chore
80+
config
6881
docs
6982
feat
7083
fix
84+
init
7185
refactor
7286
remove
7387
style

bracket-combinations/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Bracket Combinations
2+
3+
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.
4+
5+
## Examples
6+
7+
```javascript
8+
BracketCombinations(2); // should == 2
9+
BracketCombinations(3); // should == 5
10+
```
11+
12+
## Execute
13+
14+
```bash
15+
node solution.js
16+
```

bracket-combinations/solution.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
function BracketCombinations(num) {
2+
if (num === 0) {
3+
return 1;
4+
}
5+
// By Doing sum search i found a formula that can achieve what this problem want
6+
// called Catalan number (Catalan Formula)
7+
// where catalan formula is ==> (2n!) / (n+1)! n!
8+
9+
// first i will calculate the factorial of the num
10+
let factorial = (n) => {
11+
let k = 1;
12+
for (var i = n; i >= 2; i--) {
13+
k *= i;
14+
}
15+
return k;
16+
};
17+
18+
// formula going down
19+
const result = factorial(2 * num) / (factorial(num + 1) * factorial(num));
20+
return result;
21+
}
22+
23+
(() => {
24+
[2, 3, 5, 8].forEach((num) => {
25+
console.log(JSON.stringify(num), '==', BracketCombinations(num));
26+
});
27+
})();

commitlint.config.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,21 @@ const config = {
5252
'type-enum': [
5353
2,
5454
'always',
55-
['add', 'adopt', 'build', 'chore', 'docs', 'feat', 'fix', 'refactor', 'remove', 'style'],
55+
[
56+
'add',
57+
'adopt',
58+
'apply',
59+
'build',
60+
'chore',
61+
'config',
62+
'docs',
63+
'feat',
64+
'fix',
65+
'init',
66+
'refactor',
67+
'remove',
68+
'style',
69+
],
5670
],
5771
},
5872
};

0 commit comments

Comments
 (0)