DevOps legacy roasting!
Save the business from technological purgatory. 

Convert IT to DevOps, modernize application workloads, take it all to the Cloud…….

You will receive a string of workloads represented by words….some legacy and some modern mixed in with complaints from the business….your job is to burn the legacy in a disco inferno and count the value of each roasting and the number of complaints resolved. 

```
complaints (in this format, case-insensitive) -> "slow!", "expensive!", "manual!", "down!", "hostage!", "security!"

```

The value is based on real or perceived pain by the business and the expense of keeping it all running. 

Pull the values from the list below...

```
1970s Disco Fever Architecture………
Sort of like a design from Saturday night Fever….

            (  .      )
                )           (              )
                      .  '   .   '  .  '  .
             (    , )       (.   )  (   ',    )
              .' ) ( . )    ,  ( ,     )   ( .
           ). , ( .   (  ) ( , ')  .' (  ,    )
          (_,) . ), ) _) _,')  (, ) '. )  ,. (' )
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            Burn Baby Burn in a Disco Inferno

Legacy is identified by the following keywords:

1000 points - COBOL of any kind whatsoever
              keyword => "COBOL"
500 points  - non-object oriented architecture
              keyword => "nonobject"
500 points  - monolithic architecture
              keyword => "monolithic"
100 points  - fax system dependencies
              keyword => "fax"
100 points  - modem dependencies
              keyword => "modem"
50 points   - thick client dependencies
              keyword => "thickclient"
50 points   - tape drive dependencies
              keyword => "tape"
50 points   - floppy drive dependencies
              keyword => "floppy"
50 points   - workloads with DevOps Anti-patterns
              keyword => "oldschoolIT"

The count is based on case-insensitive words!

Return a string in the following format

->'Burn baby burn disco inferno 2400 points earned in this roasting and 2 complaints resolved!'

If there are no complaints and no legacy from above return

->'These guys are already DevOps and in the Cloud and the business is happy!'

```
If you have any doubt COBOL should be burned.. just look at
this quote from Dijkstra.

The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offense. Edsger Dijkstra

For more information on how to have a disco inferno

https://www.youtube.com/watch?v=A_sY2rjxq6M

Disclaimer - this should only be attempted by trained professionals and in accordance with local ordinances. EX: Disco may be outlawed in certain countries.

Difficulty: EASY
Tags: String algorithms

Fundamentals

Starter code:
def roast_legacy(workloads):
	

Solutions:
complaints = ['slow!', 'expensive!', 'manual!', 'down!', 'hostage!', 'security!']
legacy = {'cobol': 1000, 'nonobject': 500, 'monolithic': 500, 'fax': 100, 'modem': 100, 'thickclient': 50, 'tape': 50, 'floppy': 50, 'oldschoolit': 50}
import re

def roast_legacy(workloads):
	complaining = sum((1 for _ in re.finditer('|'.join(complaints), workloads.lower())))
	roasting = sum((legacy[m.group()] for m in re.finditer('|'.join(legacy), workloads.lower())))
	if roasting or complaining:
		return 'Burn baby burn disco inferno %d points earned in this roasting and %d complaints resolved!' % (roasting, complaining)
	else:
		return 'These guys are already DevOps and in the Cloud and the business is happy!'


complaints = ['slow!', 'expensive!', 'manual!', 'down!', 'hostage!', 'security!']
legacies = {'cobol': 1000, 'nonobject': 500, 'monolithic': 500, 'fax': 100, 'modem': 100, 'thickclient': 50, 'tape': 50, 'floppy': 50, 'oldschoolit': 50}

def roast_legacy(workloads):
	wl = workloads.lower()
	comps = sum([wl.count(s) for s in complaints])
	score = sum([wl.count(s) * p for (s, p) in legacies.items()])
	if (comps, score) == (0, 0):
		return 'These guys are already DevOps and in the Cloud and the business is happy!'
	return 'Burn baby burn disco inferno {} points earned in this roasting and {} complaints resolved!'.format(score, comps)


import re

def roast_legacy(s):
	cpn = len(re.findall('slow!|expensive!|manual!|down!|hostage!|security!', s, re.I))
	points = list(map(lambda x: x.lower(), re.findall('COBOL|nonobject|monolithic|fax|modem|thickclient|tape|floppy|oldschoolIT', s, re.I)))
	p = sum(([[[50, 100][i[:2] in 'fa mo'], 500]['no' in i], 1000][i[0] == 'c'] for i in points))
	return f'Burn baby burn disco inferno {p} points earned in this roasting and {cpn} complaints resolved!' if p or cpn else 'These guys are already DevOps and in the Cloud and the business is happy!'


