@@ -14,11 +14,11 @@ import (
1414)
1515
1616// FindContest will find the latest contest in the contests array
17- func FindContest (contests []contest.Contest ) (int , error ) {
17+ func FindContest (contests []contest.Contest ) (contest. Contest , error ) {
1818 contestsSiz := len (contests )
1919
2020 if contestsSiz <= 0 {
21- return 0 , errors .New ("[Info] Contests is an empty field" )
21+ return contest. Contest {} , errors .New ("[Info] Contests is an empty field" )
2222 }
2323
2424 var lastContestTime int64 = 100000000
@@ -39,30 +39,30 @@ func FindContest(contests []contest.Contest) (int, error) {
3939 }
4040
4141 if lastContestIndex == - 1 {
42- return 0 , errors .New ("[Info] No vaild contest" )
42+ return contest. Contest {} , errors .New ("[Info] No vaild contest" )
4343 }
4444
4545 fmt .Println ("[Info] The current contest is " + contests [lastContestIndex ].Name )
4646
4747 openHackingPhase := currentTime - contests [lastContestIndex ].StartTimeSeconds - contests [lastContestIndex ].DurationSeconds
4848
49- if openHackingPhase > 12 * 3600 {
50- return 0 , errors .New ("[Info] Open hacking phase finished" )
49+ if openHackingPhase < 12 * 3600 {
50+ return contest. Contest {} , errors .New ("[Info] Open hacking phase finished" )
5151 }
5252
5353 fmt .Println ("[Info] Open hacking phase running" )
5454
55- return contests [lastContestIndex ]. ID , nil
55+ return contests [lastContestIndex ], nil
5656}
5757
5858// ChooseProblem will fetch the problem in the contest and read user's input from stdin
59- func ChooseProblem (ContestID int , cookie * []* http.Cookie ) (int , error ) {
59+ func ChooseProblem (ContestID int , cookie * []* http.Cookie ) (string , error ) {
6060 fmt .Println ("[Info] Fetching Problems..." )
6161
6262 problems , e := contest .GetProblems (ContestID , cookie )
6363
6464 if e != nil {
65- return 0 , e
65+ return "" , e
6666 }
6767
6868 fmt .Println ("" )
@@ -83,7 +83,7 @@ func ChooseProblem(ContestID int, cookie *[]*http.Cookie) (int, error) {
8383 content , e := myReader .ReadString ('\n' )
8484
8585 if e != nil {
86- return 0 , e
86+ return "" , e
8787 }
8888
8989 fields := strings .Fields (content )
@@ -102,7 +102,7 @@ func ChooseProblem(ContestID int, cookie *[]*http.Cookie) (int, error) {
102102 content , e = myReader .ReadString ('\n' )
103103
104104 if e != nil {
105- return 0 , e
105+ return "" , e
106106 }
107107
108108 fields = strings .Fields (content )
@@ -115,5 +115,5 @@ func ChooseProblem(ContestID int, cookie *[]*http.Cookie) (int, error) {
115115 choose , e = strconv .Atoi (fields [0 ])
116116 }
117117
118- return choose , nil
118+ return problems [ choose - 1 ]. Index , nil
119119}
0 commit comments