Another Fibonacci... yes but with other kinds of result.
The function is named `aroundFib` or `around_fib`, depending of the language.
Its parameter is `n` (positive integer).

First you have to calculate `f` the value of `fibonacci(n)` with `fibonacci(0) --> 0` and
`fibonacci(1) --> 1` (see: )

- 1) Find the count of each digit `ch` in `f` (`ch`: digit from 0 to 9), call this count `cnt` and find the maximum
value of `cnt`, call this maximum `maxcnt`. If there are ties, the digit `ch` to consider is the first one - in natural digit order - giving `maxcnt`.

- 2) Cut the value `f` into chunks of length at most `25`. The last chunk may be 25 long or less.

```
Example: for `n=100` you have only one chunk `354224848179261915075`
Example: for `n=180` f is `18547707689471986212190138521399707760` and you have two chunks 
`1854770768947198621219013` and `8521399707760`. First length here is 25 and second one is 13.
```

- At last return a string in the following format:
"Last chunk ...; Max is ... for digit ..."

where Max is `maxcnt` and digit the first `ch` (in 0..9) leading to `maxcnt`.


```
Example: for `n=100` -> "Last chunk 354224848179261915075; Max is 3 for digit 1" 
Example: for `n=180` -> "Last chunk 8521399707760; Max is 7 for digit 7"
Example: for `n=18000` -> "Last chunk 140258776000; Max is 409 for digit 1"
```
# Beware: 
`fib(18000)` has `3762` digits. Values of `n` are between `500` and `25000`.

# Note
Translators are welcome for all languages, except for Ruby since the Bash tests needing Ruby a Ruby reference solution is already there though not yet published.

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Starter code: def around_fib(n):
	

Solutions:
from collections import Counter
fib = [0, 1]

def around_fib(n):
	while len(fib) <= n:
		fib.append(fib[-1] + fib[-2])
	f = str(fib[n])
	val = max(((v, -int(k)) for (k, v) in Counter(f).items()))
	last = f[-(len(f) % 25 or 25):]
	return f'Last chunk {last}; Max is {val[0]} for digit {-val[1]}'


def around_fib(n):
	(a, b) = (0, 1)
	for _ in range(n):
		(a, b) = (b, a + b)
	f = str(a)
	start = (len(f) - 1) // 25 * 25
	(maxcnt, ch) = min(((-f.count(d), d) for d in '0123456789'))
	return 'Last chunk %s; Max is %d for digit %s' % (f[start:], -maxcnt, ch)


def around_fib(n):
	numbers_fibonacci = [0, 1]
	for i in range(n - 1):
		numbers_fibonacci.append(numbers_fibonacci[i] + numbers_fibonacci[i + 1])
	chunks = []
	max1 = str(max(numbers_fibonacci))
	max3 = ''.join(sorted(max1))
	count = [max3.count(i) for i in max3]
	max1_count = [max(count), max3[count.index(max(count))]]
	k = 0
	while 25 * k < len(max1):
		chunks.append(max1[25 * k:25 * (k + 1)])
		k += 1
	return 'Last chunk {}; Max is {} for digit {}'.format(chunks[-1], max1_count[0], max1_count[1])


def around_fib(n):
	fiblist = [0, 1]
	if n > 1:
		for i in range(2, n + 1):
			fiblist.append(fiblist[-1] + fiblist[-2])
	list1 = [int(i) for i in str(fiblist[-1])]
	list2 = []
	for i in range(10):
		count = list1.count(i)
		list2.append(count)
	for i in range(10):
		if list2[i] == max(list2):
			max1 = i
			max2 = max(list2)
			break
	list3 = []
	list4 = []
	x = len(list1) // 25
	if len(list1) % 25 != 0:
		for i in range(x * 25, len(list1)):
			list3.append(list1[i])
	else:
		i = -1
		while len(list3) < 25:
			list3.append(list1[i])
			i -= 1
		list3.reverse()
	return 'Last chunk ' + ''.join([str(i) for i in list3]) + '; Max is ' + str(max2) + ' for digit ' + str(max1)


def around_fib(n):
	f = str(fib(n))
	ch = ['9', '8', '7', '6', '5', '4', '3', '2', '1', '0']
	maxcnt = 0
	chunk = ''
	for digit in ch:
		cnt = f.count(digit)
		if cnt >= maxcnt:
			maxcnt = cnt
			maxdig = digit
	l = len(f) % 25
	if l == 0:
		start = len(f) - 25
	else:
		start = len(f) - l
	for i in range(start, len(f)):
		chunk += f[i]
	return 'Last chunk %s; Max is %d for digit %s' % (chunk, maxcnt, maxdig)

def fib(n):
	a = 0
	b = 1
	if n == 0:
		return a
	elif n == 1:
		return b
	else:
		for i in range(2, n + 1):
			c = a + b
			a = b
			b = c
		return b


import textwrap

def around_fib(n):
	(fib, cnt) = ([0, 1], [0] * 10)
	for i in range(n - 1):
		fib.append(fib[i] + fib[i + 1])
	cnt = [0] * 10
	for v in str(fib[-1]):
		cnt[int(v)] += 1
	chunk = textwrap.wrap(str(fib[-1]), 25)
	return 'Last chunk ' + chunk[-1] + '; Max is ' + str(max(cnt)) + ' for digit ' + str(cnt.index(max(cnt)))


from collections import Counter

def around_fib(n):
	(a, b) = (0, 1)
	for _ in range(n):
		(a, b) = (b, a + b)
	s = str(a)
	c = Counter(s)
	max_d = [0, None]
	for d in '0123456789':
		if c[d] > max_d[0]:
			max_d = [c[d], d]
	chunks = [s[i:i + 25] for i in range(0, len(s), 25)]
	return 'Last chunk {}; Max is {} for digit {}'.format(chunks[-1], max_d[0], max_d[1])


from collections import Counter
import re

def fib(x):
	(a, b) = (0, 1)
	for _ in range(x - 1):
		(a, b) = (b, a + b)
	return b

def around_fib(n):
	fo = fib(n)
	g = Counter(sorted(str(fo)))
	(dig, c) = g.most_common(1)[0]
	return 'Last chunk {}; Max is {} for digit {}'.format(re.findall('\\d{1,25}', str(fo))[-1], c, dig)