-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlgorithms1.cs
More file actions
56 lines (51 loc) · 1.86 KB
/
Algorithms1.cs
File metadata and controls
56 lines (51 loc) · 1.86 KB
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
using System.Collections.Generic;
namespace AlgorithmAnalysis
{
public static class Algorithms1
{
/* Problem: Create a function that returns whether or not a given growth rate table is valid
* A table is valid if:
* It spans all weeks 1 through 53.
* Each row can have multiple weeks.
* All rows cover a time period moving forward
* No overlapping weeks appear in the table.
* The sum of all growth percentages in the table is equal to 1
* Example Valid Table:
* Row Index StartWeek EndWeek GrowthPct
* 1 1 4 .1
* 2 8 10 .17
* 3 5 7 .05
* 4 11 53 .68
* Other notes:
* The table does not have a guaranteed order
* You may use any .NET functions available to you or build additional structures if necessary
* The order of priorities for the solution should be: Correctness, Elegance/Style, and Performance.
*/
public static bool IsValid(GrowthTable t)
{
return true;
}
}
public class GrowthTable
{
public GrowthTable() { }
public List<GrowthTableRow> Rows {get; set;}
public GrowthTable (List<GrowthTableRow> rows)
{
Rows = rows;
}
}
public class GrowthTableRow
{
public GrowthTableRow() { }
public int StartWeek { get; set; }
public int EndWeek { get; set; }
public decimal GrowthPct { get; set; }
public GrowthTableRow (int start, int end, decimal growth)
{
StartWeek = start;
EndWeek = end;
GrowthPct = growth;
}
}
}