The most pointless algorithm in existance?

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Eizo

DA Veteran Fan since 2000
Jun 26, 2004
112
0
0
36
Southampton, UK
www.larsenserver.co.uk
Hey ho

No off-topic forum so I thought i'd shove it here instead

This is probably the most pointless algorithm I have ever written (C#)

Code:
static bool PostCodeCheck(string strPostCode)
		{
			/* This sub validates a UK Post Code
			 * Parameters: string postCode
			 * Returns: true if postcode is valid
			 * Copyright ?2004 Matthew Larsen - mat.larsen@gmail.com
			 */
			bool[] x = {true, true, false, false, false, true, true};
			bool validateFail = false;
			char[] postCode = strPostCode.ToCharArray();

			if (postCode.Length > 7)
			{ validateFail = false; }
			else
			{
				int z = 0;
				foreach (char y in postCode)
				{
					if ((y >= '0' && y <= '9') == x[z])
						{ validateFail = false; break; }
					else
					{ validateFail = true; }
					z = ++z;
				}
			}
			return validateFail;
		}

Bet none of you can beat that : :lol:
 

FluXs

old skool
Feb 12, 2002
1,026
0
0
39
United Kingdom
...a program to work out the population of rabbits

Code:
PROGRAM rabbit;
{The Program Works out rabbit population
Programmer: Mark Briscoe
Date: 20th October 2000
Version: 2.00}

uses crt; {for I/O functions}


VAR
     StartPop: REAL;    {Holds starting rabbit pop}
     Yearcnt:  INTEGER; {Add/Counts on years}
     Percent:  INTEGER; {Calculate percentage}
     ThisYr:   REAL;    {Holds this years pop}

BEGIN {Main program}

     clrscr; {Clear screen}

{ -  Load program details onto main screen - }
     WRITELN('*******  Welcome to Rabbit Pop  *******');
     WRITELN('            Build : v2.00');
     WRITELN;
     WRITELN;

{ -  Ask for details about rabbits - }
     WRITELN ('Input the starting population of the Rabbits:');
     READLN  (StartPop);
     WRITELN ('The starting population of Rabbits is now: ',StartPop:8:2 );
     WRITELN ('What % has the rabbit population increased every year for ten years?');
     READLN  (Percent);
     Yearcnt:= 0;

     ThisYr :=StartPop;
{ -  Work Out Population Increase - }
     WRITELN ('For Year: 0 The population of the rabbits is: ', StartPop);
      REPEAT
        Yearcnt:=Yearcnt+1; {Add 1 year onto last year}
        ThisYr :=ThisYr+ThisYr*Percent/100;
        WRITELN ('For Year: ',Yearcnt,' The population of the rabbits is: ', ThisYr:8:2);
      UNTIL Yearcnt>=10; {stop when years is 10}

      READLN;
END.


Mark Briscoe
Rabbit Population: Pascal Coding


:eek:
 

Bytekeeper

Last of the Brunnen G
Jul 15, 2001
181
0
0
Germany
Visit site
After a few people I know started playing Lotgd (Legend of the green dragon) online and I was a bit annoyed that it was kind of a linear game I coded a bot to play it. Here's a part of it:
Code:
    public void handleLine(String line) {
        if (line.toLowerCase().indexOf("accesskey") >= 0) 
            addActionLink(line);
        else if (line.toLowerCase().indexOf("charinfo") >= 0 && line.toLowerCase().indexOf("<span") >= 0)
            addInfo(line);
        
        if (type != 0)
            return;

        line = untag(line);
        if (line.indexOf("It is a new day!") >= 0)
            type = T_NEWDAY;
        else if (line.indexOf("LoGD News") >= 0)
            type = T_NEWSPAGE;
        else if (line.indexOf("Blades Boulevard") >= 0) // village
            type = T_VILLAGESQUARE;
        else if (line.indexOf("Into the Woods") >= 0)   // forest
            type = T_FOREST;
        else if (line.indexOf("Complete Healing") >= 0) // healer
            type = T_HEALER;
        else if (line.indexOf("~ ~ ~ Fight ~ ~ ~") >= 0)
            type = T_FIGHT;
        else if (line.indexOf("Exit the tavern") >= 0 ||
                line.indexOf("Enter the tavern") >= 0)
            type = T_TAVERN;
        else if (line.indexOf("#151;Old Man—") >= 0)
            type = T_TAVERN_OLDMAN;
        else if (line.indexOf("guessing game?") >= 0 ||
                line.indexOf("How much would you bet young man?") >= 0 ||
                line.indexOf("What is your guess?") >= 0)
            type = T_GUESSINGGAME;
        else if (line.indexOf("Take out a loan") >= 0)
            type = T_BANK;
        else if (line.indexOf("Transfer gems") >= 0)
            type = T_GEMBANK; 
        else if (line.indexOf("Go into Stonehenge") >= 0)
            type = T_STONEHENGE;
        else if (line.indexOf("Leave the altar Undisturbed") >= 0)
            type = T_ALTAR_ITEMS;
        else if (line.indexOf("a fairy in the forest") >= 0)
            type = T_FAIRY;
        else if (line.indexOf("Enter Castle") >= 0 ||
                line.indexOf("Courtyard") >= 0 ||
                line.indexOf("leaning over his Moulten") >= 0 ||
                line.indexOf("Armour shop, as you walk") >= 0)
            type = T_ORCCASTLE;
        else if (line.indexOf("Flirt with") >= 0 || line.indexOf("Ask Seth to") >= 0) 
            type = T_INN;
        else if (line.indexOf("Run away from Crazy") >= 0)
            type = T_AUDREY;
        else if (line.indexOf("Smiythe") >= 0)
            type = T_SMIYTHE;
        else if (line.indexOf("him to town") >= 0) 
            type = T_OLDMANTOWN;
        else if (line.indexOf("Question Master") >= 0)
            type = T_WARRIORTRAINING;
        else if (line.indexOf("Down Town") >= 0)
            type = T_ALANDORE;
        else if (line.indexOf("You enter the Mining Tent") >= 0)
            type = T_MINE;
        else if (line.indexOf("if you can think and answer my riddle") >= 0)
            type = T_RIDDLE;
        else if (line.indexOf("You walk among the dead now, you are a shade") >= 0)
            type = T_DIED;
        else if (line.indexOf("Enter the Mausoleum") >= 0)
            type = T_GRAVEYARD;
        else if (line.indexOf("worth of your soul") >= 0)
            type = T_MAUSOLEUM;
        else if (line.indexOf("Wyvern Keep") >= 0)
            type = T_DISTRESS;
        else if (line.indexOf("Leave him here") >= 0)
            type = T_NECROMANCER;
        else if (line.indexOf("sacrifice to the gods") >= 0)
            type = T_SACRIFICEALTAR;
        else if (line.indexOf("Choose your Race") >= 0)
            type = T_CHOOSERACE;
        else if (line.indexOf("A little history about yourself") >= 0)
            type = T_CHOOSESPECIAL;
        else if (line.indexOf("You discover a small stream of faintly glowing water") >= 0)
            type = T_WATER;
        else if (line.indexOf("Grab her backside") >= 0)
            type = T_FLIRTPAGE;
        else if (line.indexOf("Peruse Weapons") >= 0 ||
                line.indexOf("click on the weapon you wish to buy") >= 0)
            type = T_WEAPONSHOP;
        else if (line.indexOf("Browse Pegasus' wares") >= 0 ||
                line.indexOf("You look over the various pieces of apparal") >= 0)
            type = T_ARMORSHOP;
        else if (line.indexOf("you are dazzled by the many jewels") >= 0 ||
                line.indexOf("If you want to sell gems") >= 0 ||
                line.indexOf("and think you can pull a fast one on me") >= 0 ||
                line.indexOf("You just sold") >= 0 ||
                line.indexOf("You just bought") >= 0)
            type = T_GEMEXCHANGE;
        else if (line.indexOf("Mine for gold and gems") >= 0) 
            type = T_OLDMINE;
        else if (line.indexOf("Step of the stone") >= 0)
            type = T_PORTAL;
        else if (line.indexOf("Master of all?") >= 0)
            type = T_FOILWENCH;
        else if (line.indexOf("Follow the trail") >= 0)
            type = T_TRAIL;
        else if (line.indexOf("Give him a gem") >= 0)
            type = T_GNOME;
        else if (line.indexOf("Run away like a baby") >= 0)
            type = T_DRAGONCAVE;
        else if (line.indexOf("unspent dragon points") >= 0)
            type = T_SPENTDRAGONPOINT;
    }
    
    public static String untag(String l) {
        int index = 0;
        l = l.replaceAll("<td", " <td");
        while ((index = l.indexOf("<")) >= 0 && l.indexOf(">", index) >= 0) {
            l = l.substring(0, index) + l.substring(l.indexOf(">", index) + 1);
        }
        return l.trim();
    }

Oh and it worked pretty well, I had like 2 billion credits after 2 days continues playing ^^
 

slobo04

DA2 Dev. Team - - Mapper - -
Feb 12, 2002
45
0
0
37
California
basic... omg bill gates first code!

REM Infinite Loop Test
10 goto 15
15 print "muhahahaha"
20 goto 10

:lol:
 
Last edited: