Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 70cbf2e

Browse files
author
Openset
committed
Add: Student Attendance Record I (Easy)
1 parent ba3bcf2 commit 70cbf2e

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
11
package student_attendance_record_i
2+
3+
import "strings"
4+
5+
func checkRecord(s string) bool {
6+
return !strings.Contains(s, "LLL") && strings.Count(s, "A") <= 1
7+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,27 @@
11
package student_attendance_record_i
2+
3+
import "testing"
4+
5+
type caseType struct {
6+
input string
7+
expected bool
8+
}
9+
10+
func TestCheckRecord(t *testing.T) {
11+
tests := [...]caseType{
12+
{
13+
input: "PPALLP",
14+
expected: true,
15+
},
16+
{
17+
input: "PPALLL",
18+
expected: false,
19+
},
20+
}
21+
for _, tc := range tests {
22+
output := checkRecord(tc.input)
23+
if output != tc.expected {
24+
t.Fatalf("input: %v, output: %v, expected: %v", tc.input, output, tc.expected)
25+
}
26+
}
27+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /