-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathINSTRUCTIONS.txt
136 lines (98 loc) · 3.41 KB
/
INSTRUCTIONS.txt
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
====================================================================
General Info
====================================================================
mvn exec:java or build-and-run.sh will compile and run the code
- Entrypoint is at Main.java; see other class files for detailed
definitions.
- See input/data.json for input
You can..
- add modify files as they please
- ask questions for clarifications
=======================
Data structure overview
=======================
Router
String name
List<EthernetPort> ports
String name
List<Vlan> vlans
int vlanId
int customer
====================================================================
Task 1
====================================================================
Generate and output a report for the provided input. The report
is separated into sections by customer.
Each section contains multiple rows, one each per combination of
router / port / vlan ids that customer-id was present at.
Report format:
=============
customer <customer-id>
- <router-name> : <port-name> : <vlan-id>
- <router-name> : <port-name> : <vlan-id>
- <router-name> : <port-name> : <vlan-id>
... (more router-port-vlanId entries)
... (more customer sections)
Sample input
=============
[
{ name: alpha
ports: [ {
name: ge-1/1/0
vlans: [
{ vlanId: 10, customer 1 }
{ vlanId: 15, customer 2 }
] } ] },
{ name: alpha
ports: [ {
name: ge-2/1/0
vlans: [
{ vlanId: 103, customer 1 }
{ vlanId: 25, customer 1 }
] } ] }]
Sample output
=============
customer 1:
- alpha : ge-1/1/0 : 10
- beta : ge-2/1/0 : 103
- beta : ge-2/1/0 : 25
customer 2:
- alpha : ge-1/1/0 : 15
====================================================================
Task 2
====================================================================
Modify the EthernetPort class so that:
- An EthernetPort instance MUST NOT have more than 512 Vlan entries.
- All Vlan instances belonging to it MUST have different vlanId fields
from each other.
Method signatures in EthernetPort should stay the same.
====================================================================
Task 3
====================================================================
For an EthernetPort instance we define two sets of integers representing
vlan-ids as follows:
- "in-use" vlan-ids is the set of all Vlan.vlanIds that are found in
the EthernetPort's vlans list,
- "free" vlan-ids is the set of all Vlan.vlanIds in the [0, 4095] range
that are NOT in the "in-use" set
Generate these sets in EthernetPort.inUseVlanIds() and .freeVlanIds().
Example:
in-use set: { 10, 12, 13, 20, 4095 }
free set: { 0, 1, ..., 9, 11, 14, ...., 4094 }
====================================================================
Task 4
====================================================================
We provide the IntRange class, which represents a continuous range
of integers defined by a floor and a ceiling. The floor and ceiling
values both do belong to the range.
A set of integers can be represented uniquely by a set of IntRanges, i.e:
input: { 1, 0, 2, 3, 4, 8, 10, 11, 12 }
output:
[
{ floor: 0, ceiling: 4 }
{ floor: 8, ceiling: 8 }
{ floor: 10, ceiling: 12 }
]
Implement this transformation in EthernetPort.freeVlanRanges()
For bonus points, tie everything together and use IntRange.humanReadable()
to print out the free vlan ranges per port for the data in input.json .