feat(runner): compile Go and check answers per test group
This commit is contained in:
1 parent
e95c681165
commit
afee564bf4
61 files changed
+2592
-143
No files matched your search
+5
@@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
unused := 1
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
scanner.Split(bufio.ScanWords)
|
||||
var total, count float64
|
||||
for scanner.Scan() {
|
||||
value, err := strconv.ParseFloat(scanner.Text(), 64)
|
||||
if err != nil {
|
||||
os.Exit(2)
|
||||
}
|
||||
total += value
|
||||
count++
|
||||
}
|
||||
fmt.Printf("%.9f\n", total/count)
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
var target int
|
||||
if _, err := fmt.Fscan(reader, &target); err != nil {
|
||||
os.Exit(2)
|
||||
}
|
||||
seen := map[int]int{}
|
||||
scanner := bufio.NewScanner(reader)
|
||||
scanner.Split(bufio.ScanWords)
|
||||
for position := 1; scanner.Scan(); position++ {
|
||||
value, err := strconv.Atoi(scanner.Text())
|
||||
if err != nil {
|
||||
os.Exit(2)
|
||||
}
|
||||
if first, ok := seen[target-value]; ok {
|
||||
fmt.Println(first, position)
|
||||
return
|
||||
}
|
||||
if _, ok := seen[value]; !ok {
|
||||
seen[value] = position
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// Wrong: always answers the first two positions.
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println(1, 2)
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
scanner.Split(bufio.ScanWords)
|
||||
total := new(big.Int)
|
||||
for scanner.Scan() {
|
||||
value, ok := new(big.Int).SetString(scanner.Text(), 10)
|
||||
if !ok {
|
||||
os.Exit(2)
|
||||
}
|
||||
total.Add(total, value)
|
||||
}
|
||||
fmt.Println(total)
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// Wrong: int64 overflows, so only the group with huge numbers fails.
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
scanner.Split(bufio.ScanWords)
|
||||
var total int64
|
||||
for scanner.Scan() {
|
||||
value, err := strconv.ParseInt(scanner.Text(), 10, 64)
|
||||
if err != nil {
|
||||
os.Exit(2)
|
||||
}
|
||||
total += value
|
||||
}
|
||||
fmt.Println(total)
|
||||
}
|
||||
Reference in new issue
Block a user