7 kyu

Computer problem series #1: Fill the Hard Disk Drive

2,334 of 7,539albertogcmr

Description:

Your task is to determine how many files of the copy queue you will be able to save into your Hard Disk Drive. The files must be saved in the order they appear in the queue.

Zero size files can always be saved even HD full.

Input:

  • Array of file sizes (0 <= s <= 100)
  • Capacity of the HD (0 <= c <= 500)

Output:

  • Number of files that can be fully saved in the HD.

Examples:

save([4,4,4,3,3], 12) -> 3
# 4+4+4 <= 12, but 4+4+4+3 > 12
save([4,4,4,3,3], 11) -> 2
# 4+4 <= 11, but 4+4+4 > 11
save([12, 0, 0, 1], 12) -> 3
# 12+0+0 <= 12, but 12+0+0+1 > 12

Do not expect any negative or invalid inputs.

Lists
Arrays
Fundamentals

Stats:

CreatedAug 6, 2019
PublishedAug 8, 2019
Warriors Trained10932
Total Skips421
Total Code Submissions25087
Total Times Completed7539
Python Completions2334
Dart Completions341
CoffeeScript Completions13
PHP Completions273
TypeScript Completions184
C++ Completions1399
Ruby Completions272
C Completions216
JavaScript Completions2039
Haskell Completions87
Crystal Completions12
Julia Completions19
Elixir Completions65
Clojure Completions39
C# Completions371
Lua Completions67
COBOL Completions8
Java Completions192
Total Stars111
% of votes with a positive feedback rating93% of 949
Total "Very Satisfied" Votes832
Total "Somewhat Satisfied" Votes95
Total "Not Satisfied" Votes22
Total Rank Assessments31
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • albertogcmr Avatar
  • JohanWiltink Avatar
  • Blind4Basics Avatar
  • Madjosz Avatar
  • rowcased Avatar
  • FArekkusu Avatar
  • monadius Avatar
  • hobovsky Avatar
  • RobsonMoon Avatar
  • daniloxxv Avatar
  • user8436785 Avatar
  • agune15 Avatar
  • akar-0 Avatar
  • skaarj1989 Avatar
  • saudiGuy Avatar
Ad