Amazon Online Assessment 2021 (OA) - Simple Cipher

As part of a Day 1 Challenge, your new team at Amazon has created a basic alphabet-based encryption and has asked members to test the cipher. A simple cipher is built on the alphabet wheel which has uppercase english letters['A'-'Z'] written on it:

Given an encrypted string consisting of english letters['A'-'Z'] only, decrypt the string by replacing each character with the kth character away on the wheel in counter clockwise direction. Counter-clockwise is the opposite direction is which the hands on a clock usually move.

Relevant Amazon OA Problems:


  • encryped: a string
  • k: an integer


the decrypted string


Example 1:


1encryped = VTAOG
2k = 2

Output: TRYME


Looking back 2 from 'V' returns 'T', from 'T' returns 'R' and so on. The decrypted string is 'TRYME'.

Try it yourself




Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.

Contrary to popular belief, Lorem Ipsum is not simply random text.

1  >>> a = [1, 2, 3]
2  >>> a[-1]
3  3

Get premium for instant access to all content and solutions