You are not logged in. Please login at www.codechef.com to post your questions!

×

CHO1 - Editorial

PROBLEM LINK:

Practice

Contest

Author: Manisha Reddy Thirumala Reddy

Tester: Manisha Reddy Thirumala Reddy

DIFFICULTY:

CAKEWALK.

PREREQUISITES:

Strings, Arrays.

PROBLEM:

Given a string s with n characters, we need to perform the following steps:

  • swap adjacent characters.
  • swap every alphabet with its ASCII reverse alphabet. Ex: For 'a' the reverse ASCII value is 'z'. we can do this by ASCII values (char)(122-'a'+97) = 'z'.

EXPLANATION:

As it is very easy question, the code snippet will guide you. for(int i=0; i<len; i = i+2){ temp = en[i+1]; en[i+1]=en[i]; en[i]=temp; }

AUTHOR'S AND TESTER'S SOLUTIONS:

Author's solution can be found here.

This question is marked "community wiki".

asked 04 Aug '18, 20:42

manisha_reddy's gravatar image

2★manisha_reddy
1
accept rate: 0%

edited 06 Aug '18, 17:55

admin's gravatar image

0★admin ♦♦
19.8k350498541


Nice chance to use a dictionary in Python.

alph = 'abcdefghijklmnopqrstuvwxyz'
cbk = dict()
for ch in range(26):
    cbk[alph[ch]] = alph[25-ch]

PS: the puzzle code for the practice version is ENCMSG (for searchers).

link

answered 05 Aug '18, 07:28

joffan's gravatar image

5★joffan
9488
accept rate: 13%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×847
×349

question asked: 04 Aug '18, 20:42

question was seen: 107 times

last updated: 06 Aug '18, 17:55