```
------------------------------------------------------------------
 we are programmed just to do anything you want us to
          w e  a r e  t h e  r o b o t s
                         

-----------------------------------------------------------[ d[(0)(0)]b]
```
Task.....
You will receieve an array of strings
such as 
```
a = ["We're functioning automatik d[(0)(0)]b","And we are dancing mechanik d[(0)(0)]b"]
```
Count the robots represented by d[(0)(0)]b

Unless of course the factory replaced a part on the robot.....
```
d[(0)(0)]b could look a little different depending on the supplier maybe like this 

d[(0)(0)]B or d[(0)(0}]B 
```
It's pretty random actually but with a global supply chain it's hard to control which part you get. Most of the parts are made global except the ones made in the factory which do not change.

```
d[(0)(0)]B 

In all robots the eyes do not change.

d[(0)(0)]B 

...0..0...
   ^  ^            
   |  | 

The rest of the body can change at random.

legs any in => abcdefghijklmnopqrstuvwxyz
...0..0... 
^        ^             
|        |

body any in => |};&#[]/><()*


...0..0... 
 ^^ ^^ ^^            
 || || ||           


```
There may be cases where a part is totally missing and of course a robot cannot function at all without a part or where the factory put a valid part in the wrong place and it's again not a valid robot.

return an array of strings with a count of each of the following tasks.

Case insensitve count of robots in string with "automatik" or "mechanik". Strings do not contain both "automatik and "mechanik". 

Return an array with the count like below 

```
a[0] = automatik count
a[1] = mechanik count

["1 robots functioning automatik", "1 robots dancing mechanik"]

```
to pay tribute...respect :)

https://en.wikipedia.org/wiki/The_Robots

Songwriters: HUETTER, RALF / SCHNEIDER-ESLEBEN, FLORIAN / BARTOS, KARL

Difficulty: EASY
Tags: String algorithms

Data structures

Ad-hoc
Skill types: Data structures

Starter code:
def count_robots(a):
	

Solutions:
import re
from collections import Counter
from itertools import chain
p = re.compile('{legs}{body}{body}0{body}{body}0{body}{body}{legs}'.format(legs='[a-z]', body='[[\\]|};&#/><()*]'))

def count_robots(a):
	cnt = Counter(chain.from_iterable((['d' if 'mechanik' in line else 'w' if 'automatik' in line else ''] * len(p.findall(line)) for line in map(str.lower, a))))
	return ['{w} robots functioning automatik'.format_map(cnt), '{d} robots dancing mechanik'.format_map(cnt)]


import re
LEGS = '[a-z]'
BODY = '[|};&#\\[\\]/><()*]'

def counRobots(strng, typeRobot):
	return str(sum((len(re.findall(LEGS + BODY + '{2}0' + BODY + '{2}0' + BODY + '{2}' + LEGS, substr)) for substr in map(str.lower, strng) if typeRobot in substr)))

def count_robots(a):
	return ['{} robots functioning automatik'.format(counRobots(a, 'automatik')), '{} robots dancing mechanik'.format(counRobots(a, 'mechanik'))]


import re
count_robots = lambda a, b='[|};&#\\[\\]/><()*]{2}', l='[a-zA-Z]': ['%d robots %s %s' % (sum((len(re.findall(l + b + '0' + b + '0' + b + l, s)) * (r in s.lower()) for s in a)), m, r) for (m, r) in [('functioning', 'automatik'), ('dancing', 'mechanik')]]


import re
LEGS = '[a-z]'
BODY = '[|};&#\\[\\]/><()*]'
counRobots = lambda a, type: str(sum((len(re.findall(LEGS + BODY + '{2}0' + BODY + '{2}0' + BODY + '{2}' + LEGS, s.lower())) for s in a if type in s.lower())))
count_robots = lambda a: [counRobots(a, 'automatik') + ' robots functioning automatik', counRobots(a, 'mechanik') + ' robots dancing mechanik']


import re
p = re.compile('[a-z][{0}][{0}]0[{0}][{0}]0[{0}][{0}][a-z]'.format(re.escape('|};&#[]/><()*')))

def count_robots(a):
	n = m = 0
	for x in map(str.lower, a):
		y = len(p.findall(x))
		if 'automatik' in x:
			n += y
		elif 'mechanik' in x:
			m += y
	return [f'{n} robots functioning automatik', f'{m} robots dancing mechanik']


import re

def count_robots(aaa):
	automatik = ''
	mechanik = ''
	for val in aaa:
		if val.lower().find('automatik') >= 0:
			automatik += val
		elif val.lower().find('mechanik') >= 0:
			mechanik += val
	aaa = '[\\|\\}\\;\\&\\#\\[\\]\\>\\<\\(\\)\\*\\/]'
	regex = '[a-zA-Z]' + aaa + '{2}0' + aaa + '{2}0' + aaa + '{2}[a-zA-Z]'
	automatik_list = list(re.finditer(regex, automatik))
	mechanik_list = list(re.finditer(regex, mechanik))
	automatik_count = len(automatik_list)
	mechanik_count = len(mechanik_list)
	retval_automatik = str(automatik_count) + ' ' + 'robots functioning automatik'
	retval_mechanik = str(mechanik_count) + ' ' + 'robots dancing mechanik'
	return [retval_automatik, retval_mechanik]


import re

def count_robots(a):
	d = {'automatik': 0, 'mechanik': 0}
	r = re.compile('[a-z](?:[|};&#\\[\\]\\/><()*]{2}0){2}[|};&#\\[\\]\\/><()*]{2}[a-z]')
	t = re.compile(f"\\b({'|'.join(d.keys())})\\b")
	for x in a:
		x = x.lower()
		(c, q) = (r.findall(x), t.search(x))
		if c and q:
			d[q.group()] += len(c)
	return [f'{v} robots {m} {k}' for ((k, v), m) in zip(d.items(), ('functioning', 'dancing'))]


import re

def count_robots(a):
	automatik = 0
	mechanik = 0
	for s in a:
		c = len(re.findall('[a-z][\\|\\};&#\\[\\]\\/><\\(\\)\\*]{2}0[\\|\\};&#\\[\\]\\/><\\(\\)\\*]{2}0[\\|\\};&#\\[\\]\\/><\\(\\)\\*]{2}[a-z]', s.lower()))
		if 'automatik' in s.lower():
			automatik += c
		elif 'mechanik' in s.lower():
			mechanik += c
	return ['{} robots functioning automatik'.format(automatik), '{} robots dancing mechanik'.format(mechanik)]


from re import compile
count = compile('[a-zA-Z][|};&#[\\]\\/><()*]{2}0[|};&#[\\]\\/><()*]{2}0[|};&#[\\]\\/><()*]{2}[a-zA-Z]').findall
auto = compile('(?i)automatik').search
mecha = compile('(?i)mechanik').search

def count_robots(a):
	x = y = 0
	for s in a:
		if auto(s):
			x += len(count(s))
		elif mecha(s):
			y += len(count(s))
	return [f'{x} robots functioning automatik', f'{y} robots dancing mechanik']


import re

def count_robots(li):
	(legs, body, find) = ('[a-zA-Z]', '[|};&#[\\]/><\\(\\)*]', [])
	a = m = 0
	for i in li:
		r = re.search('automatik|mechanik', i, re.I)
		if r:
			l = re.findall('{0}{1}{1}0{1}{1}0{1}{1}{0}'.format(legs, body), i)
			if re.search('mechanik', r.group(), re.I):
				m += len(l)
			else:
				a += len(l)
	return [f'{a} robots functioning automatik', f'{m} robots dancing mechanik']