Advanced

Change History

Once a checker request has been fulfilled and the challenge owner (or checker requester) is satisfied the thread should be moved here by a moderator. Please allow some time before moving the thread, to allow feedback from the requester.

Message: Re: GC7V5NZ - Earth caches in Czechia, every state

Changed By: jpavlik
Change Date: October 05, 2018 05:26PM

Re: GC7V5NZ - Earth caches in Czechia, every state
it's simple
ones you collect all qualified caches and save it in the array by region, you make this loop for making the list:
[code]
for group,groupData in pairs(regionGroups) do
[/code]
but attention, inserting the data to generic array, the pairs iterator returns the data in alphabetic order of keys
[code]
Lua 5.2.4 Copyright (C) 1994-2015 Lua.org, PUC-Rio
> a={}
> a.abc="abc"
> a.der="def"
> a.aaa="aaa"
> a.abc="first"
> a.der="second"
> a.aaa="third"
> print(a)
> for i,v in pairs(a) do print(i,v) end
aaa aaa
third
abc abc
first
der def
second
[/code]
so, you should make a separate list of regions (indexed by numeric keys) :
[code]
if (groupData == nil) then -- create new data structure for Region
groupData = {}
groupData["qual"] = {}
groupData["find_counter"] = 0
regionGroups[groupKey] = groupData
table.insert(regionGroupsList, groupKey) -- added line
[/code]
and get the regions in order by this list:
[code]
for _,group in ipairs(regionGroupsList) do
local groupData=regionGroups[group]
[/code]

Original Message

Author: jpavlik
Date: October 05, 2018 04:52PM

Re: GC7V5NZ - Earth caches in Czechia, every state
it's simple
ones you collect all qualified caches and save it in the array by region, you make this loop for making the list:
[code]
for group,groupData in pairs(regionGroups) do
[/code]
but attention, inserting the data to generic array, the pairs iterator returns the data in alphabetic order of keys
[code]
Lua 5.2.4 Copyright (C) 1994-2015 Lua.org, PUC-Rio
> a={}
> a.abc="abc"
> a.der="def"
> a.aaa="aaa"
> print(a)
> for i,v in pairs(a) do print(i,v) end
aaa aaa
abc abc
der def
[/code]
so, you should make a separate list of regions (indexed by numeric keys) :
[code]
if (groupData == nil) then -- create new data structure for Region
groupData = {}
groupData["qual"] = {}
groupData["find_counter"] = 0
regionGroups[groupKey] = groupData
table.insert(regionGroupsList, groupKey) -- added line
[/code]
and get the regions in order by this list:
[code]
for _,group in ipairs(regionGroupsList) do
local groupData=regionGroups[group]
[/code]