AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Challenge: translate rosettacode - Was promoting autohotkey
Goto page 1, 2, 3 ... 10, 11, 12  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> General Chat
View previous topic :: View next topic  
Author Message
tinku99



Joined: 03 Aug 2007
Posts: 308
Location: Houston, TX

PostPosted: Wed May 27, 2009 5:32 am    Post subject: Challenge: translate rosettacode - Was promoting autohotkey Reply with quote

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. Will try to get back to top 10 or top 5 with AutoHotkey_L / Objects.


Last edited by tinku99 on Tue Jan 05, 2010 10:36 pm; edited 18 times in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
tinku99



Joined: 03 Aug 2007
Posts: 308
Location: Houston, TX

PostPosted: Thu May 28, 2009 3:51 pm    Post subject: tasks not yet implemented in ahk Reply with quote

If you are interested in improving your coding skills, try translating the rosettacode tasks in autohotkey.

Here are some already done.

bump
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sinkfaze



Joined: 18 Mar 2008
Posts: 2428

PostPosted: Thu May 28, 2009 6:22 pm    Post subject: Reply with quote

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

}

_________________
Try Quick Search for Autohotkey or see the tutorial for newbies.
Back to top
View user's profile Send private message
sinkfaze



Joined: 18 Mar 2008
Posts: 2428

PostPosted: Thu May 28, 2009 8:00 pm    Post subject: Reply with quote

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

_________________
Try Quick Search for Autohotkey or see the tutorial for newbies.
Back to top
View user's profile Send private message
tinku99



Joined: 03 Aug 2007
Posts: 308
Location: Houston, TX

PostPosted: Thu May 28, 2009 11:27 pm    Post subject: 99bottles and 100doors Reply with quote

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.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frankie



Joined: 02 Nov 2008
Posts: 828

PostPosted: Fri May 29, 2009 12:16 am    Post subject: Reply with quote

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.
_________________
Click here to join #AHK channel in IRC for general chat and quick help.
Back to top
View user's profile Send private message AIM Address
tinku99



Joined: 03 Aug 2007
Posts: 308
Location: Houston, TX

PostPosted: Fri May 29, 2009 12:28 am    Post subject: Reply with quote

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>
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frankie



Joined: 02 Nov 2008
Posts: 828

PostPosted: Fri May 29, 2009 12:44 am    Post subject: Reply with quote

Thanks. Its added with the command prompt edit. Link
_________________
Click here to join #AHK channel in IRC for general chat and quick help.
Back to top
View user's profile Send private message AIM Address
jaco0646



Joined: 07 Oct 2006
Posts: 1770
Location: MN, USA

PostPosted: Fri May 29, 2009 1:12 am    Post subject: Reply with quote

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. Razz
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
}

_________________
http://autohotkey.net/~jaco0646/


Last edited by jaco0646 on Fri May 29, 2009 11:12 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Krogdor



Joined: 18 Apr 2008
Posts: 1381
Location: The Interwebs

PostPosted: Fri May 29, 2009 1:30 am    Post subject: Reply with quote

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...
Back to top
View user's profile Send private message AIM Address
jaco0646



Joined: 07 Oct 2006
Posts: 1770
Location: MN, USA

PostPosted: Fri May 29, 2009 3:21 am    Post subject: Reply with quote

At the bottom of the list it says it updates every 4 hours.
_________________
http://autohotkey.net/~jaco0646/
Back to top
View user's profile Send private message Visit poster's website
Krogdor



Joined: 18 Apr 2008
Posts: 1381
Location: The Interwebs

PostPosted: Fri May 29, 2009 5:43 am    Post subject: Reply with quote

Oh, hehe...
I knew that.
Back to top
View user's profile Send private message AIM Address
tinku99



Joined: 03 Aug 2007
Posts: 308
Location: Houston, TX

PostPosted: Fri May 29, 2009 2:19 pm    Post subject: happy number Reply with quote

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.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sinkfaze



Joined: 18 Mar 2008
Posts: 2428

PostPosted: Fri May 29, 2009 2:40 pm    Post subject: Reply with quote

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 Confused ).
_________________
Try Quick Search for Autohotkey or see the tutorial for newbies.
Back to top
View user's profile Send private message
sinkfaze



Joined: 18 Mar 2008
Posts: 2428

PostPosted: Fri May 29, 2009 3:56 pm    Post subject: Reply with quote

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

_________________
Try Quick Search for Autohotkey or see the tutorial for newbies.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> General Chat All times are GMT
Goto page 1, 2, 3 ... 10, 11, 12  Next
Page 1 of 12

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group