6 kyu

Coding 3min : Tidy up the room

Description:

This is the simple version of Shortest Code series. If you need some challenges, please try the challenge version

Task:

Give you a room(n x n matrix), there are some sundries(any character except spaces). Our task is to put the sundries neatly placed in the upper left corner of the room(a small metrix)

Example:

example1:

room:[
["a"," "," "," "," "],
[" "," ","b"," "," "],
[" "," "," "," "," "],
[" ","c"," "," "," "],
[" "," ","d"," "," "]
]

There are 4 sundries in the room(a,b,c,d), so we put them in the 2x2 matrix, output should be:

[
["a","b"," "," "," "],
["c","d"," "," "," "],
[" "," "," "," "," "],
[" "," "," "," "," "],
[" "," "," "," "," "]
]

example2:

room:[
["a"," "," "," "," "],
[" "," ","b"," "," "],
[" "," "," "," "," "],
[" ","c"," "," "," "],
[" "," ","d","e"," "]
]

There are 5 sundries in the room(a,b,c,d,e), they cannot be put into the 2x2 matrix, so we put them in the 3x3 matrix, output should be:

[
["a","b","c"," "," "],
["d","e"," "," "," "],
[" "," "," "," "," "],
[" "," "," "," "," "],
[" "," "," "," "," "]
]

For more example see the testcases.

Series:

Puzzles
Games

Stats:

CreatedApr 5, 2016
PublishedApr 5, 2016
Warriors Trained270
Total Skips11
Total Code Submissions624
Total Times Completed129
JavaScript Completions129
Total Stars10
% of votes with a positive feedback rating93% of 60
Total "Very Satisfied" Votes53
Total "Somewhat Satisfied" Votes6
Total "Not Satisfied" Votes1
Total Rank Assessments7
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • smile67 Avatar
  • user9644768 Avatar
  • ejini战神 Avatar
Ad