id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > jan8_2016_HLfunnySum
prev  |  next  |  chance

Write a method that find the "funny sum" of the numbers in an array of exactly three positive integers. To find the "funny sum", you must first find the two largest numbers in the array. Add those two numbers together and replace the smallest number in the array with that sum. Repeat this process 'iteration' number of times and return the running total sum of all the pairs of numbers you added. For example, with the input array {7,2,5} and iterations=2, you would first add 7+5 to get 12. Keep 12 in your running total. Also replace the 2 (lowest number) with 12. Now add to your running total the result you get by finding the "funny sum" of {7,12,5} with iterations=1. So you add 7+12 to get 19. Add that to the 12 from before to get 31. Now find the "funny sum" of {7,12,19} with iterations=0. Since iterations=0, the "funny sum" is zero. Add zero to your running total which gives 31, which is the answer!


jan8_2016_HLfunnySum([7, 5, 2], 2) → 31
jan8_2016_HLfunnySum([1, 1, 7], 7) → 404
jan8_2016_HLfunnySum([7, 13, 2], 17) → 117179

...Save, Compile, Run (ctrl-enter)

public int jan8_2016_HLfunnySum(int[] nums, int iterations) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 310

Copyright Nick Parlante 2017 - privacy