5 kyu
Basic DeNico
481 of 1,477dcieslak
Description:
Task
Write a function deNico
/de_nico()
that accepts two parameters:
key
/$key
- string consists of unique letters and digitsmessage
/$message
- string with encoded message
and decodes the message
using the key
.
First create a numeric key basing on the provided key
by assigning each letter position in which it is located after setting the letters from key
in an alphabetical order.
For example, for the key crazy
we will get 23154
because of acryz
(sorted letters from the key).
Let's decode cseerntiofarmit on
using our crazy
key.
1 2 3 4 5
---------
c s e e r
n t i o f
a r m i t
o n
After using the key:
2 3 1 5 4
---------
s e c r e
t i n f o
r m a t i
o n
Notes
- The
message
is never shorter than thekey
. - Don't forget to remove trailing whitespace after decoding the message
Examples
deNico("crazy", "cseerntiofarmit on ") => "secretinformation"
deNico("abc", "abcd") => "abcd"
deNico("ba", "2143658709") => "1234567890"
deNico("key", "eky") => "key"
Check the test cases for more examples.
Related Kata
Fundamentals
Similar Kata:
Stats:
Created | Jul 19, 2017 |
Published | Jul 19, 2017 |
Warriors Trained | 4875 |
Total Skips | 1518 |
Total Code Submissions | 19787 |
Total Times Completed | 1477 |
JavaScript Completions | 481 |
Clojure Completions | 50 |
PHP Completions | 96 |
Python Completions | 610 |
Ruby Completions | 83 |
Crystal Completions | 14 |
C# Completions | 161 |
D Completions | 2 |
Rust Completions | 26 |
Total Stars | 144 |
% of votes with a positive feedback rating | 90% of 314 |
Total "Very Satisfied" Votes | 262 |
Total "Somewhat Satisfied" Votes | 41 |
Total "Not Satisfied" Votes | 11 |
Total Rank Assessments | 9 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 6 kyu |