Guest User

Untitled

a guest
May 24th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. import std.stream;
  2. import std.string;
  3. import std.stdio;
  4.  
  5. void main()
  6. {
  7. Stream file = new BufferedFile("c:/data/desktop/data.txt");
  8. scope (exit) file.close();
  9.  
  10. const max_chars = 'z' - 'A';
  11. char[1024][max_chars] res;
  12.  
  13. foreach (string line; file)
  14. {
  15. string[] digit_and_letters = split(line, ":");
  16. foreach (string letter; split(digit_and_letters[1]))
  17. {
  18. res[cast(uint)letter[0]-'A'][0] = digit_and_letters[0][0];
  19. }
  20. }
  21.  
  22. foreach (letter, chars; res)
  23. {
  24. if (chars[0])
  25. writefln("%s: %s", cast(char)(letter+'A'), chars[0]);
  26. }
  27. }
Add Comment
Please, Sign In to add comment