Appleby Contest '19 P2 - The Love Letter

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Plasmatic is sending a super special love letter, and because it is so special he doesn't want anyone (except his crush obviously) to see it.

To stop it from getting into the wrong hands, he has decided to encrypt the letter with a Caeser Cipher (don't worry his crush will get it).

Unfortunately, he isn't very skilled at programming and finds it difficult to apply the cipher to his letter. Can you help him do it?

Input Specification

The first line will contain the integer N, the length of the love letter.

The second line will contain the integer L, the shift he wants to apply.

The third line will contain the string S, the love letter itself. It will consist only of lowercase letters and spaces.

Output Specification

Output the love letter with the cipher applied.

Input Constraints

1 \le N \le 10^4

0 \le L \le 10^6

Sample Input
56
2
roses are red violets are blue sugar is sweet so are you
Sample Output
tqugu ctg tgf xkqngvu ctg dnwg uwict ku uyggv uq ctg aqw
Explanation

Every letter in the input has been shifted two places forward as specified in the input. Note that the letter y was looped back to a.


Comments


  • 0
    Mad_Milk  commented on Oct. 18, 2020, 11:30 a.m. edited

    Can someone gives some tips because I am getting everything wrong but the sample


    • 0
      Jonathan_Uy  commented on Oct. 19, 2020, 2:23 a.m.

      The shift L can be very large, so only subtracting 26 will not always put your letter in the range 1 to 26.


  • 0
    X_Ray  commented on Sept. 4, 2020, 7:22 p.m.

    For those getting IR, the love letter might end with a space.