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

 

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

Each demon has a rank and a position. Their position is indicated by their index in an array. Their rank is indicated by the value in that position in the array. For example, the array {6,2,5} indicated that there is a demon in position 0 with a rank of 6, a demon in position 1 with a rank of 2, and a demon in position 2 with a rank of 5. Write a method that "cycles down" and "demotes" all of the demons. Cycling down involves moving every demon down one in position, with the demon previously in position 0 going to the highest position. At the same time the demons are also getting demoted. That means their value goes down by one. So after cycling down and demoting, the array {6,2,5} becomes {1,4,5}. (The reason is that the 2 gets demoted to a 1 and cycled down to position 0. The 5 gets demoted to a 4 and cycled down to position 1. The 6 gets demoted to a 5 and moved to the highest position.) Look at the test data for examples!


oct31_2019_APP1SLHL_demonDemoted([5, 7, 9]) → [6, 8, 4]
oct31_2019_APP1SLHL_demonDemoted([4]) → [3]
oct31_2019_APP1SLHL_demonDemoted([]) → []

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

public int[] oct31_2019_APP1SLHL_demonDemoted(int[] rank) { }

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