Strange Counter
easy⏱ 15 mintypescriptchallengesproblem-solving-basic-
Runs in your browser
- Before starting
- Use a supported browser; initial dependencies may need internet.
- What it proves
- Run shows output; Test checks the authored cases, not every possible input.
- When finished
- Stop active runs when finished. No cloud infrastructure is provisioned by this exercise.
LEARN BY DOINGPut your intuition to work3 steps
Strange Counter
Use the lesson’s examples and explanation to check your idea.
Personal reflection. Nothing is sent to an AI service.Before you start
Browser lesson checks; review each requirement in Tests.
Catalog level: Easy · Estimated time: 15 min. Your prior experience can change the difficulty.
Sample case — your program reads stdin and prints to stdout.
Need a hand?
Start with a small test case. Hints progress from an idea to an explanation and, when requested, code.
Starter Strange counter: starts at 3 at time 1, decrements each second. When it reaches 1, resets to 2×previous start value. Find value at time t.
Pattern: Cycle 1: times 1-3, values 3,2,1. Cycle 2: times 4-9, values 6,5,4,3,2,1. Cycle 3: times 10-21, values 12,11,...,1. For time t, find which cycle and calculate value.
Example: t=4 → Cycle 2, position 1 → Value = 6 - (4-4) = 6
Input format
A single integer t.
Output format
The counter value at time t.
Constraints
1 ≤ t ≤ 10¹²