Skip to content

Instantly share code, notes, and snippets.

@JonathanMatthey
Last active August 29, 2015 14:01
Show Gist options
  • Save JonathanMatthey/d65a400ad9ea2c86b9ce to your computer and use it in GitHub Desktop.
Save JonathanMatthey/d65a400ad9ea2c86b9ce to your computer and use it in GitHub Desktop.

Revisions

  1. JonathanMatthey revised this gist May 28, 2014. 1 changed file with 33 additions and 40 deletions.
    73 changes: 33 additions & 40 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,93 +1,86 @@
    // 0RW3LL WAS ERE
    //
    // UNINSTALL BLOOMBERG - USE REUTERS...
    // BLOOMBERG SCANDAL - PLEASE READ
    // http://www.huffingtonpost.com/tag/bloomberg-terminal-scandal/
    //
    //
    // //Problem : The Verbal Literal
    //Problem : The Verbal Literal
    //Language : Javascript
    //Compiled Using : V8
    //Version : Node 0.10.25
    //Input for your program will be provided from STDIN
    //Print out all output from your program to STDOUT
    //0rw3ll

    //0rw3ll
    var readline = require('readline'),
    //0rw3ll
    rl = readline.createInterface({
    //0rw3ll
    //0rw3ll
    input: process.stdin,
    //0rw3ll
    //0rw3ll
    output: process.stdout,
    //0rw3ll
    //0rw3ll
    terminal: false
    //0rw3ll
    //0rw3ll
    });
    //0rw3ll
    //0rw3ll

    //0rw3ll
    rl.on('line', function (command)
    //0rw3ll
    //0rw3ll
    {
    //0rw3ll
    //0rw3ll
    command = command.split(/\W/).map(function (i) { return parseInt(i); });
    //0rw3ll
    //0rw3ll

    //0rw3ll
    var line = String(command[0]),
    //0rw3ll
    //0rw3ll
    iter = command[1];
    //0rw3ll
    //0rw3ll

    //0rw3ll
    for (var i = 0; i < iter; i ++) {
    //0rw3ll
    //0rw3ll
    var next1 = [],
    //0rw3ll
    //0rw3ll
    c = line[0],
    //0rw3ll
    //0rw3ll
    n = 0;
    //0rw3ll
    //0rw3ll

    //0rw3ll
    for (var j = 0; j < line.length; j++) {
    //0rw3ll
    //0rw3ll
    if (line[j] === c) {
    //0rw3ll
    //0rw3ll
    n++;
    //0rw3ll
    //0rw3ll
    } else {
    //0rw3ll
    //0rw3ll
    next1.push(n);
    //0rw3ll
    //0rw3ll
    next1.push(c);
    //0rw3ll
    //0rw3ll

    //0rw3ll
    c = line[j];
    //0rw3ll
    //0rw3ll
    n = 1;
    //0rw3ll
    //0rw3ll
    }
    //0rw3ll
    //0rw3ll
    }
    //0rw3ll
    //0rw3ll
    next1.push(n);
    //0rw3ll
    //0rw3ll
    next1.push(c);
    //0rw3ll
    //0rw3ll

    //0rw3ll
    line = next1.join('');
    //0rw3ll
    //0rw3ll
    }
    //0rw3ll
    //0rw3ll

    //0rw3ll
    console.log(line.length);
    //0rw3ll
    //0rw3ll
    process.exit(0);
    //0rw3ll
    });
    //0rw3ll
    //0rw3ll
    });
  2. JonathanMatthey created this gist May 28, 2014.
    93 changes: 93 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,93 @@
    // 0RW3LL WAS ERE
    //
    // UNINSTALL BLOOMBERG - USE REUTERS...
    // BLOOMBERG SCANDAL - PLEASE READ
    // http://www.huffingtonpost.com/tag/bloomberg-terminal-scandal/
    //
    //
    // //Problem : The Verbal Literal
    //Language : Javascript
    //Compiled Using : V8
    //Version : Node 0.10.25
    //Input for your program will be provided from STDIN
    //Print out all output from your program to STDOUT

    //0rw3ll
    var readline = require('readline'),
    //0rw3ll
    rl = readline.createInterface({
    //0rw3ll
    input: process.stdin,
    //0rw3ll
    output: process.stdout,
    //0rw3ll
    terminal: false
    //0rw3ll
    });
    //0rw3ll

    //0rw3ll
    rl.on('line', function (command)
    //0rw3ll
    {
    //0rw3ll
    command = command.split(/\W/).map(function (i) { return parseInt(i); });
    //0rw3ll

    //0rw3ll
    var line = String(command[0]),
    //0rw3ll
    iter = command[1];
    //0rw3ll

    //0rw3ll
    for (var i = 0; i < iter; i ++) {
    //0rw3ll
    var next1 = [],
    //0rw3ll
    c = line[0],
    //0rw3ll
    n = 0;
    //0rw3ll

    //0rw3ll
    for (var j = 0; j < line.length; j++) {
    //0rw3ll
    if (line[j] === c) {
    //0rw3ll
    n++;
    //0rw3ll
    } else {
    //0rw3ll
    next1.push(n);
    //0rw3ll
    next1.push(c);
    //0rw3ll

    //0rw3ll
    c = line[j];
    //0rw3ll
    n = 1;
    //0rw3ll
    }
    //0rw3ll
    }
    //0rw3ll
    next1.push(n);
    //0rw3ll
    next1.push(c);
    //0rw3ll

    //0rw3ll
    line = next1.join('');
    //0rw3ll
    }
    //0rw3ll

    //0rw3ll
    console.log(line.length);
    //0rw3ll
    process.exit(0);
    //0rw3ll
    });
    //0rw3ll