> When no more interesting kata can be resolved, I just choose to create the new kata, to solve their own, to enjoy the process  --myjinxin2015 said

# Description:

In this Kata, we have to try to create a mysterious pattern.

Given a positive integer `m`, you can generate a Fibonacci sequence with a length of `m`:
```
1 1 2 3 5 8 13 21 34 ...
```

Given a positive integer `n`, you need to execute `%` operation on each element of the Fibonacci sequence:
 
```
m = 9, n = 3
Fibonacci sequence: 1 1 2 3 5 8 13 21 34
               ---> 1%3 1%3 2%3 3%3 5%3 8%3 13%3 21%3 34%3
               --->  1   1   2   0   2   2    1    0    1
```
Finally, make `n` rows string to show the pattern:

```
112022101
|||||||||
   o   o
oo    o o
  o oo
```

Please note:
* Each row is separated by `"\n"`;
* You should trim the end of each row;
* If there are some empty rows at the start or end of string, you should trim them too. But, if the empty row is in the middle(see the last example), you should not trim it.



# Examples:


For m = 5, n = 5, the output should be:
```
    o 
oo
  o
   o
```
For m = 12, n = 4, the output should be:
```
     o     o
oo  o oo  o
  o     o
   o     o
```
For m = 1, n = 1, the output should be:`"o"`

For: m = 6, n = 15, the output should be:
```
oo
  o
   o

    o


     o
```

Difficulty: EASY
Tags: String algorithms

Ad-hoc

Starter code:
def mysterious_pattern(m, n):
	

Solutions:
def mysterious_pattern(m, n):
	rows = [[' '] * m for _ in range(n)]
	(a, b) = (1, 1)
	for i in range(m):
		rows[a % n][i] = 'o'
		(a, b) = (b, a + b)
	rows = [''.join(r).rstrip() for r in rows]
	return '\n'.join(rows).strip('\n')


def genFib():
	(a, b) = (1, 0)
	while 1:
		yield a
		(a, b) = (a + b, a)
(FIB, fib) = ([], genFib())

def getFib(m):
	while len(FIB) < m:
		FIB.append(next(fib))
	return FIB[:m]

def mysterious_pattern(m, n):
	lst = [v % n for v in getFib(m)]
	arr = [[' '] * m for _ in range(n)]
	for (y, x) in enumerate(lst):
		arr[x][y] = 'o'
	return '\n'.join((''.join(row).rstrip() for row in arr)).strip('\n')


def mysterious_pattern(size, n, fib=1, tmp=0):
	rows = [[' '] * size for _ in range(n)]
	for idx in range(size):
		rows[fib % n][idx] = 'o'
		(tmp, fib) = (fib, fib + tmp)
	return '\n'.join((''.join(row).rstrip() for row in rows)).strip('\n')


def mysterious_pattern(m, n):
	(lines, a, b) = ([[' '] * m for _ in range(n)], 1, 1)
	for i in range(m):
		(lines[a % n][i], a, b) = ('o', b, a + b)
	return '\n'.join([''.join(l).rstrip() for l in lines]).strip('\n')


def mysterious_pattern(m, n):
	exp = [[(' ', 'o')[j == e % n] for e in fib(m)] for j in range(n)]
	return '\n'.join((''.join(e).rstrip() for e in exp)).strip('\n')

def fib(n):
	ret = [1, 1]
	for i in range(n):
		ret.append(ret[-1] + ret[-2])
	return ret[:-2]


fib = [1, 1]
for i in range(39):
	fib.append(fib[i] + fib[i + 1])

def mysterious_pattern(l, m):
	lines = [['o' if n % m == i else ' ' for n in fib[:l]] for i in range(m)]
	return '\n'.join((''.join(line).rstrip() for line in lines)).strip('\n')


from itertools import islice

def fib():
	(a, b) = (1, 1)
	while True:
		yield a
		(a, b) = (b, a + b)

def mysterious_pattern(m, n):
	board = [[' '] * m for _ in range(n)]
	for (i, x) in enumerate(islice(fib(), m)):
		board[x % n][i] = 'o'
	return '\n'.join((''.join(row).rstrip() for row in board)).strip('\n')


FIBONACCI = [1, 1]

def mysterious_pattern(m, n):
	while len(FIBONACCI) < m:
		FIBONACCI.append(FIBONACCI[-2] + FIBONACCI[-1])
	pattern = [[' '] * m for _ in range(n)]
	for i in range(m):
		pattern[FIBONACCI[i] % n][i] = 'o'
	return '\n'.join((''.join(row).rstrip() for row in pattern)).strip('\n')


def mysterious_pattern(m, n):
	fib = [1, 1]
	for i in range(m - 2):
		fib.append(fib[-1] + fib[-2])
	ret = [['o' if fib[x] % n == y else ' ' for x in range(m)] for y in range(n)]
	return '\n'.join((''.join(row).rstrip() for row in ret)).strip('\n')


def mysterious_pattern(m, n):
	if m == 1:
		return 'o'
	seq = [1, 1]
	for i in range(m - 2):
		seq.append(seq[-2] + seq[-1])
	for (i, v) in enumerate(seq):
		seq[i] = v % n
	pattern = []
	for i in range(max(seq) + 1):
		pattern.append([])
	for x in seq:
		for (j, row) in enumerate(pattern):
			if x == j:
				pattern[j].append('o')
			else:
				pattern[j].append(' ')
	for i in range(min(seq)):
		del pattern[i]
	res = ''
	for row in pattern:
		res += ''.join(row).rstrip() + '\n'
	return res[:-1]