complaints = ('slow!', 'expensive!', 'manual!', 'down!', 'hostage!', 'security!')
legacy = {'cobol': 1000, 'nonobject': 500, 'monolithic': 500, 'fax': 100, 'modem': 100, 'thickclient': 50, 'tape': 50, 'floppy': 50, 'oldschoolit': 50}

def roast_legacy(workloads):
	workloads = workloads.lower()
	resolution = sum((workloads.count(complaint) for complaint in complaints))
	score = sum((workloads.count(k) * v for (k, v) in list(legacy.items())))
	if resolution or score:
		return f'Burn baby burn disco inferno {score} points earned in this roasting and {resolution} complaints resolved!'
	return 'These guys are already DevOps and in the Cloud and the business is happy!'


PLAINTS = {'slow!', 'expensive!', 'manual!', 'down!', 'hostage!', 'security!'}
LEGACY = {'cobol': 1000, 'nonobject': 500, 'monolithic': 500, 'fax': 100, 'modem': 100, 'thickclient': 50, 'tape': 50, 'floppy': 50, 'oldschoolit': 50}

def roast_legacy(workloads):
	workloads = workloads.lower()
	p = sum((workloads.count(elt) for elt in PLAINTS))
	l = sum((workloads.count(elt) * LEGACY[elt] for elt in LEGACY))
	return 'These guys are already DevOps and in the Cloud and the business is happy!' if p + l == 0 else 'Burn baby burn disco inferno {} points earned in this roasting and {} complaints resolved!'.format(l, p)


import re
legcom = {'cobol': 1000, 'nonobject': 500, 'monolithic': 500, 'fax': 100, 'modem': 100, 'thickclient': 50, 'tape': 50, 'floppy': 50, 'oldschoolit': 50, 'slow!': 1j, 'expensive!': 1j, 'manual!': 1j, 'down!': 1j, 'hostage!': 1j, 'security!': 1j}
lcre = re.compile('|'.join(map(re.escape, list(legcom.keys()))), flags=re.I)

def roast_legacy(ws):
	s = sum((legcom[m.group().lower()] for m in lcre.finditer(ws)))
	return 'Burn baby burn disco inferno {} points earned in this roasting and {} complaints resolved!'.format(int(s.real), int(s.imag)) if s else 'These guys are already DevOps and in the Cloud and the business is happy!'


def roast_legacy(workloads):
	workloads = workloads.lower()
	complaints = sum((workloads.count(word) for word in ['slow!', 'expensive!', 'manual!', 'down!', 'hostage!', 'security!']))
	legacy = sum((workloads.count(keyword) * points for (keyword, points) in [('cobol', 1000), ('nonobject', 500), ('monolithic', 500), ('fax', 100), ('modem', 100), ('thickclient', 50), ('tape', 50), ('floppy', 50), ('oldschoolit', 50)]))
	return 'These guys are already DevOps and in the Cloud and the business is happy!' if legacy + complaints == 0 else 'Burn baby burn disco inferno %d points earned in this roasting and %d complaints resolved!' % (legacy, complaints)


legacy = {'cobol': 1000, 'nonobject': 500, 'monolithic': 500, 'fax': 100, 'modem': 100, 'thickclient': 50, 'tape': 50, 'floppy': 50, 'oldschoolit': 50}

def roast_legacy(workloads):
	comp = 0
	for w in ['slow!', 'expensive!', 'manual!', 'down!', 'hostage!', 'security!']:
		comp += workloads.lower().count(w)
	s = 0
	for (k, v) in legacy.items():
		s += workloads.lower().count(k) * v
	if comp == s == 0:
		return 'These guys are already DevOps and in the Cloud and the business is happy!'
	return 'Burn baby burn disco inferno {} points earned in this roasting and {} complaints resolved!'.format(s, comp)


def roast_legacy(workloads):
	points = {'cobol': 1000, 'nonobject': 500, 'monolithic': 500, 'fax': 100, 'modem': 100, 'thickclient': 50, 'tape': 50, 'floppy': 50, 'oldschoolit': 50}
	complaints = ['slow!', 'expensive!', 'manual!', 'down!', 'hostage!', 'security!']
	work_loads = workloads.lower()
	count = sum((work_loads.count(complaint) for complaint in complaints))
	legacy = sum((p * work_loads.count(k) for (k, p) in points.items()))
	if not count and (not legacy):
		return 'These guys are already DevOps and in the Cloud and the business is happy!'
	return 'Burn baby burn disco inferno {} points earned in this roasting and {} complaints resolved!'.format(legacy, count)