Send in your solution as a private message to me, so that everyone gets a chance to consider the problem before solutions are posted.
Puzzle 17 - A pseudo-pseudo-array
Puzzle description: Doing repeated string concatenations with variables is very fast, but with array elements it is borderline useless in some cases. Hence, sometimes
pseudo-arrays are useful. But since, in v2 we cannot create a variable like
var%expr% := ..., we have to explicitly define each variable in the pseudo-array beforehand. This might not be feasible in some cases, why we need another solution.
Problem example,
Code: Select all
N := 100000
; normal array
a:=['a']
t1 := A_TickCount
loop N
a[1] .= 'a'
t2 := A_TickCount
;pseudo-array
b1:='b'
t3 := A_TickCount
loop N
b%'1'% .= 'b'
t4 := A_TickCount
msgbox 'a:`t' t2-t1 '`nb:`t' t4-t3
Puzzle objective: Create a substitute for the pseudo-array which has similar flexibility and performance. Define
c in the code below and complete the code in the the loop body
Code: Select all
c[1] := 'c' ; define c
t5 := A_TickCount
loop N
; complete the loop
t6 := A_TickCount
When you put the code in the first example you should get something like,
Puzzle rules: You must perform
N number of
.= 'c' such that
c reference a string of length N+1 of c:s. The
index and
name 1 is just an example, your code should work for any reasonable amount of indices/names, even if they are not known when writing the script.
Note1: Puzzle 15 is still unsolved, please consider it too
Cheers.