0
Raw Data & Analysis Objective
There is a company called Nerdina Entertainment (Nerdina for short). It's been decided to optimize the operation costs of 4 departments (see below). These have 4 types of specialists on staff. Each of the 4 types is characterized by three base properties: pay rate per month, gallons of coffee consumed per month and (just for the fun of it) the amount of code units (whatever this means) produced per month. Additionally, Nerdina employs a system of grades: each employee is assigned a grade that affects their monthly pay rate. Head of a department is a special status that alters all of the base stats. The summary of the available data is in the next sections.
The preliminary goal is to produce a report like this:
+--------------+-------+------------+--------------+------------+---------------+
| DEPARTMENT | STAFF | LABOR COST | COFFEE DRUNK | CODE UNITS | COST PER UNIT |
+--------------+-------+------------+--------------+------------+---------------+
| Analytics | 17 | 142,450 | 102 | 1,037 | 137.4 |
+--------------+-------+------------+--------------+------------+---------------+
| Training | 16 | 129,050 | 102 | 1,265 | 102 |
+--------------+-------+------------+--------------+------------+---------------+
| Development | 36 | 335,150 | 224 | 3,175 | 105.6 |
+--------------+-------+------------+--------------+------------+---------------+
| Sales | 28 | 218,450 | 131 | 1,045 | 209 |
+--------------+-------+------------+--------------+------------+---------------+
| TOTAL | 97 | 825,100 | 559 | 6,522 | 554 |
+--------------+-------+------------+--------------+------------+---------------+
| AVERAGE | 24.25 | 206,275 | 139.75 | 1,630.5 | 138.5 |
+--------------+-------+------------+--------------+------------+---------------+
Employee Types
Base stats. The figures for pay rate, coffee consumption and code units produced are per month.
+----------+---------+--------+------+
| TYPE | PAYRATE | COFFEE | CODE |
+----------+---------+--------+------+
| Manager | 7,000 | 5 | 75 |
+----------+---------+--------+------+
| Marketer | 6,600 | 4 | 5 |
+----------+---------+--------+------+
| Engineer | 8,300 | 8 | 200 |
+----------+---------+--------+------+
| Ananyst | 7,500 | 12 | 125 |
+----------+---------+--------+------+
NOTE: Heads of the departments earn and drink two times the base figure and don't produce any code.
Grades
+-------+-----------+
| GRADE | PAYRATE |
+-------+-----------+
| 1 | base |
+-------+-----------+
| 2 | base×1.25 |
+-------+-----------+
| 3 | base×1.5 |
+-------+-----------+
Staff
E.g. 6×man3 translates to 6 Managers of Grade 3
+--------------+-------------------------------------------------+
| DEPARTMENT | STAFF |
+--------------+-------------------------------------------------+
| Analytics | 9×man1, 3×man2, 2×ana3, 2×mar1 + chief 1×man2 |
+--------------+-------------------------------------------------+
| Training | 8×man1, 3×mar1, 2×ana1, 2×eng2 + chief 1×man2 |
+--------------+-------------------------------------------------+
| Development | 12×man2, 10×mar1, 8×eng2, 5×ana3 + chief 1×eng3 |
+--------------+-------------------------------------------------+
| Sales | 13×man1, 11×mar2, 3×mar3 + chief 1×man1 |
+--------------+-------------------------------------------------+
My Solution
This is a long one.
/**
* input.php
* the input format is determined by me based on the given data.
* I've been told by the peers that the current one is way too complicated and
* the array should look like this:
* $input = [
* ['Analytics', 9, Employee::MANAGER, 1],
* ['Training', 8, Employee::MANAGER, 1],
* ...
* ];
* Please advise on this point
*/
$input = [
'Analytics' => [
[9, Employee::MANAGER, 1],
[3, Employee::MANAGER, 2],
[2, Employee::ANALYST, 3],
[2, Employee::MARKETER, 1],
[1, Employee::MANAGER, 2, true]
],
'Training' => [
[...