mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-10 12:49:18 +00:00
new exercise
This commit is contained in:
parent
c1655da38f
commit
53e1053b5c
40
exercises/simulator/simulator.rs
Normal file
40
exercises/simulator/simulator.rs
Normal file
@ -0,0 +1,40 @@
|
||||
enum IPAddrKind {
|
||||
V4(u8, u8, u8, u8),
|
||||
V6(String),
|
||||
}
|
||||
|
||||
enum MacAddrKind {
|
||||
PHYSICAL(u64),
|
||||
VIRTUAL(u32),
|
||||
}
|
||||
|
||||
enum DeviceType {
|
||||
Desktop(IPAddrKind),
|
||||
Server(IPAddrKind),
|
||||
Switch(MacAddrKind),
|
||||
Router(MacAddrKind),
|
||||
}
|
||||
|
||||
struct Device {
|
||||
dtype: DeviceType,
|
||||
name: String,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// create a hashmap of pairs <Device, Vec[Device]>
|
||||
// "Desk1" [Desktop, V4] get connected to "Switch2", "Router1" [Router, Virtual]
|
||||
// "Desk2" [Desktop, V6] get connected to "Switch1", "Router1"
|
||||
// "Desk3" [Desktop, V4] get connected to "Server1" [Server, V4]
|
||||
// "Switch1" [Switch, PHYSICAL] get connected to "Router1"
|
||||
// "Switch2" [Switch, PHYSICAL] get connected to "Router2" [Router, Virtual]
|
||||
// "Server2" [Server, V6] get connected to "Router2"
|
||||
// Note: connections are suppose to be bidirectional, so write your methods in a way so that they would automatically handled
|
||||
|
||||
// Given a device name, return who are connected to it
|
||||
|
||||
// Given an IPAddrKind, return devices ip addresses who uses specific IPAddrKind
|
||||
|
||||
// Given Device1 and Device2, return true, if they are connected (including through other nodes)
|
||||
|
||||
// Given a device name, remove it from all of its connection
|
||||
}
|
||||
@ -24,7 +24,7 @@ fn main() {
|
||||
|
||||
// an instance of student (Michael Dodge, 1066, Bio, 2023)
|
||||
|
||||
// Note: shorthand possible for Rob and Michael; Adam and Helex
|
||||
// Note: shorthand possible for Rob and Michael; Adam and Nick
|
||||
|
||||
// call a function that will return list of students graduating by year
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user