Algo
BAN USER- 0of 0 votes
Answerscalculate the summary statistics for a fleet of hosts. Each host has a fixed number of slots in which virtual instances can run. Each host can only run instances of a particular type, e.g. M1, M2, or M3. You are provided with the file “FleetState.txt” that contains the state of the fleet. Each line in the file represents a single host in the following comma-separated format:
- Algo in -
<HostID>,<InstanceType>,<N>,<Slot1State>,<Slot2State>,…,<SlotNState>
where
<HostID> is an integer
<InstanceType> can be M1, M2, or M3
<N> is the total number of slots on the machine
<SlotjState> is 0 if slot j is empty and 1 if it is occupied by an instance
Write a program that loads the state of the fleet from the input file “FleetState.txt” and then computes and writes out the following summary statistics to the output file “Statistics.txt”:
For each instance type, the count of empty hosts (all slots empty)
For each instance type, the count of full hosts (all slots filled)
For each instance type, the count of the most filled hosts (having the smallest number of empty slots > 0). Both the host count and number of empty slots must be written out in that order.
The output file must have the following format:
EMPTY: M1=<count>; M2=<count>; M3=<count>;
FULL: M1=<count>; M2=<count>; M3=<count>;
MOST FILLED: M1=<count>,<empty slots>; M2=<count>,<empty slots>; M3=<count>,<empty slots>;
What is the best way to solve this problem?| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
Answerscalculate the summary statistics for a fleet of hosts. Each host has a fixed number of slots in which virtual instances can run. Each host can only run instances of a particular type, e.g. M1, M2, or M3. You are provided with the file “FleetState.txt” that contains the state of the fleet. Each line in the file represents a single host in the following comma-separated format:
- Algo in -
<HostID>,<InstanceType>,<N>,<Slot1State>,<Slot2State>,…,<SlotNState>
where
<HostID> is an integer
<InstanceType> can be M1, M2, or M3
<N> is the total number of slots on the machine
<SlotjState> is 0 if slot j is empty and 1 if it is occupied by an instance
Write a program that loads the state of the fleet from the input file “FleetState.txt” and then computes and writes out the following summary statistics to the output file “Statistics.txt”:
For each instance type, the count of empty hosts (all slots empty)
For each instance type, the count of full hosts (all slots filled)
For each instance type, the count of the most filled hosts (having the smallest number of empty slots > 0). Both the host count and number of empty slots must be written out in that order.
The output file must have the following format:
EMPTY: M1=<count>; M2=<count>; M3=<count>;
FULL: M1=<count>; M2=<count>; M3=<count>;
MOST FILLED: M1=<count>,<empty slots>; M2=<count>,<empty slots>; M3=<count>,<empty slots>;
what is the best way to solve it?| Report Duplicate | Flag | PURGE
Amazon SDE1
Okay, that is a great answer.
- Algo November 02, 2014But what if I did the same thing in the previous answer(answer #2) which is count and hash, but with more code design like OOP & OOD Ex :(polymorphism, Single Stone ....) and with class just to valdiate all inputs, like it is areally id, it is avalid host type etc..., and the code was written in java with fantastic test class that generate all the normal and the extreme cases, on top of that I wrote some ideas on how to make the code faster by dividing the input file and use multi threading to read it and how to maintain every thing right since we are using threads now.
After that, do you reject me?, and sends me an email with new header that doesn't belong to the previous conversation and filled with wrong details, BTW I got the question on fri Oct 17 I solved it and send it back on sun Oct 19 and the recruiter said we will get to you in 2-3 days, until fri Oct 31 and after three follow up emails she answered with wrong details.