This issue is a discussion for contributors to collaborate in getting ready to be featured in 48in24. Please refer to this forum topic for more info.
We will be featuring All Your Base from Apr 30 onwards.
Staff jobs
These are things for Erik/Jeremy to do:
Check/update exercise in Problem Specifications
☐ Create + schedule video
Community jobs
For each track:
Implement All Your Base
Add approaches (and an approaches introduction!) for each idiomatic or interesting/educational approach.
Add video walkthroughs (record yourself solving and digging deeper into the exercise).
Highlight up to 16 different featured exercises (coming soon)
Existing Approaches
You can use these as the basis for approaches on your own tracks. Feel free to copy/paste/reuse/rewrite/etc as you see fit! Maybe ask ChatGPT to translate to your programming language.
My latest Go solution is a bit like C++ only much neater…
(it may take a moment of reflection to figure out how/why no digit of inputDigits ever ends up >= inputBase)
A long method chain in Raku. It uses array indexes on the digit elements followed by a sum to convert to base 10, then a recursive method call on the resulting base 10 number to convert to a list of digits for the expected base.
Sure! FYI I changed the when/default to if/else as they’re functionally identical here and the latter is likely more familiar to most.
If we take 42 as an example, and convert to base 2, we start with: if 42 ≥ 2. Since this is true, we get a list, with the first element of the list being 42 % 2 == 0. samewith is being used for self recursion, the method now being called on 42 div 2 == 21 (div being integer division). self is the object, i.e. the current integer we called the method on.
A slip is a list that flattens itself into an outer list. Without it, the recursion would give use nesting lists, e.g., with 42: (0,(1,(0,(1,(0,1))))).
If I were to rewrite it as a named subroutine, it could look like this:
sub foo ($x) {
if $x ≥ %bases<to> {
slip( $x % %bases<to>, foo($x div %bases<to>) );
}
else { $x }
}