5 kyu

myjinxin katas #001 : Rotate, Remove, Return

166 of 331myjinxin2015

Description:

Description

Give you a 2D array(n * n, n is an odd number more than 1), rotate it, remove elements, return the last surviving number.

arr=[
[3,5,8,4,2],
[1,9,2,3,8],
[4,6,7,2,2],
[7,5,5,5,5],
[6,5,3,8,1]
]

Rotate it in a counter clockwise direction:

2,8,2,5,1
4,3,2,5,8
8,2,7,5,3
5,9,6,5,5
3,1,4,7,6

Remove 1 maximum value and 1 minimum value of each row(remember, only remove 1 maximum value and 1 minimum value, not all of same, remove from left side)

2,2,5
4,3,5
7,5,3
6,5,5
3,4,6

Rotate again:

5,5,3,5,6
2,3,5,5,4
2,4,7,6,3

Remove again:

5,5,5
3,5,4
4,6,3

Rotate again:

5,4,3
5,5,6
5,3,4

Remove again:

4
5
4

Rotate again:

4,5,4

Remove again:

4

Return the last surviving number 4

Task

Complete function rotateAndRemove that accepts 1 argument arr. Returns the result in accordance with the rules above.

Puzzles
Algorithms
Arrays

Stats:

CreatedSep 15, 2016
PublishedSep 15, 2016
Warriors Trained762
Total Skips36
Total Code Submissions1823
Total Times Completed331
JavaScript Completions166
Python Completions166
Rust Completions7
Go Completions9
Total Stars30
% of votes with a positive feedback rating93% of 91
Total "Very Satisfied" Votes80
Total "Somewhat Satisfied" Votes9
Total "Not Satisfied" Votes2
Total Rank Assessments4
Average Assessed Rank
5 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • smile67 Avatar
  • user9644768 Avatar
  • akar-0 Avatar
  • dfhwze Avatar
Ad