Code Puzzle Thread

Talk about anything
qwerty12
Posts: 468
Joined: 04 Mar 2016, 04:33
GitHub: qwerty12

Re: Code Puzzle Thread

27 Sep 2017, 18:57

wolf_II wrote:The puzzle is: Can someone fix the bug?


It took me a while, but I think it's that __Delete won't work with a function expecting two or more mandatory arguments. Changing the parameters to add default values appears to work: Watchdog(wParam := 0, lParam := 0) Watchdog(wParam, lParam := 0)

(And thanks, I found two one functions of my own where it wasn't being cleaned up because of not knowing this...)

EDIT: Wait, you said three characters. Because we're in object land, an implicit this is passed to __Delete() as the first parameter, so only the second parameter needs a default argument. (EDIT: I think)

derz00 wrote:Wow, good job qwerty12


Oh, thanks, derz00 :oops:

wolf_II wrote::D The answer by qwerty12 is correct! Well done! :thumbup:


Oh, awesome, thanks!

Helgef wrote:Puzzle submition is open for anyone again (assuming qwerty12 declines the privilege ;) ).


I will have to do so again, sorry...
Last edited by qwerty12 on 28 Sep 2017, 08:47, edited 3 times in total.
User avatar
derz00
Posts: 464
Joined: 02 Feb 2016, 17:54
GitHub: derz00
Location: Middle of the round cube

Re: Code Puzzle Thread

27 Sep 2017, 20:22

Wow, good job qwerty12
try it and see
...
wolf_II
Posts: 1804
Joined: 08 Feb 2015, 20:55

Re: Code Puzzle Thread

27 Sep 2017, 23:26

qwerty12 wrote:Watchdog(wParam, lParam := 0)
This is close to the answer I found too (https://autohotkey.com/boards/viewtopic ... 45#p156945).

:D The answer by qwerty12 is correct! Well done! :thumbup:



The three characters answer I was thinking of was: lParam=""
Helgef
Posts: 2836
Joined: 17 Jul 2016, 01:02
Contact:

Re: Code Puzzle Thread

28 Sep 2017, 01:28

Great! :thumbup:
qwerty12 is now in the lead with 3 points :clap:
Puzzle submition is open for anyone again (assuming qwerty12 declines the privilege ;) ).
User avatar
Xeo786
Posts: 180
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Code Puzzle Thread

01 Nov 2017, 06:39

It took me 20 minutes .. :think: and luck

Code: [Select all] [Expand] [Download] (Untitled.ahk)GeSHi © Codebox Plus



ops sorry didn't see there are more pages ..... it has been solved already :headwall:
"When there is no gravity, there is absolute vacuum" -Game changer theory
Helgef
Posts: 2836
Joined: 17 Jul 2016, 01:02
Contact:

Re: Code Puzzle Thread

01 Nov 2017, 06:54

Hello Xeo786 :wave:
ops sorry didn't see there are more pages

No problems, I'm glad to see more suggestions on solutions. Your solution is not quite correct, although you have right Idea :thumbup:

A note to all:
Please feel free to submit a new puzzle :) You are also welcome to PM me if you have doubts or questions about a puzzle idea.

Cheers.
User avatar
derz00
Posts: 464
Joined: 02 Feb 2016, 17:54
GitHub: derz00
Location: Middle of the round cube

Re: Code Puzzle Thread

01 Nov 2017, 07:39

May a puzzle be in Python? :P lol

Helgef wrote:No


All right, it's here. https://autohotkey.com/boards/viewtopic.php?f=23&t=39267
Last edited by derz00 on 01 Nov 2017, 10:03, edited 1 time in total.
try it and see
...
User avatar
Xeo786
Posts: 180
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Code Puzzle Thread

01 Nov 2017, 07:46

so Here is new Puzzle ............. its is a Loop Parse Puzzle :

Its a Traveling Script posted below.... Places are defined as A B C D , and D is connected to Place A so script choose randomly to travel forward or backward but can't jump from A to C it has to travel B then C so all places are connect as loop/circle;

You can only change two line to make this script work, lines with [editable line] Tag :trollface:

Required: You can't travel to Same Place and Script has to travel trough all places.

trick is hidden inside these two lines you have to figure out :think:

Code: [Select all] [Expand] [Download] (Loop Parse Puzzle.ahk)GeSHi © Codebox Plus

"When there is no gravity, there is absolute vacuum" -Game changer theory
Helgef
Posts: 2836
Joined: 17 Jul 2016, 01:02
Contact:

Re: Code Puzzle Thread

01 Nov 2017, 09:47

derz00 wrote:May a puzzle be in Python? :P lol

No :D (Maybe in the Other Programming Languages forum)
Xeo786 wrote:so Here is new Puzzle ............. its is a Loop Parse Puzzle :

Great! :thumbup:
User avatar
Xtra
Posts: 1033
Joined: 02 Oct 2015, 12:15

Re: Code Puzzle Thread

01 Nov 2017, 11:40

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Helgef
Posts: 2836
Joined: 17 Jul 2016, 01:02
Contact:

