Once upon a time, a CodeWarrior, after reading a [discussion on what can be the plural](http://www.codewars.com/kata/plural/discuss/javascript), took a look at [this page](http://en.wikipedia.org/wiki/Grammatical_number#Types_of_number
) and discovered that **more than 1** "kind of plural" may exist. 

For example [Sursurunga Language](http://en.wikipedia.org/wiki/Sursurunga_language) distinguishes 5 types of numbers: **singular** (1 thing), **dual** (2 things), '**trial**' or '**lesser paucal**' (3 or 4), '**greater paucal**' (more than 4) and **plural** (many).

In this kata, you'll have to handle only four types of numbers:

- **singular**: 0 or 1 thing
- **dual**: 2 things
- **paucal**: 3 to 9 things
- **plural**: more than 9 things

To add some flavor the **number-marker** will not be added in same places:

- **singular**, no marker : `1 cat`
- **dual**, prefixed "`bu`" : `2 cats -> 2 bucat`
- **paucal**, suffixed "`zo`" : `4 cats -> 4 catzo`
- **plural**, "circumfixed `ga`" : `100 cats -> 100 gacatga`

As you all ("hawk eyes") have seen, the final `s` of english plural **disappears**.

( btw these markers, of course, have absolutely nothing to do with true sursurunga language, we're just talking about "**pig**-sursurunga" with **pig** as **pig** in "**pig latin**" )

## Your Job . . .
. . . if you accept it, will be to write a `sursurungal` function which get a `string` as argument and returns this string with words in it eventually converted to their "pig-sursurunga number type".

If a `number` ( *ie* 1 or more digit ) + a `space` + a `word` ( letters ) are found then the word should be converted.

**Each** group of `number+space+word` found in the string should be evaluated.

### Examples :

You may assume at least 1 `number+space+word` group will be provided.

**Beware** `s` of english plural should be removed, not ending `s` of some singular words ( *eg* "kiss" )

Good luck!

Difficulty: EASY
Starter code: def sursurungal(txt):
	

Solutions:
import re

def sursurungal(txt):
	txt = re.sub('\\b2\\s(\\S+)s', '2 bu\\1', txt)
	txt = re.sub('\\b([3-9])\\s(\\S+)s', '\\1 \\2zo', txt)
	return re.sub('(\\d+\\d)\\s(\\S+)s', '\\1 ga\\2ga', txt)


def sursurungal(txt):
	(sursurungal.pluralize, dual, paucal, plural) = (False, 'bu{}'.format, '{}zo'.format, 'ga{}ga'.format)

	def process_word(word):
		if sursurungal.pluralize != False:
			out = None
			if sursurungal.pluralize <= 1:
				out = word
			else:
				base = word
				if word[-1] == 's':
					base = word[0:-1]
				if sursurungal.pluralize == 2:
					out = dual(base)
				elif sursurungal.pluralize <= 9:
					out = paucal(base)
				else:
					out = plural(base)
			sursurungal.pluralize = False
			return out
		if word.isdigit():
			sursurungal.pluralize = int(word)
		return word
	return '\n'.join((' '.join((process_word(w) for w in l.split(' '))) for l in txt.split('\n')))


sursurungal = lambda s: __import__('re').sub('(\\d+) (\\w+)', lambda x: (lambda a, b: str(a) + ' ' + [[['bu' + b[:-1], b[:-1] + 'zo'][a > 2], 'ga' + b[:-1] + 'ga'][a > 9], b][a < 2])(int(x.group(1)), x.group(2)), s)


import re

def sursurungal(stg):
	return re.sub('(\\d+) (\\w+)', sur_grp, stg)

def sur_grp(m):
	(n, w) = (int(c) if c.isdigit() else c for c in m.groups())
	(p, s) = ('', w[-1]) if n < 2 else ('bu', '') if n == 2 else ('', 'zo') if n < 10 else ('ga', 'ga')
	return f'{n} {p}{w[:-1]}{s}'


import re

def s(m):
	(n, w) = m.groups()
	n = int(n)
	if n <= 1:
		return m.group()
	w = w[:-1]
	if n == 2:
		return '{} bu{}'.format(n, w)
	elif n <= 9:
		return '{} {}zo'.format(n, w)
	else:
		return '{} ga{}ga'.format(n, w)

def sursurungal(txt):
	return re.sub('(\\d+) (\\w+)', s, txt)


import re
PATTERN = re.compile('(\\d+) (\\w+)')

def repl(m):
	n = int(m.group(1))
	return '{} {}{}{}'.format(n, 'bu' if n == 2 else 'ga' if n > 9 else '', m.group(2) if n < 2 else m.group(2)[:-1], '' if n < 3 else 'zo' if n < 10 else 'ga')

def sursurungal(txt):
	return PATTERN.sub(repl, txt)


import re

def sursurungal(txt):
	return re.sub('([0-9]+) ([a-z]+)', lambda x: change(x.group(1), x.group(2)), txt)

def change(n, w):
	n = int(n)
	if n <= 1:
		return str(n) + ' ' + w
	elif n == 2:
		return str(n) + ' bu' + w.rstrip('s')
	elif n > 2 and n <= 9:
		return str(n) + ' ' + w.rstrip('s') + 'zo'
	else:
		return str(n) + ' ' + 'ga' + w.rstrip('s') + 'ga'


import re
from functools import partial

def convert(match):
	(n, s) = match.groups()
	n = int(n)
	if n == 0 or n == 1:
		return match.group()
	elif n == 2:
		return '2 bu{}'.format(s[:-1])
	elif 3 <= n <= 9:
		return '{} {}zo'.format(n, s[:-1])
	else:
		return '{} ga{}ga'.format(n, s[:-1])
sursurungal = partial(re.compile('(\\d+) (\\w+)').sub, convert)


import re

def sursurungal(txt):

	def change(t1):
		(a, b) = t1.split()
		if int(a) <= 1:
			return t1
		if int(a) == 2:
			return '{} bu{}'.format(a, b[:-1]) if b[-1] == 's' else '{} bu{}'.format(a, b)
		if int(a) <= 9:
			return '{} {}zo'.format(a, b[:-1]) if b[-1] == 's' else '{} {}zo'.format(a, b)
		else:
			return '{} ga{}ga'.format(a, b[:-1]) if b[-1] == 's' else '{} ga{}ga'.format(a, b)
	lst = re.findall('[0-9]+\\s[a-zA-Z]+[\n]?', txt)
	lst = [i[:-1] if i[-1:] == '\n' else i for i in lst]
	t = txt[:]
	for i in lst:
		t = re.sub(i, '~', t)
	lst2 = [change(i) for i in lst]
	for i in lst2:
		t = t.replace('~', i, 1)
	return t