about | help | code help+videos | done | prefs |
Write a method that returns the sum of the desired numbers from the 'nums' array. Only use numbers that are in the same position in the 'nums' array as a value of TRUE in the 'include' array. For example, if 'nums' is {7,9,15,20,33} and 'include' is {true,false,false,true,false}, you would return 27 because 7+20=27 (since 7 and 20 were in the same position as a 'true' value in 'include'). Note: If the entire 'include' array contains 'true', you will return the sum of ALL the numbers in 'nums'. If the entire 'include array contains 'false', you will return a zero. Preconditions: 'nums' can contain any integers and can be any length, including a length of zero. The length of 'nums' and the length of 'include' are the same. quiz2023_04_25_APP1SLHL_sumMask([], []) → 0 quiz2023_04_25_APP1SLHL_sumMask([53, 64, 80], [false, false, true]) → 80 quiz2023_04_25_APP1SLHL_sumMask([1, 2, 4, 8, 16, 32], [true, true, true, true, true, true]) → 63 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 230
Copyright Nick Parlante 2017 - privacy