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

 

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

On RingWorld they play a game involving arrays of numbers. Each player is given an array of numbers, a number of columns, and a target value. The contestants have to determine how many of the columns add up to the target value. For example, the array {1, 7, 7, 5, 2, 8, 6, 2, 10} with 3 columns and a target value of 15 would return two. The reason is that the three columns would be {1, 7, 7}, {5, 2, 8}, and {6, 2, 10}. Two of these columns add up to the target of 15, but the third one does not. So the goal is to return the number of columns that add up to the target. Note that the value for columns will always cause the same number of numbers in each column. For example, an array of length 3, 6, 9, 12, 15, etc could all have three columns, but an array of length 5 could not because that would cause one column to be shorter than the others. You may assume that the number of columns given will fit the length of the array.


ringWorldGame3([5, 12, 2, 12, 7], 5, 12) → 2
ringWorldGame3([5, 12, 2, 12, 7], 1, 12) → 0
ringWorldGame3([5, 12, 2, 12, 7], 1, 38) → 1

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

public int ringWorldGame3(int[] nums, int columns, int target) { }

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: 290

Copyright Nick Parlante 2017 - privacy