6 kyu

Decoded String by the Numbers

94 of 347Omnilord

Description:

This is a simple string decoding algorithm. The idea is to take a string of characters and decode it into an array. Each character is a single element in the result unless a backslash followed by a positive number is encountered.

When a backslash followed by a positive number is found, the number indicates how many of the next characters are grouped together as one element.

Example:

"abc\5defghi\2jkl" => [ "a", "b", "c", "defgh", "i", "jk", "l" ]

If the number is larger than the count of remaining characters, treat it as reading the remaining characters.

If you are reading characters, and you find an escape inside a string, they should be tallied into the string:

"\5ab\3cde" => [ "ab\3c", "d", "e" ]
Algorithms

Stats:

CreatedOct 25, 2015
PublishedOct 25, 2015
Warriors Trained1142
Total Skips28
Total Code Submissions3723
Total Times Completed347
JavaScript Completions236
Haskell Completions21
Julia Completions9
Python Completions94
Total Stars36
% of votes with a positive feedback rating90% of 108
Total "Very Satisfied" Votes91
Total "Somewhat Satisfied" Votes13
Total "Not Satisfied" Votes4
Total Rank Assessments13
Average Assessed Rank
6 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • Omnilord Avatar
  • JohanWiltink Avatar
  • cliffstamp Avatar
  • stellartux Avatar
  • G_kuldeep Avatar
  • user8436785 Avatar
  • Wei-Ting Yang Avatar
  • saudiGuy Avatar
Ad