forked from wufenggirl/LeetCode-in-Golang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecord.go
55 lines (47 loc) · 1.02 KB
/
record.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import "fmt"
type record struct {
Easy, Medium, Hard, Total count
}
type count struct {
Solved, Total int
}
func (r *record) progressTable() string {
res := fmt.Sprintln("| |Easy|Medium|Hard|Total|")
res += fmt.Sprintln("|:---:|:---:|:---:|:---:|:---:|")
res += fmt.Sprintf("|**Accepted**|%d|", r.Easy.Solved)
res += fmt.Sprintf("%d|", r.Medium.Solved)
res += fmt.Sprintf("%d|", r.Hard.Solved)
res += fmt.Sprintf("%d|\n", r.Total.Solved)
res += fmt.Sprintf("|**Total**|%d|", r.Easy.Total)
res += fmt.Sprintf("%d|", r.Medium.Total)
res += fmt.Sprintf("%d|", r.Hard.Total)
res += fmt.Sprintf("%d|", r.Total.Total)
return res
}
func (r *record) update(p problem) {
if !p.isAvailable() {
return
}
switch p.Difficulty {
case "Easy":
r.Easy.Total++
if p.IsAccepted {
r.Easy.Solved++
}
case "Medium":
r.Medium.Total++
if p.IsAccepted {
r.Medium.Solved++
}
case "Hard":
r.Hard.Total++
if p.IsAccepted {
r.Hard.Solved++
}
}
r.Total.Total++
if p.IsAccepted {
r.Total.Solved++
}
}