6 kyu

Message Validator

338 of 4,202frkn2076

Description:

In this kata, you have an input string and you should check whether it is a valid message. To decide that, you need to split the string by the numbers, and then compare the numbers with the number of characters in the following substring.

For example "3hey5hello2hi" should be split into 3, hey, 5, hello, 2, hi and the function should return true, because "hey" is 3 characters, "hello" is 5, and "hi" is 2; as the numbers and the character counts match, the result is true.

Notes:

  • Messages are composed of only letters and digits
  • Numbers may have multiple digits: e.g. "4code13hellocodewars" is a valid message
  • Every number must match the number of character in the following substring, otherwise the message is invalid: e.g. "hello5" and "2hi2" are invalid
  • If the message is an empty string, you should return true
Algorithms

More By Author:

Check out these other kata created by frkn2076

Stats:

CreatedDec 2, 2020
PublishedDec 2, 2020
Warriors Trained8810
Total Skips208
Total Code Submissions29831
Total Times Completed4202
C# Completions338
JavaScript Completions1534
Python Completions1391
Ruby Completions101
Julia Completions15
Swift Completions115
Java Completions590
Rust Completions78
Haskell Completions46
Clojure Completions15
C Completions79
Lua Completions10
C++ Completions56
Total Stars169
% of votes with a positive feedback rating92% of 624
Total "Very Satisfied" Votes544
Total "Somewhat Satisfied" Votes64
Total "Not Satisfied" Votes16
Total Rank Assessments36
Average Assessed Rank
5 kyu
Highest Assessed Rank
1 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • frkn2076 Avatar
  • natan Avatar
  • anter69 Avatar
  • imjasonmiller Avatar
  • Madjosz Avatar
  • hobovsky Avatar
  • stellartux Avatar
  • albertogcmr Avatar
  • trashy_incel Avatar
  • pastre Avatar
  • waldmann42 Avatar
  • Just4FunCoder Avatar
  • lnx1_1 Avatar
  • PetitLu117 Avatar
  • SummerTheCoder Avatar
Ad