Beta

[Code Golf] The final countdown?

Description:

Introduction

10, 9, 8, 7, 6, 5, 4, 3, 2, 1, zero.

Increasing the step the countdown may be faster

10, 8, 6, 4, 2, zero.

But will it reach zero?

10, 7, 4, 1, 4294967294, 4294967291, ...

Using 32 bit unsigned integers, sometimes the countdown will eventually reach zero, and sometimes it will loop forever.

Task

Given the start value and the step, determine if the countdown will eventually reach 0.

Countdown algorithm:

n        startwhilen0n        nstep(mod  232)end\small n\;\;\leftarrow\;\;\hbox{start}\\ \hbox{while}\quad n \ne 0\\ \quad n\;\;\leftarrow\;\; n - \hbox{step}\quad (\hbox{mod}\;2^{32})\\ \hbox{end}
Input
  • start: start value, integer. Range: 0start<232\small0\le\hbox{start}\lt2^{32}
  • step: counter step, integer. Range: 0step<232\small0\le\hbox{step}\lt2^{32}
Output

True if the countdown will eventually reach 0, False otherwise.

Restrictions

The code should not be longer than 42 bytes.

For compatibility with future versions of python, the code should not contain numeric literals immediately followed by keywords.

1or 2   # no
1 or 2  # ok

Examples

start  step  | result   |
--------------------------------------------
  10     1   |  True    |   10,9,8,7,6,5,4,3,2,1,0.
  10     2   |  True    |   10,8,6,4,2,0.
  10     3   |  True    |   10,7,4,1,4294967294, ..., 5,2,4294967295, ..., 6,3,0.
   4     2   |  True    |   4,2,0.
   2     4   |  False   |   2,4294967294,4294967290, ..., 6,2,4294967294, ...
   7     2   |  False   |   7,5,3,1,4294967295, ..., 3,1,4294967295, ...
Fundamentals
Restricted

Similar Kata:

Stats:

CreatedMar 11, 2025
PublishedMar 12, 2025
Warriors Trained30
Total Skips0
Total Code Submissions146
Total Times Completed9
Python Completions9
Total Stars3
% of votes with a positive feedback rating100% of 4
Total "Very Satisfied" Votes4
Total "Somewhat Satisfied" Votes0
Total "Not Satisfied" Votes0
Total Rank Assessments4
Average Assessed Rank
5 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • mauro-1 Avatar
Ad