Skip to content
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
6 changes: 3 additions & 3 deletions .github/workflows/go-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version: '1.24'

- name: Install dependencies
run: go mod tidy
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version: '1.24'
cache: true

- name: Install golangci-lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.59.1
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.64.5

- name: Print Go environment
run: |
Expand Down
26 changes: 18 additions & 8 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
linters:
disable-all: false
enable:
- errorlint
#- godot
- goimports
- misspell
- nolintlint
- predeclared
- testifylint
- unconvert
- durationcheck
- exportloopref
- nilerr
- whitespace
- unparam
- tagalign
- stylecheck
- gosec
#- gofumpt
- perfsprint
- nestif
- noctx
- prealloc
- depguard
# - revive
# - gocritic
# - wastedassign
# - goconst
# - gomnd
- gocritic
- bodyclose

linters-settings:
depguard:
rules:
main:
deny:
- pkg: "io/ioutil"
desc: "ioutil is deprecated, use os or io instead"

nestif:
min-complexity: 5

run:
timeout: 5m
tests: true
11 changes: 1 addition & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,7 @@ The test cases should test both solutions.
### Solution Template

```go
/*
[Issue title]

// Time complexity: O(n)
// Space complexity: O(n)
func ImprovedSolution() {

*/

package challenge
package challengeName

// Time complexity: O(n)
// Space complexity: O(n)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/angelicagardner/coding-challenges

go 1.21.1
go 1.24
File renamed without changes.
14 changes: 14 additions & 0 deletions projecteuler/problem_001.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package projecteuler

// Time complexity: O(1)
// Space complexity: O(1)
func Solution(limit int) int {
n := limit - 1

sumMultiples := func(k int) int {
p := n / k
return k * (p * (p + 1)) / 2
}

return sumMultiples(3) + sumMultiples(5) - sumMultiples(15)
}
25 changes: 25 additions & 0 deletions projecteuler/problem_001_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package projecteuler

import "testing"

func TestSolution(t *testing.T) {
t.Run("limit 10", func(t *testing.T) {
limit := 10
expected := 23
got := Solution(limit)

if got != expected {
t.Errorf("Solution(%d) = %d; want %d", limit, got, expected)
}
})

t.Run("limit 1000", func(t *testing.T) {
limit := 1000
expected := 233168
got := Solution(limit)

if got != expected {
t.Errorf("Solution(%d) = %d; want %d", limit, got, expected)
}
})
}
Loading