Skip to content

Instantly share code, notes, and snippets.

@dnadlinger
Created October 16, 2010 19:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnadlinger/630201 to your computer and use it in GitHub Desktop.
Save dnadlinger/630201 to your computer and use it in GitHub Desktop.
import std.algorithm;
import std.stdio;
enum INPUT = "cqrb lryqna rb fjh, fjh qjamna cqjw axc cqracnnw. qnan, hxd wnena twxf qxf oja cx bqroc! xq kh cqn fjh, cqn jwbfna rb mnjmvjwblqnbc.";
void main() {
foreach ( offset; 0..25 ) {
writeln( map!( ( dchar c ) {
if ( c < 'a' ) return c;
if ( 'z' < c ) return c;
return cast( dchar )( ( ( ( c - 'a' ) + offset ) % 26 ) + 'a' );
} )( INPUT ) );
}
}
Program received signal SIGSEGV, Segmentation fault.
0x080499cd in ave.main.__dgliteral1 (this=0x0, c=99) at Documents/code/d/programlets/hacker.org/ave.d:11
11 return cast( dchar )( ( ( ( c - 'a' ) + offset ) % ( 'z' - 'a' + 1 ) ) + 'a' );
(gdb) bt
#0 0x080499cd in ave.main.__dgliteral1 (this=0x0, c=99) at Documents/code/d/programlets/hacker.org/ave.d:11
#1 0x08049ab1 in ave.main.Map!(__dgliteral1,string).Map.fillCache (this=0xffffda90) at /usr/include/d/std/algorithm.d:152
#2 0x08049ae2 in ave.main.Map!(__dgliteral1,string).Map.this (this=0xffffda90, input=578266287835185284) at /usr/include/d/std/algorithm.d:163
#3 0x0804984e in ave.main.map!(delegate dchar(dchar c)
{
if (cast(uint)c < 97u)
return c;
if (122u < cast(uint)c)
return c;
return cast(dchar)((cast(uint)c - 97u + cast(uint)offset) % 26u + 97u);
}
).map!(string).map (this=0xf7d49e40, __HID1=0xffffdad4, r=578266287835185284) at /usr/include/d/std/algorithm.d:108
#4 0x08049800 in D main () at Documents/code/d/programlets/hacker.org/ave.d:12
#5 0x0804fe56 in rt.dmain2.main() ()
#6 0x0804fdb0 in rt.dmain2.main() ()
#7 0x0804fe9a in rt.dmain2.main() ()
#8 0x0804fdb0 in rt.dmain2.main() ()
#9 0x0804fd56 in main ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment