func (clock *ballClock) simulateDays() string { clock.halfDays = 0 ballVal := -1 for clock.done == false { ballVal, clock.ballq = slice.Shift(clock.ballq) clock.updMinTrack(ballVal) } return fmt.Sprintf("%d balls cycle for %d days.", clock.numBalls, clock.halfDays/2) }
func (clock *ballClock) simulateDuration() string { ballVal := -1 for i := 0; i < clock.duration; i++ { ballVal, clock.ballq = slice.Shift(clock.ballq) clock.updMinTrack(ballVal) } durationStats := jsonResult{ Min: clock.minTrack, FiveMin: clock.fiveMinTrack, Hour: clock.hourTrack, Main: clock.ballq, } result, err := json.Marshal(durationStats) if err != nil { log.Println("error: ", err) } return string(result) }