Appearance
Common patterns
A catalogue of rules that come up again and again. Find the goal, copy the expression, adjust the numbers. Each group below constrains a different aspect of a step.
Sign and value of the candidate
These constrain current_value — the number the player is about to play.
| Goal | Rule |
|---|---|
| Candidate must be positive | current_value > 0 |
| Candidate must be negative | current_value < 0 |
| Candidate must not be zero (already enforced, but explicit) | current_value != 0 |
| Only single-digit values allowed (1–9) | current_value IN (1, 2, 3, 4, 5, 6, 7, 8, 9) |
| Multiples of 5 are forbidden | current_value NOT IN (5, 10, 15, 20, 25, 30, 35, 40, 45, 50) |
Sum constraints
These constrain current_sum — the running total after the step — or prev_sum, the total before it.
| Goal | Rule |
|---|---|
| Sum must stay in range 0–99 | current_sum >= 0 AND current_sum <= 99 |
| Sum must not exceed 100 | current_sum <= 100 |
| The result must be a two-digit number | current_sum >= 10 AND current_sum <= 99 |
| Result must be a single-digit number (1–9) | current_sum >= 1 AND current_sum <= 9 |
| When sum exceeds 50, player must subtract | IF prev_sum > 50 THEN current_value < 0 |
Digit constraints
These reach inside a number with the digit functions and quantifiers.
| Goal | Rule |
|---|---|
| No zeros anywhere in the result's digits | ALL_DIGITS(current_sum) != 0 |
| No nines in the running total | ALL_DIGITS(prev_sum) != 9 |
| Restrict the result to digits 1–9 | ALL_DIGITS(current_sum) IN (1, 2, 3, 4, 5, 6, 7, 8, 9) |
| At least one digit of the candidate must be odd | SOME_DIGITS(current_value) IN (1, 3, 5, 7, 9) |
| Leading digit of the result must not be 9 | highest_digit(current_sum) != 9 |
Note that "every digit of the result must be distinct" is not directly expressible. The nearest workable substitute is restricting which digits are allowed at all, as in the third row above.
Step-position constraints
These use step_index, last_step_index and isLastStep to limit a rule to part of the exercise. All of them are IF…THEN rules, so they are skipped — not failed — on the steps they do not apply to.
| Goal | Rule |
|---|---|
| On the last step, land on exactly 50 | IF isLastStep THEN current_sum = 50 |
| First step must be a positive single digit | IF step_index = 0 THEN current_value IN (1, 2, 3, 4, 5, 6, 7, 8, 9) |
Place-based patterns
These use the derived variables place, formula and digitBefore, which describe which decimal place a step affects. They are the shape almost every real technique rule takes — see decimal places for how they are derived and when they are null.
| Goal | Rule |
|---|---|
| Add an 8 where the affected digit is 0 or 1 (any place) | current_value > 0 AND formula = 8 AND digitBefore IN (0, 1) |
| Subtract a 1 where the affected digit is not 0 or 5 | current_value < 0 AND formula = 1 AND digitBefore IN (1, 2, 3, 4, 6, 7, 8, 9) |
| Steps in the ones place only | place = 1 |
| Steps in the ones or tens place only | place IN (1, 10) |
| Operate only on ±10, ±20, ±30, ±50 | place = 10 AND formula IN (1, 2, 3, 5) |
| The candidate's tens digit must not be 9 (works for multi-place values too) | digitAt(current_value, 10) != 9 |
| Start from a clean ones digit | IF step_index = 0 THEN digitAt(prev_sum, 1) = 0 |
place, formula and digitBefore are null on multi-place values
A candidate like +47 touches two decimal places, so it has no single place or formula digit and all three variables are null. Positive tests against them (formula = 8) then reject the step; negative tests (formula != 9) quietly let it through. Use digitAt when the value may span several places. Full explanation.