-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
45 lines (42 loc) · 880 Bytes
/
main.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
package main
import (
"encoding/csv"
"fmt"
"log"
"os"
"time"
)
func main () {
var cnt = 0
var icnt = 0
var espaco string
//Opening CSV
file, _ := os.Open("problems.csv")
defer file.Close()
reader := csv.NewReader(file)
data,_ := reader.ReadAll()
//Initializing the timer
fmt.Printf("Digite t para iniciar o timer\n")
fmt.Scanf("%s", &espaco)
if espaco == "t" {
for _, value := range data {
icnt++
fmt.Printf("%s = ", value[0])
//Setting the the timer to init alongside the loop
time.AfterFunc(30 * time.Second, func (){
fmt.Println()
fmt.Printf("Voce acertou %d de %d", cnt, icnt )
log.Fatal("Tempo limite excedido")
})
var res string
fmt.Scanf("%s", &res)
if res == value[1]{
fmt.Printf("correto\n")
cnt++
} else {
fmt.Printf("Incorreto\n")
}
}
fmt.Printf("Voce acertou %d de %d", cnt, icnt )
}
}