-
Notifications
You must be signed in to change notification settings - Fork 1
/
testFunc.js
90 lines (80 loc) · 2.1 KB
/
testFunc.js
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
const main = ()=>{
var righttime = 10
var wrongtime = 10
var drawntime = 10
var totaltime = 30
var test = [44,55,66,44,32,17]
wrongtime += time_of_wrong(test,33)
righttime += time_of_right(test,33)
drawntime += time_of_drawn(test,33)
totaltime = righttime+wrongtime+drawntime
//console.log(reranktotalscore(test,33))
console.log(righttime)
console.log(wrongtime)
console.log(drawntime)
console.log("totaltime = "+totaltime)
console.log(checkhuay(9,10))
displaypercent(righttime,wrongtime,drawntime,totaltime)
console.log(checkhuay(47,38))
console.log(checkhuay(92,29))
}
const displaypercent = (right,wrong,drawn,total)=>{
console.log(((right/total)*100).toFixed(2))
console.log(((wrong/total)*100).toFixed(2))
console.log(((drawn/total)*100).toFixed(2))
console.log((((right/total)*100)+(wrong/total)*50).toFixed(2))
}
const totaltime_of_baihuay = (amount)=>{
return amount.length
}
const time_of_right = (amount,prize)=>{
var x = 0
for(i=0;i<amount.length;i++){
if(checkhuay(amount[i],prize) == 3)x += 1
}
return x
}
const time_of_wrong = (amount,prize)=>{
var x = 0
for(i=0;i<amount.length;i++){
if(checkhuay(amount[i],prize) == -0.5)x += 1
}
return x
}
const time_of_drawn = (amount,prize)=>{
var x = 0
for(i=0;i<amount.length;i++){
if(checkhuay(amount[i],prize) == 1)x += 1
}
return x
}
const time_of_swift = (amount,prize)=>{
var x = 0
for(i=0;i<amount.length;i++){
if(checkhuay(amount[i],prize) == 2)x += 1
}
return x
}
const reranktotalscore =(allbai,prize)=>{
var score = 0
for (i = 0;i<allbai.length;i++){
score += checkhuay(allbai[i],prize)
}
return score
}
const checkhuay =(doubt,prize)=>{
var swift = 10*(doubt%10)+(prize%10)
var check = doubt+prize
var x = prize-doubt
if(x==0){
return 3
}else if(x==1||x==-1||x==10||x==-10){
return 1
}else if(swift==doubt||swift==prize){
return 2
}else{
return -0.5
}
//console.log(total)
}
main()