6 kyu

Computer problem series #7: Indentation mix

Description:

Autoformat code level 2

You have received a code file, it looks like that it has been written by different people with different code editors. There is an unwanted mix of spaces " " and tabs "\t" where there should only be spaces.

Task:

The function must correct errors in the indentation of each line of text. Adjust the spaces at the beginning to the closest level of intentation. In the event of a tie, opt for the larger.

One tab "\t" is equivalent to as many spaces " " as it takes to reach the next tabstop. Indentation levels must have a multiple of 4 spaces.

Example:

In the examples spaces are represented with "·", tabs with \t

·\t# comment
var·int·=·2;
if·(true){
···console.log(int);
··}
·console.log('end');

Should be:

····# comment
var·int·=·2;
if·(true){
····console.log(int);
····}
console.log('end');
Strings
Algorithms

Stats:

CreatedOct 23, 2019
PublishedMay 7, 2020
Warriors Trained268
Total Skips68
Total Code Submissions425
Total Times Completed45
Python Completions45
Total Stars3
% of votes with a positive feedback rating87% of 19
Total "Very Satisfied" Votes15
Total "Somewhat Satisfied" Votes3
Total "Not Satisfied" Votes1
Total Rank Assessments9
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • albertogcmr Avatar
  • fenring76 Avatar
Ad