Skip to main content
Commonmark migration
Source Link

##JS, 303, 288, 275, 273, 274 (bug fix)## function z(s){return s.split('').map(function(d){if((r=Math.random)(b='qwertyuiop0asdfghjkl000zxcvbnm')>.1)return d if((c=r(x=(d>'`'?b:(b=b.toUpperCase())).indexOf(d))*(/[a-z]/i.test(d)+2))<2)return c>1?d+d:'' for(a=0;!a;)a=b[x+[11,-11,1,-1][~~(r()*4)]] return a}).join('')}

JS, 303, 288, 275, 273, 274 (bug fix)

function z(s){return s.split('').map(function(d){if((r=Math.random)(b='qwertyuiop0asdfghjkl000zxcvbnm')>.1)return d
if((c=r(x=(d>'`'?b:(b=b.toUpperCase())).indexOf(d))*(/[a-z]/i.test(d)+2))<2)return c>1?d+d:''
for(a=0;!a;)a=b[x+[11,-11,1,-1][~~(r()*4)]]
return a}).join('')}

##JS, 303, 288, 275, 273, 274 (bug fix)## function z(s){return s.split('').map(function(d){if((r=Math.random)(b='qwertyuiop0asdfghjkl000zxcvbnm')>.1)return d if((c=r(x=(d>'`'?b:(b=b.toUpperCase())).indexOf(d))*(/[a-z]/i.test(d)+2))<2)return c>1?d+d:'' for(a=0;!a;)a=b[x+[11,-11,1,-1][~~(r()*4)]] return a}).join('')}

JS, 303, 288, 275, 273, 274 (bug fix)

function z(s){return s.split('').map(function(d){if((r=Math.random)(b='qwertyuiop0asdfghjkl000zxcvbnm')>.1)return d
if((c=r(x=(d>'`'?b:(b=b.toUpperCase())).indexOf(d))*(/[a-z]/i.test(d)+2))<2)return c>1?d+d:''
for(a=0;!a;)a=b[x+[11,-11,1,-1][~~(r()*4)]]
return a}).join('')}
bugfix for special characters
Source Link

##JS, 303, 288, 275, 273##273, 274 (bug fix)## function z(s){return s.split('').map(function(d){if((r=Math.random)(b='qwertyuiop0asdfghjkl000zxcvbnm')>.1)return d if((c=r(x=(d>'`'?b:(b=b.toUpperCase())).searchindexOf(d))*(/[a-z]/i.test(d)+3+2))<2)return c>1?d+d:'' for(a=0;!a;)a=b[x+[11,-11,1,-1][~~(r()*4)]] return a}).join('')}

function z (s) {
  return s.split('') // split input string into characters.
          .map( // and then for each character...
    function (d) {
      r = Math.random; // set up a shortened form of Math.random
      // declare keyboard here because we have parens and we can save a delimeter.
      b = 'qwertyuiop0asdfghjkl000zxcvbnm';  
      if (r() > .1) {  // normal case
        return d;
      }
      numOptions = /[a-z]/i.test(d) + 3;2; // if it's a character, 0+31+2, else -1+30+2 options

      // test here because we have parens. x might be -1
      if (d > '`') { 
        x = b.search(d);  // x marks the spot
      } else {
        b = b.toUpperCase();
        x = b.search(d);
      }

      c = r() * numOptions; // chars can be 0-3, non-chars: 0-2
      if (c < 2) {                // this case is simple, so it comes first
        return c>1 ? d + d : ''; // double or omit.
      }

      // we must be in keyslip mode.

      // in the golfed code, this while loop become for loops, 
      // but it's really a while.
      a = 0;
      while (!a) { // that is, a != null && a != 0
        v = ~~(r() * 4); // 0, 1, 2, or 3
        newX = x + [11, -11, 1, -1][v]; // choose one
        a = b[newX];  // slip the key
      }
      return a;
    }
  ) // end the map function
  .join('') // and then reassemble the string
}

##JS, 303, 288, 275, 273## function z(s){return s.split('').map(function(d){if((r=Math.random)(b='qwertyuiop0asdfghjkl000zxcvbnm')>.1)return d if((c=r(x=(d>'`'?b:(b=b.toUpperCase())).search(d))*(/[a-z]/i.test(d)+3))<2)return c>1?d+d:'' for(a=0;!a;)a=b[x+[11,-11,1,-1][~~(r()*4)]] return a}).join('')}

