All pastes #373713 Raw Edit

Unnamed

public text v1 · immutable
#373713 ·published 2007-02-26 23:26 UTC
rendered paste body
  if ((time()-$time) >= 20 && $target =~ /^#rubik$/i && $text =~ /^[.!]((alg)?m|mega(minx)?)(\s(\d+))?/i) {
    my $len = $5;
    if ($len > 100) { $len = 100; }
    if ($len <= 0) { $len = 60; }
    Irssi::signal_stop();
    my @bits = (1,1,1,1,1,1,1,1,1,1,1,1);
    my $chars = "ABCDEFabcdef2'";
    my ($result,$rand);
    for (my $i; $i < $len; $i++) {
      $rand = int(rand(12));
      while (!$bits[$rand]) { $rand = int(rand(12));  }
      #$bits[$rand] = 0;
      
      #       A  B  C  D  E  F  a  b  c  d  e  f
      #       0  1  2  3  4  5  6  7  8  9  10 11
      #  
      #  A  - 0  1  1  1  1  1  a  b  c  d  e  f 
      #  B  - 1  0  1  D  E  1  a  b  c  1  1  f
      #  C  - 1  1  0  1  E  F  a  b  c  d  1  1
      #  D  - 1  B  1  0  1  F  a  1  c  d  e  1
      #  E  - 1  B  C  1  0  1  a  1  1  d  e  f
      #  F  - 1  1  C  D  1  0  a  b  1  1  e  f
      #  a  - A  B  C  D  E  F  0  1  1  1  1  1
      #  b  - A  B  C  1  1  F  1  0  1  d  e  1
      #  c  - A  B  C  D  1  1  1  1  0  1  e  f
      #  d  - A  1  C  D  E  1  1  b  1  0  1  f
      #  e  - A  1  1  D  E  F  1  b  c  1  0  1
      #  f  - A  B  1  1  E  F  1  1  c  d  1  0
      my ($A, $B, $C, $D, $E, $F, $a, $b, $c, $d, $e, $f) = @bits;
      
      if ($rand == 0) { @bits = split //,"0" . "1" . "1" . "1" . "1" . "1" . $a  . $b  . $c  . $d  . $e  . $f ; }
      if ($rand == 1) { @bits = split //,"1" . "0" . "1" . $D  . $E  . "1" . $a  . $b  . $c  . "1" . "1" . $f ; }
      if ($rand == 2) { @bits = split //,"1" . "1" . "0" . "1" . $E  . $F  . $a  . $b  . $c  . $d  . "1" . "1"; }
      if ($rand == 3) { @bits = split //,"1" . $B  . "1" . "0" . "1" . $F  . $a  . "1" . $c  . $d  . $e  . "1"; }
      if ($rand == 4) { @bits = split //,"1" . $B  . $C  . "1" . "0" . "1" . $a  . "1" . "1" . $d  . $e  . $f ; }
      if ($rand == 5) { @bits = split //,"1" . "1" . $C  . $D  . "1" . "0" . $a  . $b  . "1" . "1" . $e  . $f ; }
      if ($rand == 6) { @bits = split //,$A  . $B  . $C  . $D  . $E  . $F  . "0" . "1" . "1" . "1" . "1" . "1"; }
      if ($rand == 7) { @bits = split //,$A  . $B  . $C  . "1" . "1" . $F  . "1" . "0" . "1" . $d  . $e  . "1"; }
      if ($rand == 8) { @bits = split //,$A  . $B  . $C  . $D  . "1" . "1" . "1" . "1" . "0" . "1" . $e  . $f ; }
      if ($rand == 9) { @bits = split //,$A  . "1" . $C  . $D  . $E  . "1" . "1" . $b  . "1" . "0" . "1" . $f ; }
      if ($rand == 10){ @bits = split //,$A  . "1" . "1" . $D  . $E  . $F  . "1" . $b  . $c  . "1" . "0" . "1"; }
      if ($rand == 11){ @bits = split //,$A  . $B  . "1" . "1" . $E  . $F  . "1" . "1" . $c  . $d  . "1" . "0"; }
      
      $result .= substr($chars,$rand,1);
      $rand = int(rand(4));
      if ($rand && $rand != 3) { $result .= substr($chars,$rand+11,1); }
      if ($rand == 3) { $result .= "2'"; }
      $result .= " ";
    }
    $totals[7]++; 
    $time = time();
    $server->command("msg #rubik Megaminx scramble #$totals[7]: $result");
    save_counts();
  }