Skip to content

Instantly share code, notes, and snippets.

@hyojjxipitug
Last active December 30, 2025 16:38
Show Gist options
  • Select an option

  • Save hyojjxipitug/e9eb26321038e4d8cfb38828e4fd98ab to your computer and use it in GitHub Desktop.

Select an option

Save hyojjxipitug/e9eb26321038e4d8cfb38828e4fd98ab to your computer and use it in GitHub Desktop.
Answer to interview question from Cassidoo’s newsletter (12/29/25):
def replaceRepeats(s, n):
count = 0
output = ''
for c in s:
if c == str(n):
count += 1
elif count > 0 and c != str(n):
output += str(count)
output += c
count = 0
else:
output += c
if count > 0:
output += str(count)
return output
assert replaceRepeats('1234500362000440', 0), '1234523623441'
assert replaceRepeats('000000000000', 0), '12'
assert replaceRepeats('123456789', 1), '123456789'
print('Happy 2026 🥳🎉')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment