Simple Fun #392: Count Robot
Description:
Task
Some robot components are stacked in the warehouse, such as heads
, arms
, bodies
and legs
. Your task is to determine AT LEAST how many robots these components belong to.
Preload
There are five kinds of robots in all. An object array ROBOTS
was preloaded, like this:
[
{type:"A",head:5,arm:20,body:10,leg:20},
{type:"B",head:8,arm:15,body:20,leg:20},
{type:"C",head:5,arm:10,body:15,leg:15},
{type:"D",head:6,arm:20,body:15,leg:10},
{type:"E",head:8,arm:15,body:15,leg:10}
]
You can use it directly without redefining it in your code.
Input
heads
, an integer array, each element represents the size of a robot's head.arms
, an integer array, each element represents the length of a robot's arm.bodies
, an integer array, each element represents the size of a robot's body.legs
, an integer array, each element represents the length of a robot's leg.
Output
An integer, the minimum possible number of robots.
Examples
For heads = [], arms = [], bodies = [] and legs = []
The output should be 0
.
There is no robot component in the warehouse.
For heads = [5], arms = [20,20], bodies = [10] and legs = [20,20]
The output should be 1
.
All of these component can belong to one robot(type A).
For heads = [5,8], arms = [20,15,20], bodies = [10,20] and legs = [20,20,20]
The output should be 2
.
these components can belong to a robot(type A):
heads [5], arms [20,20], bodies [10] legs [20,20]`
these components can belong to a robot(type B):
heads [8], arms [15], bodies [20] legs [20]`
See more examples in testcases.
Note
Each robot has 1 head, 2 arms, 1 body and 2 legs.
All inputs are valid.
Testcases or reference solution may contains bug, please test and feedback ;-)
Happy Coding
^_^
Similar Kata:
Stats:
Created | Feb 2, 2018 |
Published | Apr 27, 2018 |
Warriors Trained | 54 |
Total Skips | 3 |
Total Code Submissions | 126 |
Total Times Completed | 6 |
JavaScript Completions | 6 |
Total Stars | 2 |
% of votes with a positive feedback rating | 100% of 1 |
Total "Very Satisfied" Votes | 1 |
Total "Somewhat Satisfied" Votes | 0 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 1 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 5 kyu |