Advertisement
Guest User

phone number problem

a guest
Jan 27th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.30 KB | None | 0 0
  1. import std.stdio, std.range, std.algorithm;
  2.  
  3. static immutable int[] KEYS = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 1, 2, 3, 4];
  4.  
  5. void main() {
  6.   stdin.byLine.dropOne.each!((i, line) => writefln("Case #%d: %d", i+1, line.map!(c => (c == ' ' ? 1 : KEYS[c - 'a'])).sum));
  7. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement