about | help | code help+videos | done | prefs |
"RingWorld" is a book by Larry Niven about a civilization that builds a ring-shaped structure around their sun with a radius of one astonomical unit. The surface is shielded by black rectangles that "float" between the ring and the sun. Each of these rectangles has a desired position. Write a method that accepts an array of integers indicating the current position of each rectangle. The desired position is also an input parameter. Return an array of the changes needed for each rectangle to be in the correct position. For example, if a rectangle has a current position of 900 and all the rectangles have a desired position of 1000, the current rectangle needs to change by positive 100 to get to the correct position. Look at the test data for further examples. ringWorldPosition2([702, 400, 480, 200], 400) → [-302, 0, -80, 200] ringWorldPosition2([40, 70, 100, 100, 110], 100) → [60, 30, 0, 0, -10] ringWorldPosition2([], 500) → [] ...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: 290
Copyright Nick Parlante 2017 - privacy