Jump to content
DavidLago

Bogosort on AutoIt

Recommended Posts

DavidLago

Hey.

Bogosort: https://en.wikipedia.org/wiki/Bogosort 

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 this post


Link to post
Share on other sites
TheSaint

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. :D

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)

userbar.png

Share this post


Link to post
Share on other sites
DavidLago

Hi, not asking for anything :)

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 :D

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 this post


Link to post
Share on other sites
TheSaint
32 minutes ago, DavidLago said:

Hi, not asking for anything :)

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 :D

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)

userbar.png

Share this post


Link to post
Share on other sites
DavidLago

Reported, Sir!


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

Share this post


Link to post
Share on other sites
JLogan3o13

Moved per request.


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

Share this post


Link to post
Share on other sites
TheDcoder
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

My contributions to the AutoIt Community

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!!!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites
DavidLago

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

Screenshot - 18_01_2016 , 15_02_04.png


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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×