function z (s) {
  return s.split('') // split input string into characters.
          .map( // and then for each character...
    function (d) {
      r = Math.random; // set up a shortened form of Math.random
      // declare keyboard here because we have parens and we can save a delimeter.
      b = 'qwertyuiop0asdfghjkl000zxcvbnm';  
      if (r() > .1) {  // normal case
        return d;
      }
      numOptions = /[a-z]/i.test(d) + 3; // if it's a character, 0+3, else -1+3 options

      // test here because we have parens. x might be -1
      if (d > '`') { 
        x = b.search(d);  // x marks the spot
      } else {
        b = b.toUpperCase();
        x = b.search(d);
      }

      c = r() * numOptions; // chars can be 0-3, non-chars: 0-2
      if (c < 2) {                // this case is simple, so it comes first
        return c>1 ? d + d : ''; // double or omit.
      }

      // we must be in keyslip mode.

      // in the golfed code, this while loop become for loops, 
      // but it's really a while.
      a = 0;
      while (!a) { // that is, a != null && a != 0
        v = ~~(r() * 4); // 0, 1, 2, or 3
        newX = x + [11, -11, 1, -1][v]; // choose one
        a = b[newX];  // slip the key
      }
      return a;
    }
  ) // end the map function
  .join('') // and then reassemble the string
}

##JS, 303, 288, 275, 273, 274 (bug fix)## function z(s){return s.split('').map(function(d){if((r=Math.random)(b='qwertyuiop0asdfghjkl000zxcvbnm')>.1)return d if((c=r(x=(d>'`'?b:(b=b.toUpperCase())).indexOf(d))*(/[a-z]/i.test(d)+2))<2)return c>1?d+d:'' for(a=0;!a;)a=b[x+[11,-11,1,-1][~~(r()*4)]] return a}).join('')}

function z (s) {
  return s.split('') // split input string into characters.
          .map( // and then for each character...
    function (d) {
      r = Math.random; // set up a shortened form of Math.random
      // declare keyboard here because we have parens and we can save a delimeter.
      b = 'qwertyuiop0asdfghjkl000zxcvbnm';  
      if (r() > .1) {  // normal case
        return d;
      }
      numOptions = /[a-z]/i.test(d) + 2; // if it's a character, 1+2, else 0+2 options

      // test here because we have parens. x might be -1
      if (d > '`') { 
        x = b.search(d);  // x marks the spot
      } else {
        b = b.toUpperCase();
        x = b.search(d);
      }

      c = r() * numOptions; // chars can be 0-3, non-chars: 0-2
      if (c < 2) {                // this case is simple, so it comes first
        return c>1 ? d + d : ''; // double or omit.
      }

      // we must be in keyslip mode.

      // in the golfed code, this while loop become for loops, 
      // but it's really a while.
      a = 0;
      while (!a) { // that is, a != null && a != 0
        v = ~~(r() * 4); // 0, 1, 2, or 3
        newX = x + [11, -11, 1, -1][v]; // choose one
        a = b[newX];  // slip the key
      }
      return a;
    }
  ) // end the map function
  .join('') // and then reassemble the string
}
dropped another 2
Source Link

##JS, 303##303, 288, 275, 273## function z(s){return s.split('').map(function(d){if((r=Math.random)(b='qwertyuiop0asdfghjkl000zxcvbnm')>.1)return d if((c=r(x=(d>'`'?b:(b=b.toUpperCase())).search(d))*(/[a-z]/i.test(d)+3))<2)return c>1?d+d:'' for(a=0;!a;)a=b[x+[11,-11,1,-1][~~(r()*4)]] return a}).join('')}

function z(s){return s.split('').map(function(d){if((r=Math.random)()>.1)return d
if((c=r()*(/[a-z]/i.test(d)?3:2))<2)return c>1?d+d:''
if((x=(b="qwertyuiop0asdfghjkl000zxcvbnm").indexOf(d))<0)x=(b=b.toUpperCase()).indexOf(d)
for(a=0,n=11;i=!a;a=b[x+n])for(v=r()*4;v>i;n=i++%2?-n:1);return a}).join('')}
function z (s) {
  return s.split('') // split input string into characters.
          .map( // and then for each character...
    function (d) {
      r = Math.random; // set up a shortened form of Math.random
      // declare keyboard here because we have parens and we can save a delimeter.
      b = 'qwertyuiop0asdfghjkl000zxcvbnm';  
      if (r() > .1) {  // normal case
        return d;
      }
      numOptions = /[a-z]/i.test(d) ? 3 :+ 2;3; // if it's a character, three0+3, else -1+3 options
  
     c =// r()test *here numOptions;because //we charshave canparens. bex 0-3,might non-chars:be 0-21
      if (cd < 2> '`') {  
        x = b.search(d);  // x marks //the thisspot
 case is simple, so it comes} firstelse {
        returnb c>1= ?b.toUpperCase();
 d + d : ''; // double orx omit= b.search(d);
      }

      c = r() * numOptions; // wechars mustcan be in0-3, keyslipnon-chars: mode.0-2
      bif =(c "qwertyuiop0asdfghjkl000zxcvbnm";< 2) //{ keyboard map
      x = b.indexOf(d);  // x marks the spot
// this case is simple, so ifit (xcomes <first
 0) {  // not here? must be a capitalreturn letter!
c>1 ? d + d : ''; // bdouble =or bomit.toUpperCase();
      }

  x = b.indexOf(d);
  // we must be in keyslip }mode.

      // in the golfed code, thesethis while loopsloop become for loops, 
      // but it's really a while.
      a = 0, n = 11, i = 1;0;
      while (!a) { // that is, a != null && a != 0
        i = 1;
        v = ~~(r() * 4;4); // so v is a random number <= 4
        while (v0, >1, i)2, {or 3
          nnewX = i++ % 2 ? -n : 1; // n steps in thisx pattern:+ [11, -11, 1, -1]
     1][v]; // choose }one
        a = b[x+n];b[newX];  // slip the key
      }
      return a;
    }
  ) // end the map function
  .join('') // and then reassemble the string
}