Re: Code Puzzle Thread

01 Nov 2017, 13:35

So we are suposed to go A->B->C->D->A->B->... ?

Edit 1: Minor adjustment of Xtra's code,

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


Edit 2:
Another way would be to ignore the variables Place_X, and just define the appropriate strings, a bit of cheat I guess,

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

User avatar
Xeo786
Posts: 180
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Code Puzzle Thread

02 Nov 2017, 00:07

Xtra's Code stop working at place_D and keep traveling to same place ;)

Helgef wrote:So we are suposed to go A->B->C->D->A->B->... ?

No no as defined destination and connection (A connected to B & D) (B connected to A & C) (C connected to B&D) (D connected to A & C)
so script choose randomly to travel forward or backward. i.e. from A it can randomly choose to travel back to D or forward to B

Code: [Select all] [Download] (Untitled.ahk)GeSHi © Codebox Plus

loop, parse, % pasring_Text := i++ != "" ? ((mod(i,4)+1)=1?(Random_place=1?Place_D:Place_B):(mod(i,4)+1)=2?(Random_place=1?Place_A:Place_C):(mod(i,4)+1)=3?(Random_place=1?Place_B:Place_D):(mod(i,4)+1)=4?(Random_place=1?Place_C:Place_A):""):"", `n, `r   ;[editable line] you can only define pasring Text variable here

This can be solved by above way :angel: but as line said "you can only define parsing Text variable" not variables and conditions :terms:

this can be solved by defining single variable "loop, parse, here, `n, `r"
I bet solution will blow your mind.... you would say WT* how is it even working.... :HeHe:
Image
"When there is no gravity, there is absolute vacuum" -Game changer theory
User avatar
nnnik
Posts: 2687
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: Code Puzzle Thread

02 Nov 2017, 01:34

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


My solution. ( The code I changed is equivalent to what you wrote before )
BTW in your code:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Recommends AHK Studio
User avatar
Xeo786
Posts: 180
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Code Puzzle Thread

02 Nov 2017, 02:14

nnnik you have changed the whole code ....but how your half post is not visible :wtf: ?...... where you mentioned these hidden/blur variable :bravo: .
Now I can see the 2nd half :P
"When there is no gravity, there is absolute vacuum" -Game changer theory
Helgef
Posts: 2836
Joined: 17 Jul 2016, 01:02
Contact:

Re: Code Puzzle Thread

02 Nov 2017, 02:30

I see, cool one. :thumbup:
Xeo786, am I correct to interpret your last post as nnnik's last code is the solution and should be credited a point?
User avatar
Xeo786
Posts: 180
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Code Puzzle Thread

02 Nov 2017, 02:47

Helgef wrote:I see, cool one. :thumbup:
Xeo786, am I correct to interpret your last post as nnnik's last code is the solution and should be credited a point?

Yah One point goes for nnnik. :D
"When there is no gravity, there is absolute vacuum" -Game changer theory
Helgef
Posts: 2836
Joined: 17 Jul 2016, 01:02
Contact:

Re: Code Puzzle Thread

02 Nov 2017, 03:04

Excellent, I have updated the score. Now, if you want nnnik, it is your privilege to submit a new puzzle for an additonal point, within some unspecified time frame ;)

Cheers.
Helgef
Posts: 2836
Joined: 17 Jul 2016, 01:02
Contact:

Re: Code Puzzle Thread

04 Dec 2017, 18:36

Puzzle 8 - Minimise the min
Puzzle objective: Modify the function Min(List*) such that it runs about 50 % faster in the special test case in the code box below.
Puzzle rules: You are only allowed to edit the function Min(List*), you cannot modify any of the marked lines in the function. The marked lines, that is the for-loop, must run and determine the result. You are not allowed to modify the contents of the object refered to by the variable List. The function must work in any case the original does, but only needs to be faster in the test case.
Code:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


Original function credits: [Function] Min/Max including with Associative Arrays

For reference, on my PC, the test case takes about 16 ms. PC performance vary so please submit any improvements.

Cheers.
rommmcek
Posts: 317
Joined: 15 Aug 2014, 15:18

Re: Code Puzzle Thread

07 Dec 2017, 02:04

Puzzle8:
Replacing the line List._NewEnum().Next(element, X) with

Code: [Select all] [Download] GeSHi © Codebox Plus

List._NewEnum().Next(, !X ? X : "")
I gain ~8% on speed, replacing it with

Code: [Select all] [Download] GeSHi © Codebox Plus

	for k, l in List
k>50 ? x:=l : ""
I gain ~25%, well still far away from the goal, but at least I tried!
Bye!
Helgef
Posts: 2836
Joined: 17 Jul 2016, 01:02
Contact:

Re: Code Puzzle Thread

07 Dec 2017, 13:20

Hello rommmcek :wave: . Your second try is good, but not quite there, you should think about why that improves the performance, then you will find a way to improve it further.

Cheers.

Return to “Offtopic”

Who is online

Users browsing this forum: No registered users and 5 guests