7 kyu

Simple Fun #175: Same Encryption

149 of 423myjinxin2015

Description:

Task

John loves encryption. He can encrypt any string by the following algorithm:

take the first and the last letters of the word;
replace the letters between them with their number;
replace this number with the sum of it digits 
          until a single digit is obtained.

Given two strings(s1 and s2), return true if their encryption is the same, or false otherwise.

Example

For s1 = "EbnhGfjklmjhgz" and s2 = "Eabcz", the result should be true.

"EbnhGfjklmjhgz" --> "E12z" --> "E3z"
"Eabcz" --> "E3z"
Their encryption is the same.

Input/Output

  • [input] string s1

The first string to be encrypted.

s1.length >= 3

  • [input] string s2

The second string to be encrypted.

s2.length >= 3

  • [output] a boolean value

true if encryption is the same, false otherwise.

Puzzles
Algorithms

Stats:

CreatedMar 1, 2017
PublishedMar 1, 2017
Warriors Trained795
Total Skips10
Total Code Submissions2238
Total Times Completed423
JavaScript Completions149
C# Completions59
Python Completions214
Ruby Completions37
Total Stars14
% of votes with a positive feedback rating89% of 139
Total "Very Satisfied" Votes112
Total "Somewhat Satisfied" Votes24
Total "Not Satisfied" Votes3
Total Rank Assessments5
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • smile67 Avatar
  • hobovsky Avatar
  • Just4FunCoder Avatar
  • saudiGuy Avatar
Ad