##JS, 303##

function z(s){return s.split('').map(function(d){if((r=Math.random)()>.1)return d
if((c=r()*(/[a-z]/i.test(d)?3:2))<2)return c>1?d+d:''
if((x=(b="qwertyuiop0asdfghjkl000zxcvbnm").indexOf(d))<0)x=(b=b.toUpperCase()).indexOf(d)
for(a=0,n=11;i=!a;a=b[x+n])for(v=r()*4;v>i;n=i++%2?-n:1);return a}).join('')}
function z (s) {
  return s.split('') // split input string into characters.
          .map( // and then for each character...
    function (d) {
      r = Math.random; // set up a shortened form of Math.random
      if (r() > .1) {  // normal case
        return d;
      }
      numOptions = /[a-z]/i.test(d) ? 3 : 2; // if it's a character, three options
      c = r() * numOptions; // chars can be 0-3, non-chars: 0-2
      if (c < 2) {                // this case is simple, so it comes first
        return c>1 ? d + d : ''; // double or omit.
      }

      // we must be in keyslip mode.
      b = "qwertyuiop0asdfghjkl000zxcvbnm"; // keyboard map
      x = b.indexOf(d);  // x marks the spot
      if (x < 0) {  // not here? must be a capital letter!
        b = b.toUpperCase();
        x = b.indexOf(d);
      }

      // in the golfed code, these while loops become for loops, 
      // but it's really a while.
      a = 0, n = 11, i = 1;
      while (!a) { // that is, a != null && a != 0
        i = 1;
        v = r() * 4; // so v is a random number <= 4
        while (v > i) { 
          n = i++ % 2 ? -n : 1; // n steps in this pattern: [11, -11, 1, -1]
        }
        a = b[x+n];  // slip the key
      }
      return a;
    }
  ) // end the map function
  .join('') // and then reassemble the string
}

##JS, 303, 288, 275, 273## function z(s){return s.split('').map(function(d){if((r=Math.random)(b='qwertyuiop0asdfghjkl000zxcvbnm')>.1)return d if((c=r(x=(d>'`'?b:(b=b.toUpperCase())).search(d))*(/[a-z]/i.test(d)+3))<2)return c>1?d+d:'' for(a=0;!a;)a=b[x+[11,-11,1,-1][~~(r()*4)]] return a}).join('')}

function z (s) {
  return s.split('') // split input string into characters.
          .map( // and then for each character...
    function (d) {
      r = Math.random; // set up a shortened form of Math.random
      // declare keyboard here because we have parens and we can save a delimeter.
      b = 'qwertyuiop0asdfghjkl000zxcvbnm';  
      if (r() > .1) {  // normal case
        return d;
      }
      numOptions = /[a-z]/i.test(d) + 3; // if it's a character, 0+3, else -1+3 options
 
      // test here because we have parens. x might be -1
      if (d > '`') {  
        x = b.search(d);  // x marks the spot
      } else {
        b = b.toUpperCase();
        x = b.search(d);
      }

      c = r() * numOptions; // chars can be 0-3, non-chars: 0-2
      if (c < 2) {                // this case is simple, so it comes first
        return c>1 ? d + d : ''; // double or omit.
      }

      // we must be in keyslip mode.

      // in the golfed code, this while loop become for loops, 
      // but it's really a while.
      a = 0;
      while (!a) { // that is, a != null && a != 0
        v = ~~(r() * 4); // 0, 1, 2, or 3
        newX = x + [11, -11, 1, -1][v]; // choose one
        a = b[newX];  // slip the key
      }
      return a;
    }
  ) // end the map function
  .join('') // and then reassemble the string
}
deleted 15 characters in body
Source Link
Loading
added non-golfed version
Source Link
Loading
deleted 5 characters in body
Source Link
Loading
Source Link
Loading