Skip to content

Instantly share code, notes, and snippets.

@DarkHole1
Forked from run-dlang/main.d
Created May 18, 2018 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DarkHole1/2bd2686b3857a80576bcf052db35486e to your computer and use it in GitHub Desktop.
Save DarkHole1/2bd2686b3857a80576bcf052db35486e to your computer and use it in GitHub Desktop.
Code shared from run.dlang.io.
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