Skip to content

Instantly share code, notes, and snippets.

@Shaddyjr
Created November 11, 2025 14:44
Show Gist options
  • Select an option

  • Save Shaddyjr/07d39d34700c80c8faf916bb3fa83f13 to your computer and use it in GitHub Desktop.

Select an option

Save Shaddyjr/07d39d34700c80c8faf916bb3fa83f13 to your computer and use it in GitHub Desktop.
# Source: https://www.hackerrank.com/challenges/strange-code/problem
# Video: https://youtu.be/12nt1BhS4r4
def strangeCounter(t):
# keep running time
# interate for each max value
current_max_val = 3 # always 3
while t > current_max_val:
# there's still a whole group of current_max_val to skip
t -= current_max_val
current_max_val <<= 1
return current_max_val - t + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment