-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathscorev3.go
97 lines (82 loc) · 2.35 KB
/
scorev3.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
"time"
)
const (
accuracyPortion = 0.3
comboPortion = 0.7
thresholdScore = 1099727 // Threshold score required to unlock the flag
)
func calculateScore(accuracy, combo, maxAchievableCombo, modeBonus float64, currentTime int64) float64 {
// Introduce a time-dependent modifier based on time % 727
timeModifier := float64(currentTime%727) / 727
// Modify accuracy and combo based on the time modifier
adjustedAccuracy := accuracy + (1-accuracy)*timeModifier
adjustedCombo := combo + (maxAchievableCombo-combo)*timeModifier
// Calculate v3 score
totalScore := 1000000 * ((adjustedAccuracy * accuracyPortion) + (adjustedCombo / maxAchievableCombo * comboPortion))
totalScore *= modeBonus
return totalScore
}
func parseInput(input string) (modeBonus, accuracy, combo, maxAchievableCombo float64, err error) {
parts := strings.Fields(input)
// Parse mode, can be HD, HR or DT
switch parts[0] {
case "HD":
modeBonus = 1.06
case "HR":
modeBonus = 1.08
case "DT":
modeBonus = 1.1
default:
err = fmt.Errorf("bad input")
return
}
// Parse accuracy
accuracyStr := strings.TrimSuffix(parts[1], "%")
accuracy, err = strconv.ParseFloat(accuracyStr, 64)
if err != nil || accuracy < 0 || accuracy > 95 {
err = fmt.Errorf("bad input")
return
}
accuracy /= 100
// Parse combo
comboParts := strings.Split(strings.TrimSuffix(parts[2], "x"), "/")
combo, err = strconv.ParseFloat(comboParts[0], 64)
if err != nil {
err = fmt.Errorf("bad input")
return
}
maxAchievableCombo, err = strconv.ParseFloat(comboParts[1], 64)
if err != nil || maxAchievableCombo != 1200 || combo > 1000 {
err = fmt.Errorf("bad input")
return
}
return
}
func main() {
// input := "DT 95% 1000/1200x"
reader := bufio.NewReader(os.Stdin)
input, _ := reader.ReadString('\n')
modeBonus, accuracy, combo, maxAchievableCombo, err := parseInput(input)
if err != nil {
return
}
currentTime := time.Now().Unix()
// Check if the player's score meets the threshold for the flag
if int(calculateScore(accuracy, combo, maxAchievableCombo, modeBonus, currentTime)) >= thresholdScore {
flag, err := os.ReadFile("flag.txt")
if err != nil {
fmt.Println("Error reading flag file:", err)
return
}
fmt.Println("Congratulations! Here is your flag:", string(flag))
} else {
fmt.Println("Keep trying!")
}
}