• # Display Regex As Diagram To Better Understand It And Count Domino Tiling Variants

Hello, checkiomates🐱‍👤!

At this digest we offer you to get familiar with regex visualizer and play with domino tiles, counting possible variants of their placing.

💡TIP

We allow users to assign hotkeys to "Run Code", "Check Solution" and stop code. You may see current combinations on buttons and change them in editor menu. If you want to discover all CheckiO features, visit our tutorial. It's a longread, but it's worth it!

🏁MISSION

In domino tiling problem, a room of contiguous unit squares is to be tessellated with blank 2-by-1 domino tiles, each such tile placed either vertically or horizontally.

In our version of domino tiling, the shape of the room consists of vertically stacked rows that all share the common straight line left wall. The array of rows contains the length of the individual rows, as measured in squares. You need to find and return a number of ways, how the given room may be tiled.

An interesting and useful video to dive into problem is present!

assert.strictEqual(dominoTile([2, 2]), 2);
assert.strictEqual(dominoTile([4, 3, 2, 1]), 0);
assert.strictEqual(dominoTile([5, 3, 4, 2]), 7);

📖ARTICLE

Might come in handy for learning regular expressions or if you have a complex regular expression and you don’t know what it does (not an uncommon situation..!)

For example, here is a diagram for a simple email tester /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}\$/:

👩‍💻CODE SHOT

This one is easy-peasy for you! How do you think, what the following code does?

function ??????(data: number[]): number {
const data1 = data.slice();
return data.sort().reduce((sum, el, i) => sum += (el!= data1[i]) ? 1 : 0, 0);
}