-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathThe_Office_II_Boredom_Score.cs
62 lines (49 loc) · 2.04 KB
/
The_Office_II_Boredom_Score.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System.Collections.Generic;
using System.Linq;
namespace CodingChallenges;
[TestClass]
public class The_Office_II_Boredom_Score {
[TestMethod]
public void Test() {
/*
The Office II - Boredom Score
Each department has a different boredom assessment score, as follows:
accounts = 1
finance = 2
canteen = 10
regulation = 3
trading = 6
change = 6
IS = 8
retail = 5
cleaning = 4
pissing about = 25
Depending on the cumulative score of the team, return the appropriate sentiment:
<=80: 'kill me now'
< 100 & > 80: 'i can handle this'
100 or over: 'party time!!'
*/
Assert.AreEqual("kill me now", Boredom(new Dictionary<string, string>() { { "Tim", "accounts" }, { "Jim", "trading" }, { "Sandy", "regulation" }, { "Andy", "accounts" }, { "Katie", "finance" }, { "Laura", "IS" } }));
Assert.AreEqual("i can handle this", Boredom(new Dictionary<string, string>() { { "Jim", "pissing about" }, { "Tim", "regulation" }, { "Andy", "IS" }, { "Laura", "pissing about" }, { "Alex", "canteen" }, { "John", "canteen" } }));
Assert.AreEqual("party time!!", Boredom(new Dictionary<string, string>() { { "Andy", "pissing about" }, { "Tim", "accounts" }, { "Smith", "pissing about" }, { "Randy", "pissing about" }, { "Sandy", "IS" }, { "Laura", "pissing about" } }));
}
public static string Boredom(Dictionary<string, string> staff) =>
@"accounts = 1
finance = 2
canteen = 10
regulation = 3
trading = 6
change = 6
IS = 8
retail = 5
cleaning = 4
pissing about = 25".Split("\n")
.Select(s => s.Split("="))
.Select(s => (s.First().Trim(), int.Parse(s.Last())))
.Select(x => (staff.Count(d=> d.Value==x.Item1) * x.Item2))
.Sum() switch {
<= 80 => "kill me now",
< 100 => "i can handle this",
_ => "party time!!"
};
}