Base 7
Real-world version: Seven-Rod Counting FrameThe statement here is our own: the same inputs, outputs and technique.
A museum shows an old counting frame that works in sevens. Each rod carries from zero to six beads, and a rod is worth seven times the rod immediately to its right, so the rightmost rod counts ones, the next counts sevens, the next counts forty-nines, and so on.
Given an integer value, return the text a curator would write on the label: the bead count of each rod, read from the leftmost rod that carries a bead down to the ones rod, with no extra zero in front. If value is negative, put a single - before those digits. If value is zero, the label is the single character 0.
Examples
Example 1
- Input
- value = 342
- Output
- "666"
Six beads on the forty-nines rod, six on the sevens rod and six on the ones rod come to 294 plus 42 plus 6.
Example 2
- Input
- value = -48
- Output
- "-66"
Forty-eight is six sevens plus six ones, and the value is negative, so the label carries a leading minus.
Example 3
- Input
- value = 2401
- Output
- "10000"
2401 is seven multiplied by itself four times, so a single bead sits on the fifth rod from the right and every rod to its right is bare.
Constraints
- -10^7 <= value <= 10^7
The signature
The editor starts with this. It matches the parent problem's shape, so a solution that works here works on a standard judge unchanged.
def to_base_seven(value: int) -> str:public String toBaseSeven(int value)Checking your plan…
How this problem was checked
- Passed: Reference solution run against 12 test cases: 12 passed
- Passed: 3 worked examples confirmed by running the code
- Passed: 0 eight-word sequences shared with the parent problem's text
- Passed: Agrees with an independent brute-force solution on random inputs
- Passed: Test set shown to catch deliberately broken solutions
- Passed: Reviewed by a separate quality pass
- Passed: Function arity matches the parent problem's