# Bogosort on AutoIt

## Recommended Posts

Hey.

Useless, but fun.

```Global \$Var1, \$Var2, \$Var3, \$Var4, \$Var5, \$Var6, \$count = ""
Global \$Value = \$Var1 + \$Var2 + \$Var3 + \$Var4 + \$Var5 + \$Var6
Global \$Number = 10000
Global \$Flag = False

While Not \$Flag = True
\$count = \$count + 1
\$Var1 = Random(0, 2000, 1)
\$Var2 = Random(0, 2000, 1)
\$Var3 = Random(0, 2000, 1)
\$Var4 = Random(0, 2000, 1)
\$Var5 = Random(0, 2000, 1)
\$Var6 = Random(0, 2000, 1)
\$Value = \$Var1 + \$Var2 + \$Var3 + \$Var4 + \$Var5 + \$Var6
If \$Value = \$Number Then \$Flag = True
WEnd
MsgBox(64, "Bogosort", "Bogosort took " & \$count & " tries to guess 6 numbers!")```

Is anyone able to improve it in any way?

Edited by DavidLago

Just a server analyst that has never been into programming that much. So, small fish here

##### Share on other sites

Hi DavidLago, welcome to the General Chat forum.

If you are asking for improvements to code, then really this topic should be in Examples or GH&S.

Most of us come here to escape from code ... fun though your finished code might be.

Or perhaps even the Scripting & Development section of the forum, in Developer General Discussion

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

##### Share on other sites

Just showing up a really fun code, and if someone else wants to have fun, adding some stupid stuff in the code within the topic, that would be even more fun

If you think it would fit better there, could you move it?

Just a server analyst that has never been into programming that much. So, small fish here

##### Share on other sites
32 minutes ago, DavidLago said:

Just showing up a really fun code, and if someone else wants to have fun, adding some stupid stuff in the code within the topic, that would be even more fun

The original description of the Chat Forum, used to say no code, and as far as I know, that still stands.

To get around that, you could perhaps talk about Bogosort here, and provide a link to your code at wherever it gets relocated to.

Quote

If you think it would fit better there, could you move it?

Report the topic and ask, as it requires a MOD to do it.

Or just take up my suggestion and split your code off.

Edited by TheSaint

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

##### Share on other sites

Reported, Sir!

Just a server analyst that has never been into programming that much. So, small fish here

##### Share on other sites

Moved per request.

√-1 2^3 ∑ π, and it was delicious!

##### Share on other sites
5 hours ago, DavidLago said:

Is anyone able to improve it in any way?

```#include <MsgBoxConstants.au3>

Global Const \$NUMBER_TO_SORT = 10000
Global Const \$DIFFICULTY = 2000
Global Const \$NO_OF_ITERATIONS = 6

Global \$iCount = 0
Global \$iSum = 0

Do
\$iSum = 0
\$iCount = \$iCount + 1
For \$i = 1 To \$NO_OF_ITERATIONS
\$iSum += Random(0, \$DIFFICULTY, 1)
Next
Until \$iSum = \$NUMBER_TO_SORT

MsgBox(\$MB_OK + \$MB_ICONINFORMATION, "Bogosort", "Bogosort took " & \$iCount & " tries to guess " & \$NUMBER_TO_SORT & " out of " & \$NO_OF_ITERATIONS & " randomly added up numbers (each not exceeding " & \$DIFFICULTY & ')')```

P.S Its not AutoIT, Its AutoIt

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) mean to do that to anybody!!!

##### Share on other sites

I wonder how long it would get to guess 12000...

Just a server analyst that has never been into programming that much. So, small fish here

## Create an account

Register a new account

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...