Submission #2244846


Source Code Expand

import std.stdio,
       std.string,
       std.conv;

void main() {
  string s = readln.chomp;
  int K = readln.chomp.to!(int);
  s.to!(char[]);
  char[] ans;
  foreach (char c; s[0..(s.length - 1)]) {
    if (c == 'a') {
      continue;
    }
    if ('z' - c + 1 <= K) {
      ans ~= 'a';
      K -= 'z' - c + 1;
    }
    else {
      ans ~= c;
    }
  }
  char c = s[s.length - 1];
  for (int i = 0; i < K % 26; i++) {
    if (c == 'z') {
      c = 'a';
    }
    else {
      c = (c + 1).to!(char);
    }
  }
  writeln(ans ~ c);
}

Submission Info

Submission Time
Task C - Next Letter
User nemu_sou
Language D (DMD64 v2.070.1)
Score 0
Code Size 568 Byte
Status CE

Compile Error

./Main.d(8): Warning: calling std.conv.to!(char[]).to!(string).to without side effects discards return value of type char[], prepend a cast(void) if intentional