Look, how Cellular Automatons learn Algorithms, using Iterators and Iterables!
Did you know, that you may click on any mission tag and see all missions, where this tag is present! If you want to discover all CheckiO features, visit our tutorial. It's a longread, but it's worth it!
Today's new missions are dedicated to cellular automatons - a 2-dimensional fractal pattern that grows on a regular grid of cells. Maybe, the most famous example is a Conway's Game of Life. All challenges are adapted from the following video with Neil Sloane (founder of the On-Line Encyclopedia of Integer Sequences).
Toothpicks by freeman_lex - So, you have an infinite number of toothpicks of equal length and put them down on the table according to the rule. On the first step you just put one toothpick. It has two free ends, on which on the second step you respectively put two toothpicks perpendicularly. Now you have four free ends and put the next four toothpicks on the step three. If two toothpicks ends touch each other, the are not free, so after step three you again have four free end and so on. Your function must return the number of toothpicks, placed on the table, after step steps.
toothpicks(2) == 3 toothpicks(3) == 7 toothpicks(4) == 11
Ulam–Warburton Automaton by freeman_lex - This mission is dedicated to the Ulam–Warburton cellular automaton (UWCA) - a 2-dimensional fractal pattern that grows on a regular grid of cells consisting of squares. Starting with one square initially ON and all others OFF, successive iterations are generated by turning ON all squares that share precisely one edge with an ON square. So, your function must return the number of activated cells after given number of steps.
automaton(2) == 5 automaton(3) == 9 automaton(4) == 21
Ulam-Warburton Automaton Hex by freeman_lex - This mission is dedicated to hexagonal version the Ulam–Warburton cellular automaton (UWCA) - a 2-dimensional fractal pattern that grows on a regular grid of cells consisting of hexagon's. Starting with one hexagon initially ON and all others OFF, successive iterations are generated by turning ON all hexagons that share precisely one edge with an ON hexagon. So, your function must return the number of activated cells after given number of steps.
automaton(2) == 7 automaton(3) == 13 automaton(4) == 31
The offered articles are about popular and widely used algorithms, iterators and iterables and small recommendation, how to make code more readable. So, here they are!
Top 8 Algorithms Every Programmer Should Know - These algorithms are widely used in various applications and it’s important for a programmer to have a strong understanding of them.
Iterators and Iterables in Python: Run Efficient Iterations - Python’s iterators and iterables are two different but related tools that come in handy when you need to iterate over a data stream or container. Iterators and iterables are fundamental components of Python programming, and you’ll have to deal with them in almost all your programs.
Please put units in names - Using strong types, or putting units in names, is a small effort that can make a tremendous difference for code readability.
Why do you need other programming languages, if you already have Python?!🤷♂️
🙌 Thanks for your attention! Hope to meet you at CheckiO. We are really interested in your thoughts! Please, leave a comment below! ⤵
Welcome to CheckiO - games for coders where you can improve your codings skills.
The main idea behind these games is to give you the opportunity to learn by exchanging experience with the rest of the community. Every day we are trying to find interesting solutions for you to help you become a better coder.Join the Game