Beta

Cable Matching Problem

13 of 56Sarkanyolo

Description:

We are selling cables with various, non-standard sizes. The length of our cables and the orders from customers can only be positive integers. Find the cable pieces which will fulfill an order. The input is the order as integer and the list of lengths of our cables. The result should be the lengths of the needed cables, in descending order, in string, separated by comma. If there is no result, return "No result".

Example

cableMatching(200, {10,10,23,4,5,67,889,150,50}) # should return "150,50"
cableMatching(83, {10,10,23,4,5,67,889,150,50})  # should return "50,23,10"
cableMatching(12, {10,10,23,4,5,67,889,150,50})  # should return "No result"
cableMatching(200, {10,10,23,4,5,67,889,150,50}) should return "150,50"
cableMatching(83, {10,10,23,4,5,67,889,150,50}) should return "50,23,10"
cableMatching(12, {10,10,23,4,5,67,889,150,50}) should return "No result"
cableMatching(200, {10,10,23,4,5,67,889,150,50}) should return "150,50"
cableMatching(83, {10,10,23,4,5,67,889,150,50}) should return "50,23,10"
cableMatching(12, {10,10,23,4,5,67,889,150,50}) should return "No result"
(cable-calc 200 [10,10,23,4,5,67,889,150,50]) should return "150,50"
(cable-calc 83 [10,10,23,4,5,67,889,150,50]) should return "50,23,10"
(cable-calc 12 {10,10,23,4,5,67,889,150,50]) should return "No result"

Random Test

100 small tests with 10 <= cables.size <= 50, cables[i] <= 100, need <= 5000
10 large test with 10 <= cables.size <= 50, cables[i] <= 1000, need <= 10000
Algorithms

Stats:

CreatedMay 6, 2015
PublishedMay 6, 2015
Warriors Trained257
Total Skips74
Total Code Submissions596
Total Times Completed56
C# Completions13
Ruby Completions8
Python Completions30
Clojure Completions4
C++ Completions7
Total Stars11
% of votes with a positive feedback rating84% of 28
Total "Very Satisfied" Votes22
Total "Somewhat Satisfied" Votes3
Total "Not Satisfied" Votes3
Total Rank Assessments28
Average Assessed Rank
5 kyu
Highest Assessed Rank
3 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • Sarkanyolo Avatar
  • Abbe Avatar
  • Voile Avatar
  • hobovsky Avatar
  • Glyxerine Avatar
  • user8436785 Avatar
Ad