AutoHotkey Community

It is currently May 26th, 2012, 7:09 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 417 posts ]  Go to page 1, 2, 3, 4, 5 ... 28  Next
Author Message
PostPosted: May 27th, 2009, 6:32 am 
Offline

Joined: August 3rd, 2007, 8:01 am
Posts: 555
Location: Houston, TX
I think autohotkey is terribly underrepresented on major websites comparing programming languages. So, I added a few autohotkey examples on rosettacode here:AutoHotkey_Originated.
from the site:
Quote:
Rosetta Code is a programming chrestomathy site. The idea is to present solutions to the same task in as many different languages.
If you believe it, help me prove that autohotkey is as usefull as the most popular languages by translating:
Tasks_not_implemented_in_AutoHotkey
Here are the translated tasks

Edit:
If you contribute, edit your user page on rosettacode with something like:
Code:
{{mylangbegin}}
{{mylang|AutoHotkey| proficiency level here }}
{{mylangend}}
so you show up in the AutoHotkey_User list

Edit2:
AutoHotkey is now ranked in the top 10 of the most popular languages.

Edit3:
slipped to 14.

Edit4:
back to top 10. May 16, 2010.


Last edited by tinku99 on May 16th, 2010, 10:05 pm, edited 19 times in total.

Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 28th, 2009, 4:51 pm 
Offline

Joined: August 3rd, 2007, 8:01 am
Posts: 555
Location: Houston, TX
If you are interested in improving your coding skills, try translating the rosettacode tasks in autohotkey.

Here are some already done.

bump


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 28th, 2009, 7:22 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
I can't post it to the Wiki from where I'm at but if someone else would like to here's a solution we can post for 99 bottles of beer, or if someone sees a more optimal solution please go for it:

Code:
x=100
Loop, 99 {

  if (x - A_Index - 1 > 1)
   FileAppend
   , % x - A_Index " bottles of beer on the wall,`n" x - A_Index " bottles of beer,`nTake one down and pass it around,`n" x - A_Index - 1 " bottles of beer on the wall.`n`n"
   , Output.txt
  else if (x - A_Index - 1 = 1)
   FileAppend
   , % x - A_Index " bottles of beer on the wall,`n" x - A_Index " bottles of beer,`nTake one down and pass it around,`n" x - A_Index - 1 " bottle of beer on the wall.`n`n"
   , Output.txt
  else if (x - A_Index - 1 = 0)
   FileAppend
   , % x - A_Index " bottle of beer on the wall,`n" x - A_Index " bottle of beer,`nTake one down and pass it around,`nNo more bottles of beer on the wall.`n"
   , Output.txt

}

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 28th, 2009, 9:00 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
Also (again I am unable to post to the Wiki), here's a solution to the 100 doors problem if someone would like to review it for optimization or just post it to the Wiki:

Code:
Loop, 100
  Door%A_Index% := "closed"

Loop, 100 {
  x := A_Index
  y := A_Index
  While (x <= 100)
  {
    CurrentDoor := Door%x%
    If CurrentDoor contains closed
    {
      Door%x% := "open"
      x += y
    }
    else if CurrentDoor contains open
    {
      Door%x% := "closed"
       x += y
     }
  }
}

Loop, 100 {
   CurrentDoor := Door%A_Index%
   If CurrentDoor contains open
      Res .= "Door" A_Index "`n"
}

MsgBox % "The following doors are still open.`n`n" Res

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: 99bottles and 100doors
PostPosted: May 29th, 2009, 12:27 am 
Offline

Joined: August 3rd, 2007, 8:01 am
Posts: 555
Location: Houston, TX
Thanks sinkfaze,
I posted them both with minor changes: 99 bottles, 100 doors.
If you want to further modify what i posted, start a new thread in the ahk forums, for that task.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 29th, 2009, 1:16 am 
Offline
User avatar

Joined: November 2nd, 2008, 4:23 pm
Posts: 2906
Location: 127.0.0.1
If were going for all the puzzles I did an easy one:
Code:
Loop, 100
{
  If (Mod(A_Index, 15) = 0)
    Output .= "FizzBuzz`n"
  Else If (Mod(A_Index, 3) = 0)
    Output .= "Fizz`n"
  Else If (Mod(A_Index, 5) = 0)
    Output .= "Buzz`n"
  Else
    Output .= "`n"
}
Msgbox % Output
Someone else can post it to the wiki. I don't know how to work wikipedia. Also is there a better way to display it than the msgbox? I didn't want to add a gui with an editbox to to the code because thats to much code.

