Created
May 18, 2018 16:56
-
-
Save run-dlang/37edceffa1ef78963c2dbe7e7bd18a9b to your computer and use it in GitHub Desktop.
Code shared from run.dlang.io.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.stdio; | |
import std.array: split, join; | |
import std.algorithm.iteration: map; | |
import std.conv: to; | |
void main() | |
{ | |
string s = "635-34-7-3 751-16-2-1-1 224-16-4-1-1 625-11-3-1-1 231-16-4-2-1-1 212-7-3-2-1 603-19-5-2-2 624-27-6-3-1-1 663-28-1 600-27-3-2-1-1 102-12-4"; | |
string alph = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz{}"; | |
string res = s.split(' ').map!("a.split('-').map!(\"a.to!int\").fold!\"a + b * b\"(0)").map!((a) => [alph[a / 10000], alph[a % 10000 / 100], alph[a % 100]]).join(""); | |
writeln(res); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment