## 1) Sorting array of words that differ by one char

Given an array of equal-length strings, you'd like to know if it's possible to rearrange the order of the elements in such a way that each consecutive pair of strings differ by exactly one character. Return

if it's possible, and **true**

if not.**false**

**Note: You're only rearranging the order of the strings, not the order of the letters within the strings!**

Example

- For

, the output should be**inputArray = ["aba", "bbb", "bab"]**

.**solution(inputArray) = false** **["aba", "bbb", "bab"]****["aba", "bab", "bbb"]****["bbb", "aba", "bab"]****["bbb", "bab", "aba"]****["bab", "bbb", "aba"]****["bab", "aba", "bbb"]**- For

, the output should be**inputArray = ["ab", "bb", "aa"]**

.**solution(inputArray) = true**

There are 6 possible arrangements for these strings:

None of these satisfy the condition of consecutive strings differing by 1 character, so the answer is

.**false**

It's possible to arrange these strings in a way that each consecutive pair of strings differ by 1 character (eg:

or **"aa", "ab", "bb"**

), so return **"bb", "ab", "aa"**

.**true**

## 2) Find digit degree

Let's define *digit degree* of some positive integer as the number of times we need to replace this number with the sum of its digits until we get to a one digit number.

Given an integer, find its digit degree.

Example

- For

, the output should be**n = 5**

;**solution(n) = 0** - For

, the output should be**n = 100**

.**solution(n) = 1**

.**1 + 0 + 0 = 1** - For

, the output should be**n = 91**

.**solution(n) = 2**

->**9 + 1 = 10**

.**1 + 0 = 1**

## 3) Build a palindrome string

Given a string, find the shortest possible string which can be achieved by adding characters to the end of initial string to make it a palindrome.

Example

For

, the output should be**st = "abcdc"**

.**solution(st) = "abcdcba"**

## 4) Sudoku

*Sudoku* is a number-placement puzzle. The objective is to fill a

grid with digits so that each column, each row, and each of the nine **9 × 9**

sub-grids that compose the grid contains all of the digits from **3 × 3**

to **1**

.**9**

This algorithm should check if the given grid of numbers represents a correct solution to Sudoku.

Example

- For

```
grid = [[1, 3, 2, 5, 4, 6, 9, 8, 7],
[4, 6, 5, 8, 7, 9, 3, 2, 1],
[7, 9, 8, 2, 1, 3, 6, 5, 4],
[9, 2, 1, 4, 3, 5, 8, 7, 6],
[3, 5, 4, 7, 6, 8, 2, 1, 9],
[6, 8, 7, 1, 9, 2, 5, 4, 3],
[5, 7, 6, 9, 8, 1, 4, 3, 2],
[2, 4, 3, 6, 5, 7, 1, 9, 8],
[8, 1, 9, 3, 2, 4, 7, 6, 5]]
```

the output should be

;**solution(grid) = true**

- For

```
grid = [[8, 3, 6, 5, 3, 6, 7, 2, 9],
[4, 2, 5, 8, 7, 9, 3, 8, 1],
[7, 9, 1, 2, 1, 4, 6, 5, 4],
[9, 2, 1, 4, 3, 5, 8, 7, 6],
[3, 5, 4, 7, 6, 8, 2, 1, 9],
[6, 8, 7, 1, 9, 2, 5, 4, 3],
[5, 7, 6, 9, 8, 1, 4, 3, 2],
[2, 4, 3, 6, 5, 7, 1, 9, 8],
[8, 1, 9, 3, 2, 4, 7, 6, 5]]
```

the output should be

.**solution(grid) = false**

The output should be

: each of the nine **false**

sub-grids should contain all of the digits from **3 × 3**

to **1**

.These examples are represented on the image below.**9**

## 5) Diagonal with rectangulars

Imagine a white rectangular grid of

rows and **n**

columns divided into two parts by a diagonal line running from the upper left to the lower right corner. Now let's paint the grid in two colors according to the following rules:**m**

- A cell is painted black if it has at least one point in common with the diagonal;
- Otherwise, a cell is painted white.

Count the number of cells painted black.

Example

- For

and**n = 3**

, the output should be**m = 4**

.**solution(n, m) = 6** - For

and**n = 3**

, the output should be**m = 3**

.**solution(n, m) = 7**

There are

cells that have at least one common point with the diagonal and therefore are painted black.**6**

cells have at least one common point with the diagonal and are painted black.**7**

Добавляйтесь в друзья https://app.codesignal.com/profile/vlad360