_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 29th, 2009, 1:28 am 
Offline

Joined: August 3rd, 2007, 8:01 am
Posts: 555
Location: Houston, TX
Frankie wrote:
Also is there a better way to display it than the msgbox? I didn't want to add a gui with an editbox to to the code because thats to much code.
You can either use consolesend. example
or do this: example
Code:
FileDelete, output.txt
FileAppend, %output% output.txt
run, cmd /k type Output.txt

Frankie wrote:
I don't know how to work wikipedia.

just click edit, and paste this in the proper alphabetic position.
Code:
=={{header|AutoHotkey}}==
<lang AutoHotkey>
...autohotkey code here...
</lang>


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 29th, 2009, 1:44 am 
Offline
User avatar

Joined: November 2nd, 2008, 4:23 pm
Posts: 2906
Location: 127.0.0.1
Thanks. Its added with the command prompt edit. Link

_________________
aboutscriptappsscripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 29th, 2009, 2:12 am 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
Here's my solution to Happy Number. I like the idea of posting solutions here first to let others look them over for bugs or optimizations before submitting them on Rosetta Code. Plus I've never had any luck with recursion before. :P
EDIT: updated code
Code:
MsgBox,% Happy()
return

Happy() {
 static in:=1,out:="",int:=1,index:=1
 Loop,Parse,int
  num += A_LoopField**2
 If (num=1) OR (index++ > 9) {
  out .= num=1 ? in "`n":""
  int := ++in
  index := 1
 }
 Else int := num
 StringReplace,out,out,`n,`n,UseErrorLevel
 If (ErrorLevel < 8)
  Happy()
 Return, out
}


Last edited by jaco0646 on May 30th, 2009, 12:12 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 29th, 2009, 2:30 am 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
Just curious, how do you make a task disappear from the list of uncompleted tasks for a given language? I had hoped it would do it automatically after you put the given language onto a task page, but after posting an AHK solution for the Ackermann function, the task still appears on AHK's uncompleted task page...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 29th, 2009, 4:21 am 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
At the bottom of the list it says it updates every 4 hours.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 29th, 2009, 6:43 am 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
Oh, hehe...
I knew that.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: happy number
PostPosted: May 29th, 2009, 3:19 pm 
Offline

Joined: August 3rd, 2007, 8:01 am
Posts: 555
Location: Houston, TX
jaco0646 wrote:
Here's my solution to Happy Number. I like the idea of posting solutions here first to let others look them over for bugs or optimizations before submitting them on Rosetta Code.

your ahk Happy Number seems to work.

A few suggestions for improvement:
I don't think you have to worry about optimizing too much. Readability is more important IMO.
Consider taking out SetBatchLines.

Also, I would modify the happy() function to accept a number and decide if its happy. Try translating the python example.

I think it would be good to also have a dedicated thread for each rosettacode task posted. It would be easier for people to find, improve, and discuss it later.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 29th, 2009, 3:40 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
Here is my solution to the Bogosort task, this looks like an AHK equivalent of the Bogosort algorithm:

Code:
Lost = 123456789
Loop {
  Seed = 123456789
  Found := ""
  Loop, 9 {
    Random, No, 1, % 10 - A_Index
    Found .= SubStr(Seed,No,1)
    Seed := SubStr(Seed,1,No-1) . SubStr(Seed,No+1)
  }
  if (Lost = Found)
  {
    MsgBox % "We have a match!`n`nLost: " Lost "`nFound: " Found
    break
  }
}


Sorry, at work again and cannot post to the Wiki (but I can do everything else :? ).

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 29th, 2009, 4:56 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
Here's another one for the bubble sort algorithm if someone would like to double-check it:

Code:
Seed = 123456789
Loop 9 {
  Random, No, 1, % 10 - A_Index
  Number .= SubStr(Seed,No,1)
  Seed := SubStr(Seed,1,No-1) . SubStr(Seed,No+1)
}
Lost := Number
Loop {

  if Lost <> 123456789
  {
    Loop 8 {
      if (SubStr(Lost,A_Index,1) > SubStr(Lost,A_Index+1,1))
        Lost := SubStr(Lost,1,A_Index-1) . SubStr(Lost,A_Index+1,1) . SubStr(Lost,A_Index,1) . SubStr(Lost,A_Index+2)
    }
  }
  else
  {
    MsgBox % "You've successfully bubble sorted the number!`n`nStarting number: " Number "`nLost: " Lost
    break
  }
}

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 417 posts ]  Go to page 1, 2, 3, 4, 5 ... 28  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: ram09 and 13 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group