THT Community (TCom)

Full Version: The Monkey Theory
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
On #lobby (irc.echelon4.net), SumWon wanted to see how many virtual monkeys it took to type BANANA given a six-key limit and a keyboard with all keys except Shift, Tab, *Lock, Enter, F1, F2, Esc, etc. in C++

The practice later caught on with myself making a PHP version, another user (Chris) making a Python version, another user (Clinteger) making a Python version, and the chain continued.

I'll post my code here for you guys to see and, if you wish, use, but BE AWARE:
  1. The PHP.ini is edited to allow 350 MB RAM usage and unlimited execution time.
  2. This is NOT executed on a web page. This is done purely on the command line interface.
  3. This is done on my OWN SERVER, NOT another server or VPS. Executing this on a website will get you killed by the host police.

There is also another script that automatically post the results to twitter (written in bash, requires cURL), and another script the twitter script depends on (this one's written in PHP) to format the monkey number into their proper place values.

PHP Monkey Script
(click to find Pastie entry)

PHP Script to support Bash Script
PHP Code:
<?php
echo number_format($_REQUEST['number']);
// Yep, that simple. 

Bash Script
(click to find Pastie entry)
Requires extra configuration

Follow me on Twitter @MonkeysLikeCode.

No monkeys were harmed in the making of this program.
PHP Code:
set_time_limit(0); 
(unlimited) Angel

Also, here is a pastie with syntax highlighting: http://pastie.org/828157
(02-16-2010 08:15 PM)Kevin Wrote: [ -> ]
PHP Code:
set_time_limit(0); 
(unlimited) Angel

You and your logic. Not to mention it already started. Tongue
You can also set max execution time to 0/unlimited in your php.ini. Another thing is when you run from the command line you can create a custom php.ini for use with that script. Then use the -c flag.
(02-16-2010 10:08 PM)Kevin Wrote: [ -> ]You can also set max execution time to 0/unlimited in your php.ini. Another thing is when you run from the command line you can create a custom php.ini for use with that script. Then use the -c flag.

Angel
(02-17-2010 12:34 AM)Nelson Wrote: [ -> ]
(02-16-2010 10:08 PM)Kevin Wrote: [ -> ]You can also set max execution time to 0/unlimited in your php.ini. Another thing is when you run from the command line you can create a custom php.ini for use with that script. Then use the -c flag.

Angel

Heart
(02-17-2010 01:28 AM)Kevin Wrote: [ -> ]
(02-17-2010 12:34 AM)Nelson Wrote: [ -> ]
(02-16-2010 10:08 PM)Kevin Wrote: [ -> ]You can also set max execution time to 0/unlimited in your php.ini. Another thing is when you run from the command line you can create a custom php.ini for use with that script. Then use the -c flag.

Angel

Heart

Well, at least I'm almost at 550,000,000 monkeys (after restarting at 2:00 in the morning). Big Grin

But still no banana. Angry
int i = 0;
while ( 1 )
{
cout << i << endl;
i++;
}

Tongue Now this this goes fast. C++ ftw.
(02-17-2010 04:38 PM)zzbomb Wrote: [ -> ]int i = 0;
while ( 1 )
{
cout << i << endl;
i++;
}

Tongue Now this this goes fast. C++ ftw.

There's no random string generation or a check for the string "BANANA"
Your argument is invalid Tongue
Grr. Gimme 5 min. ill program it legitly.
And done. Check it out. After a minute. the count is up to 400,000 and going......

2.5Million.
Code:
#include <iostream>
using namespace std;

int main()
{
    int i;
    long int count = 0;
    string banana ="";
    srand((unsigned int)time(NULL));
    while ( banana != "BANANA" )
    {
          for ( i = 0; i < 6; i++ )
          {
              
              int n = rand() % 26;
              char c = (char)(n+65);
              banana += c;
          }
          cout << banana << " ";
          
          if ( banana != "BANANA" )
          {
               banana = "";
               count++;
          }
          cout << count << endl;

    }
    
    system("pause");
    return 0;
}

ok im gunna stop this now it is at 6million lol.
Pages: 1 2
Reference URL's