Skip to content

Commit 78e01bc

Browse files
authored
Merge pull request #304 from sir-gon/develop
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Arrays: New Year …
2 parents 838c56b + df9056e commit 78e01bc

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

exercises/hackerrank/interview_preparation_kit/arrays/new_year_chaos.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
//nolint:stylecheck // error strings should not be capitalized (ST1005)
1313
const tooChaoticError = "Too chaotic"
14+
const NEW_YEAR_CHAOS_TOLERANCE = 2
1415

1516
func minimumBribesCalculate(q []int32) (int32, error) {
1617

@@ -21,12 +22,13 @@ func minimumBribesCalculate(q []int32) (int32, error) {
2122
for _, value = range q {
2223
position := i + 1
2324

24-
if value-int32(position) > 2 {
25-
//nolint:stylecheck // error strings should not be capitalized (ST1005)
25+
if value-int32(position) > NEW_YEAR_CHAOS_TOLERANCE {
26+
// error strings should not be capitalized (ST1005)
27+
//nolint:stylecheck
2628
return 0, errors.New(tooChaoticError)
2729
}
2830

29-
var fragment []int32 = q[min(max(value-2, 0), int32(i)):i]
31+
var fragment []int32 = q[min(max(value-NEW_YEAR_CHAOS_TOLERANCE, 0), int32(i)):i]
3032

3133
for _, k := range fragment {
3234
if k > value {

0 commit comments

Comments
 (0)