Beta

Guess the list pattern #5

Description:

Make a function called "pattern" that takes an array and an integer as input and returns the correct pattern as an array.

Four examples are shown below:

pattern([1, 2, 3, 4, 5, 6, 7, 8], 5) = [8, 3, 5, 2, 1, 6, 7, 4]

pattern([5, 12, 78, 23, 70, 45, 54], 15) = [23, 78, 54, 12, 70, 45, 5]

pattern([4, 7, 8, 2, 5, -1, -9, 3], 21) = [8, 3, 2, -1, -9, 5, 4, 7]

pattern([56, 21, 57, 4, 9, 0, -2, -6], 650) = [56, 0, 4, 57, -6, 21, -2, 9]

Hint: Random

Fundamentals
Lists
Data Structures
Arrays
Puzzles

Similar Kata:

More By Author:

Check out these other kata created by Beast

Stats:

CreatedSep 16, 2017
PublishedSep 16, 2017
Warriors Trained34
Total Skips0
Total Code Submissions4
Total Times Completed4
Ruby Completions4
Total Stars1
% of votes with a positive feedback rating33% of 3
Total "Very Satisfied" Votes1
Total "Somewhat Satisfied" Votes0
Total "Not Satisfied" Votes2
Total Rank Assessments3
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • Beast Avatar
Ad