dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
1.5 KiB
1.5 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 69b559d2903b9e4afe9075f8 | Challenge 238: Digit Rotation Escape | 29 | challenge-238 |
--description--
Given a positive integer, determine if it, or any of its rotations, is evenly divisible by its digit count.
A rotation means to move the first digit to the end. For example, after 1 rotation, 123 becomes 231.
- Check rotation
0(the given number) first. - Given numbers won't contain any zeros.
- Return the first rotation number if one is found, or
"none"if not.
--hints--
get_rotation(123) should return 0.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_rotation(123), 0)`)
}})
get_rotation(13579) should return 3.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_rotation(13579), 3)`)
}})
get_rotation(24681) should return "none".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_rotation(24681), "none")`)
}})
get_rotation(84138789345) should return 6.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_rotation(84138789345), 6)`)
}})
--seed--
--seed-contents--
def get_rotation(n):
return n
--solutions--
def get_rotation(n):
s = str(n)
digit_count = len(s)
current = s
for i in range(digit_count):
if int(current) % digit_count == 0:
return i
current = current[1:] + current[0]
return "none"