Skip to content

Commit 2c282a8

Browse files
authored
add problem counter (#103)
1 parent 1467bba commit 2c282a8

File tree

9 files changed

+55
-23
lines changed

9 files changed

+55
-23
lines changed

.github/scripts/count-rehearsals.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
# Counts the number of rehearsal files in each section
3+
set -euo pipefail
4+
5+
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
6+
# shellcheck source=.github/scripts/sections.sh
7+
source "${SCRIPT_DIR}/sections.sh"
8+
9+
ALL_TESTS=0
10+
# shellcheck disable=SC2154
11+
for section in "${sections[@]}"; do
12+
SECTION_TESTS=$(find "${section}" -name "*_test.go" | wc -l)
13+
ALL_TESTS=$((ALL_TESTS + SECTION_TESTS))
14+
done
15+
echo $ALL_TESTS

.github/scripts/export-md.sh

+6-16
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,16 @@
11
#!/usr/bin/env bash
2+
# Exports the markdown files from the docs site
23
set -euo pipefail
34

4-
# This script is used to export the markdown files from the docs site
5+
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
6+
# shellcheck source=./.github/scripts/sections.sh
7+
source "${SCRIPT_DIR}/sections.sh"
8+
59
declare -a files=(
610
README.md
711
complexity.md
8-
./array/README.md
9-
./strings/README.md
10-
./linkedlist/README.md
11-
./stack/README.md
12-
./queue/README.md
13-
./hashtable/README.md
14-
./tree/README.md
15-
./heap/README.md
16-
./recursion/README.md
17-
./dnc//README.md
18-
./bit//README.md
19-
./backtracking/README.md
20-
./graph/README.md
21-
./greedy/README.md
22-
./dp/README.md
2312
)
13+
files+=("${sections[@]/%//README.md}")
2414

2515
for file in "${files[@]}"; do
2616
cat "$file"

.github/scripts/sections.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
declare -a sections=(
5+
./array
6+
./strings
7+
./linkedlist
8+
./stack
9+
./queue
10+
./hashtable
11+
./tree
12+
./heap
13+
./recursion
14+
./dnc
15+
./bit
16+
./backtracking
17+
./graph
18+
./greedy
19+
./dp
20+
)
21+
22+
export sections

.github/workflows/tests.yaml

+6-5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v3
14+
- uses: reviewdog/action-misspell@v1
15+
with:
16+
github_token: ${{ secrets.github_token }}
17+
locale: "US"
1418
- uses: github/super-linter@v4
1519
env:
1620
DEFAULT_BRANCH: main
@@ -22,10 +26,7 @@ jobs:
2226
YAML_CONFIG_FILE: .yamllint.yml
2327
VALIDATE_GITLEAKS: false
2428
LOG_LEVEL: WARN
25-
- uses: reviewdog/action-misspell@v1
26-
with:
27-
github_token: ${{ secrets.github_token }}
28-
locale: "US"
29+
VALIDATE_SHELL_SHFMT: false
2930
tests:
3031
runs-on: ubuntu-latest
3132
steps:
@@ -37,7 +38,7 @@ jobs:
3738
~/.cache/go-build
3839
~/go/pkg/
3940
~/go/bin/
40-
key: go-cache-${{ hashFiles('go.sum') }}
41+
key: go-cache-${{ hashFiles('go.mod') }}
4142
- run: go test -v -coverprofile=profile.cov ./...
4243
- uses: shogo82148/actions-goveralls@v1
4344
with:

greedy/task_scheduling.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ package greedy
22

33
import "sort"
44

5+
// Event represents an event to be scheduled.
56
type Event struct {
67
Name string
78
StartTime int
89
EndTime int
910
}
1011

11-
// Solves the problem in O(n*Log n) time and O(1) space.
12+
// ScheduleEvents Solves the problem in O(n*Log n) time and O(1) space.
1213
func ScheduleEvents(events []Event) []Event {
1314
sort.Slice(events, func(i, j int) bool {
1415
return events[i].EndTime < events[j].EndTime

heap/heap_sort.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func HeapSort(list []int) []int {
3131
return sorted
3232
}
3333

34-
// Returns a new Min Heap.
34+
// NewMinHeap Returns a new Min Heap.
3535
func NewMinHeap() *MinHeap {
3636
return &MinHeap{
3737
Data: []*Vertex{},

queue/queue_using_circular_array.go

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type UsingCircularArray struct {
1212

1313
const emptyValue = 0
1414

15+
// ErrQueueAtMaxCapacity occurs when the queue is at max capacity.
1516
var ErrQueueAtMaxCapacity = errors.New("queue is at max capacity")
1617

1718
// NewCircularQueue returns a fixed size circular queue.

stack/basic_calculator.go

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ type evaluation struct {
88
stack []float64
99
}
1010

11+
// ErrImbalancedParentheses occurs when the expression has imbalanced parentheses.
1112
var ErrImbalancedParentheses = errors.New("expression has imbalanced parentheses")
1213

1314
// BasicCalculator solves the problem in O(n) time and O(n) space.

strings/reverse_vowels.go

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ var (
1111
`i`: true,
1212
`u`: true,
1313
}
14+
// ErrPopStack is returned when the stack is empty.
1415
ErrPopStack = errors.New("can not Pop on an empty stack")
1516
)
1617

0 commit comments

Comments
 (0)