7 kyu

Digital cypher

568 of 8,310dcieslak

Description:

Introduction

Digital Cypher assigns to each letter of the alphabet unique number. For example:

 a  b  c  d  e  f  g  h  i  j  k  l  m
 1  2  3  4  5  6  7  8  9 10 11 12 13
 n  o  p  q  r  s  t  u  v  w  x  y  z
14 15 16 17 18 19 20 21 22 23 24 25 26

Instead of letters in encrypted word we write the corresponding number, eg. The word scout:

 s  c  o  u  t
19  3 15 21 20

Then we add to each obtained digit consecutive digits from the key. For example. In case of key equal to 1939 :

   s  c  o  u  t
  19  3 15 21 20
 + 1  9  3  9  1
 ---------------
  20 12 18 30 21
  
   m  a  s  t  e  r  p  i  e  c  e
  13  1 19 20  5 18 16  9  5  3  5
+  1  9  3  9  1  9  3  9  1  9  3
  --------------------------------
  14 10 22 29  6 27 19 18  6  12 8

Task

Write a function that accepts str string and key number and returns an array of integers representing encoded str.

Input / Output

The str input string consists of lowercase characters only.
The key input number is a positive integer.

Example

Encode("scout",1939);  ==>  [ 20, 12, 18, 30, 21]
Encode("masterpiece",1939);  ==>  [ 14, 10, 22, 29, 6, 27, 19, 18, 6, 12, 8]

Digital cypher series

Fundamentals
Ciphers
Cryptography

Stats:

CreatedMay 31, 2017
PublishedMay 31, 2017
Warriors Trained15306
Total Skips1155
Total Code Submissions30121
Total Times Completed8310
C# Completions568
JavaScript Completions2513
Ruby Completions292
Python Completions2980
Crystal Completions19
C++ Completions810
TypeScript Completions273
Rust Completions552
F# Completions50
C Completions205
NASM Completions8
Julia Completions14
Elixir Completions21
Java Completions230
Go Completions82
Total Stars266
% of votes with a positive feedback rating93% of 1323
Total "Very Satisfied" Votes1165
Total "Somewhat Satisfied" Votes143
Total "Not Satisfied" Votes15
Total Rank Assessments10
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • dcieslak Avatar
  • sv90 Avatar
  • GiacomoSorbi Avatar
  • imjasonmiller Avatar
  • kazk Avatar
  • adrian.eyre Avatar
  • Blind4Basics Avatar
  • Voile Avatar
  • wyrdforge Avatar
  • Maksio Avatar
  • celfrumos Avatar
  • hobovsky Avatar
  • uniapi Avatar
  • Lixfeld Avatar
  • stellartux Avatar
  • ejini战神 Avatar
  • QKiryu Avatar
  • NikCSharp Avatar
  • saudiGuy Avatar
Ad