Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module bingbong; private:
- import std.range;
- import std.random;
- import std.stdio;
- import std.string;
- import std.conv;
- import std.uni;
- enum formats = [
- "*%s*",
- "**%s**",
- "***%s***",
- "~~%s~~",
- "__%s__",
- "__*%s*__",
- "__**%s**__",
- "__***%s***__",
- "`%s`",
- null,
- ];
- bool coinFlip()
- {
- return uniform!"[]"( 1, 100 ) <= 50;
- }
- ElementType!R sample( R )( R r ) if( isRandomAccessRange!R && hasLength!R )
- {
- auto index = uniform( 0, r.length );
- return r[index];
- }
- void main()
- {
- auto text = "?";
- auto count = 100;
- string output;
- auto i = 0u;
- foreach( c; text.cycle )
- {
- if( i++ >= count * text.length )
- break;
- auto fmt = formats.sample;
- auto chr = coinFlip ? c.to!( string ).toUpper() : c.to!string;
- output ~= ( fmt is null ? chr : fmt.format( chr ) ) ~ ' ';
- }
- output.writeln();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement