Advanced

Re: GC9NW86 - Challenge to cover 25% of the land area of the US

[Resolved] GC9NW86 - Challenge to cover 25% of the land area of the US
February 24, 2022 03:33AM
This challenge is a derivation of the electoral college challenge. A find in each state or territory is worth the land area of that area. Goal is to pass 25% of the land area of the entire US & territories

Source wikipedia:
 Alaska 570,640.95
 Texas 261,231.71
 California 155,779.22
 Montana 145,545.80
 New Mexico 121,298.15
 Arizona 113,594.08
 Nevada 109,781.18
 Colorado 103,641.89
 Oregon 95,988.01
 Wyoming 97,093.14
 Michigan 56,538.90
 Minnesota 79,626.74
 Utah 82,169.62
 Idaho 82,643.12
 Kansas 81,758.72
 Nebraska 76,824.17
 South Dakota 75,811.00
 Washington 66,455.52
 North Dakota 69,000.80
 Oklahoma 68,594.92
 Missouri 68,741.52
 Florida 53,624.76
 Wisconsin 54,157.80
 Georgia 57,513.49
 Illinois 55,518.93
 Iowa 55,857.13
 New York 47,126.40
 North Carolina 48,617.91
 Arkansas 52,035.48
 Alabama 50,645.33
 Louisiana 43,203.90
 Mississippi 46,923.27
 Pennsylvania 44,742.70
 Ohio 40,860.69
 Virginia 39,490.09
 Tennessee 41,234.90
 Kentucky 39,486.34
 Indiana 35,826.11
 Maine 30,842.92
 South Carolina 30,060.70
 West Virginia 24,038.21
 Maryland 9,707.24
 Hawaii 6,422.63
 Massachusetts 7,800.06
 Vermont 9,216.66
 New Hampshire 8,952.65
 New Jersey 7,354.22
 Connecticut 4,842.36
 Delaware 1,948.54
 Rhode Island 1,033.81
 District of Columbia 61.05
 Puerto Rico 3,423.78
 Northern Mariana Islands 182.33
 United States Virgin Islands 134.32
 American Samoa 76.46
 Guam 209.80
Minor Outlying Islands 16.00
Total US 3,535,948.13
Re: GC9NW86 - Challenge to cover 25% of the land area of the US
February 24, 2022 11:37AM
Before a scriptwriter starts spending time on this we would like to know if a reviewer will publish this challenge criteria.

Please ask advise from your reviewer

If you ask by posting a reviewer note on the cache page, remember that you have to submit the cache for review for the reviewer to see your question.
Re: GC9NW86 - Challenge to cover 25% of the land area of the US
February 25, 2022 04:38AM
Challenge approved by reviewer
Re: GC9NW86 - Challenge to cover 25% of the land area of the US
March 05, 2022 03:04AM
Challenge criteria was approved and awaiting checker creation for publishing
Re: GC9NW86 - Challenge to cover 25% of the land area of the US
March 05, 2022 11:42AM
Sorry forgot to place this topic on new script required for a scriptwriter to spent time on this
Re: GC9NW86 - Challenge to cover 25% of the land area of the US
March 05, 2022 06:15PM
No worries.

As I stated initially this is a simple derivation of the electoral college challenge but using land area instead of electoral college votes. if this is done through some form of lookup table or file I'd be happy to do the cut and paste.

Thanks
Re: GC9NW86 - Challenge to cover 25% of the land area of the US
March 19, 2022 04:01PM
So looks like no one was picking this up so I took the liberties of trying.I downloaded the source of the electoral college challenge and hacked the script to change it to area. Unfortunately I don't know how to test it. Can one of you please test or release it and see how well/bad I did.

If the votes variable need to be an integer I'm fine with rounding to whole sq. miles. Also I did not know what to do with these but did the work for 51 of the areas:
Puerto Rico 3,423.78
Northern Mariana Islands 182.33
United States Virgin Islands 134.32
American Samoa 76.46
Guam 209.80
Minor Outlying Islands 16.00

Thanks

Start .lua file copied from PCG-LUA-script-1172.lua
-----------------
local args={...}
local conf = args[1].config
local profileName = args[1].profileName
local profileId = args[1].profileId
local filter = {}
PGC.print("Got profile name: ", profileName, "\n")
debug = false

if (conf.VotesNeeded ~= nil) then
VotesNeeded = conf.VotesNeeded
PGC.print("Votes Needed: " .. VotesNeeded .. "\n")
else
VotesNeeded = 883987.04
PGC.print("VotesNeeded parameter missing!!\nDefaulting to 88397.0325 for 25% of the US area\n\n")
end

filter.country="United States"

--- these are probably not used for area challenges, but leaving them for flexibility
if (conf.difficulties ~= nil) then filter.difficulties = conf.difficulties end
if (conf.terrains ~= nil) then filter.terrains = conf.terrains end
if (conf.foundOnOrAfter) ~= nil then filter.minVisitDate = conf.foundOnOrAfter end
if (conf.foundOnOrBefore ~= nil) then filter.maxVisitDate =conf.foundOnOrBefore end
if (conf.hiddenOnOrAfter) ~= nil then filter.minHiddenDate = conf.hiddenOnOrAfter end
if (conf.hiddenOnOrBefore ~= nil) then filter.maxHiddenDate = conf.hiddenOnOrBefore end
PGC.print("\nfilter: ")
PGC.print(filter)

function spairs(t, order)
-- collect the keys
local keys = {}
for k in pairs(t) do keys[#keys+1] = k end

-- if order function given, sort by it by passing the table and keys a, b,
-- otherwise just sort the keys
if order then
table.sort(keys, function(a,b) return order(t, a, b) end)
else
table.sort(keys)
end

-- return the iterator function
local i = 0
return function()
i = i + 1
if keys then
return keys, t[keys]
end
end
end

function remove_crazy_caches(finds)
PGC.print("Omitted caches:\n")
local crazy_caches = PGC.GetBookmarklist("BMAFMJR", {} ) or {}
local codes = {}
for _,code in ipairs(crazy_caches) do
codes
 = true
  end
  local res={}
  for _,f in ipairs(finds) do
    if not codes[f.gccode] and f.type~="Locationless (Reverse) Cache" then
      table.insert(res, f)
    else
      PGC.print(f.cache_name .. " " .. f.gccode .. " http://coord.info/"; .. f.gccode .. " " .. f.region .. "\n" )
    end
  end
  return res
end    


local WinCount=0
local LossCount=0

States = {}
States["Alabama"] ={}
States["Alabama"]["Name"] =  "Alabama"
States["Alabama"]["Status"] = "Not Found"
States["Alabama"]["Votes"] = "50645.33"
States["Alaska"] ={}
States["Alaska"]["Name"] =  "Alaska"
States["Alaska"]["Status"] = "Not Found"
States["Alaska"]["Votes"] = "570640.95"
States["Arizona"] ={}
States["Arizona"]["Name"] =  "Arizona"
States["Arizona"]["Status"] = "Not Found"
States["Arizona"]["Votes"] = "113594.08"
States["Arkansas"] ={}
States["Arkansas"]["Name"] =  "Arkansas"
States["Arkansas"]["Status"] = "Not Found"
States["Arkansas"]["Votes"] = "52035.48"
States["California"] ={}
States["California"]["Name"] =  "California"
States["California"]["Status"] = "Not Found"
States["California"]["Votes"] = "155779.22"
States["Colorado"] ={}
States["Colorado"]["Name"] =  "Colorado"
States["Colorado"]["Status"] = "Not Found"
States["Colorado"]["Votes"] = "103641.89"
States["Connecticut"] ={}
States["Connecticut"]["Name"] =  "Connecticut"
States["Connecticut"]["Status"] = "Not Found"
States["Connecticut"]["Votes"] = "4842.36"
States["Delaware"] ={}
States["Delaware"]["Name"] =  "Delaware"
States["Delaware"]["Status"] = "Not Found"
States["Delaware"]["Votes"] = "1948.54"
States["District of Columbia"] ={}
States["District of Columbia"]["Name"] =  "District of Columbia"
States["District of Columbia"]["Status"] = "Not Found"
States["District of Columbia"]["Votes"] = "61.05
States["Florida"] ={}
States["Florida"]["Name"] =  "Florida"
States["Florida"]["Status"] = "Not Found"
States["Florida"]["Votes"] = "53624.76"
States["Georgia"] ={}
States["Georgia"]["Name"] =  "Georgia"
States["Georgia"]["Status"] = "Not Found"
States["Georgia"]["Votes"] = "57513.49"
States["Hawaii"] ={}
States["Hawaii"]["Name"] =  "Hawaii"
States["Hawaii"]["Status"] = "Not Found"
States["Hawaii"]["Votes"] = "6422.63"
States["Idaho"] ={}
States["Idaho"]["Name"] =  "Idaho"
States["Idaho"]["Status"] = "Not Found"
States["Idaho"]["Votes"] = "82643.12"
States["Illinois"] ={}
States["Illinois"]["Name"] =  "Illinois"
States["Illinois"]["Status"] = "Not Found"
States["Illinois"]["Votes"] = "55518.93"
States["Indiana"] ={}
States["Indiana"]["Name"] =  "Indiana"
States["Indiana"]["Status"] = "Not Found"
States["Indiana"]["Votes"] = "35826.11"
States["Iowa"] ={}
States["Iowa"]["Name"] =  "Iowa"
States["Iowa"]["Status"] = "Not Found"
States["Iowa"]["Votes"] = "55857.13"
States["Kansas"] ={}
States["Kansas"]["Name"] =  "Kansas"
States["Kansas"]["Status"] = "Not Found"
States["Kansas"]["Votes"] = "81758.72"
States["Kentucky"] ={}
States["Kentucky"]["Name"] =  "Kentucky"
States["Kentucky"]["Status"] = "Not Found"
States["Kentucky"]["Votes"] = "39486.34"
States["Louisiana"] ={}
States["Louisiana"]["Name"] =  "Louisiana"
States["Louisiana"]["Status"] = "Not Found"
States["Louisiana"]["Votes"] = "43203.90"
States["Maine"] ={}
States["Maine"]["Name"] =  "Maine"
States["Maine"]["Status"] = "Not Found"
States["Maine"]["Votes"] = "30842.92"
States["Maryland"] ={}
States["Maryland"]["Name"] =  "Maryland"
States["Maryland"]["Status"] = "Not Found"
States["Maryland"]["Votes"] = "9707.24"
States["Massachusetts"] ={}
States["Massachusetts"]["Name"] =  "Massachusetts"
States["Massachusetts"]["Status"] = "Not Found"
States["Massachusetts"]["Votes"] = "7800.06"
States["Michigan"] ={}
States["Michigan"]["Name"] =  "Michigan"
States["Michigan"]["Status"] = "Not Found"
States["Michigan"]["Votes"] = "56538.90"
States["Minnesota"] ={}
States["Minnesota"]["Name"] =  "Minnesota"
States["Minnesota"]["Status"] = "Not Found"
States["Minnesota"]["Votes"] = "79626.74"
States["Mississippi"] ={}
States["Mississippi"]["Name"] =  "Mississippi"
States["Mississippi"]["Status"] = "Not Found"
States["Mississippi"]["Votes"] = "46923.27"
States["Missouri"] ={}
States["Missouri"]["Name"] =  "Missouri"
States["Missouri"]["Status"] = "Not Found"
States["Missouri"]["Votes"] = "68741.52"
States["Montana"] ={}
States["Montana"]["Name"] =  "Montana"
States["Montana"]["Status"] = "Not Found"
States["Montana"]["Votes"] = "145545.80"
States["Nebraska"] ={}
States["Nebraska"]["Name"] =  "Nebraska"
States["Nebraska"]["Status"] = "Not Found"
States["Nebraska"]["Votes"] = "76824.17"
States["Nevada"] ={}
States["Nevada"]["Name"] =  "Nevada"
States["Nevada"]["Status"] = "Not Found"
States["Nevada"]["Votes"] = "109781.18"
States["New Hampshire"] ={}
States["New Hampshire"]["Name"] =  "New Hampshire"
States["New Hampshire"]["Status"] = "Not Found"
States["New Hampshire"]["Votes"] = "8952.65"
States["New Jersey"] ={}
States["New Jersey"]["Name"] =  "New Jersey"
States["New Jersey"]["Status"] = "Not Found"
States["New Jersey"]["Votes"] = "7354.22"
States["New Mexico"] ={}
States["New Mexico"]["Name"] =  "New Mexico"
States["New Mexico"]["Status"] = "Not Found"
States["New Mexico"]["Votes"] = "121298.15"
States["New York"] ={}
States["New York"]["Name"] =  "New York"
States["New York"]["Status"] = "Not Found"
States["New York"]["Votes"] = "47126.40"
States["North Carolina"] ={}
States["North Carolina"]["Name"] =  "North Carolina"
States["North Carolina"]["Status"] = "Not Found"
States["North Carolina"]["Votes"] = "48617.91"
States["North Dakota"] ={}
States["North Dakota"]["Name"] =  "North Dakota"
States["North Dakota"]["Status"] = "Not Found"
States["North Dakota"]["Votes"] = "69000.89"
States["Ohio"] ={}
States["Ohio"]["Name"] =  "Ohio"
States["Ohio"]["Status"] = "Not Found"
States["Ohio"]["Votes"] = "40860.69"
States["Oklahoma"] ={}
States["Oklahoma"]["Name"] =  "Oklahoma"
States["Oklahoma"]["Status"] = "Not Found"
States["Oklahoma"]["Votes"] = "68594.92"
States["Oregon"] ={}
States["Oregon"]["Name"] =  "Oregon"
States["Oregon"]["Status"] = "Not Found"
States["Oregon"]["Votes"] = "95988.01"
States["Pennsylvania"] ={}
States["Pennsylvania"]["Name"] =  "Pennsylvania"
States["Pennsylvania"]["Status"] = "Not Found"
States["Pennsylvania"]["Votes"] = "44742.70"
States["Rhode Island"] ={}
States["Rhode Island"]["Name"] =  "Rhode Island"
States["Rhode Island"]["Status"] = "Not Found"
States["Rhode Island"]["Votes"] = "1033.81"
States["South Carolina"] ={}
States["South Carolina"]["Name"] =  "South Carolina"
States["South Carolina"]["Status"] = "Not Found"
States["South Carolina"]["Votes"] = "30060.70"
States["South Dakota"] ={}
States["South Dakota"]["Name"] =  "South Dakota"
States["South Dakota"]["Status"] = "Not Found"
States["South Dakota"]["Votes"] = "75811.00"
States["Tennessee"] ={}
States["Tennessee"]["Name"] =  "Tennessee"
States["Tennessee"]["Status"] = "Not Found"
States["Tennessee"]["Votes"] = "41234.90"
States["Texas"] ={}
States["Texas"]["Name"] =  "Texas"
States["Texas"]["Status"] = "Not Found"
States["Texas"]["Votes"] = "261231.71"
States["Utah"] ={}
States["Utah"]["Name"] =  "Utah"
States["Utah"]["Status"] = "Not Found"
States["Utah"]["Votes"] = "82169.62"
States["Vermont"] ={}
States["Vermont"]["Name"] =  "Vermont"
States["Vermont"]["Status"] = "Not Found"
States["Vermont"]["Votes"] = "9216.66"
States["Virginia"] ={}
States["Virginia"]["Name"] =  "Virginia"
States["Virginia"]["Status"] = "Not Found"
States["Virginia"]["Votes"] = "39490.09"
States["Washington"] ={}
States["Washington"]["Name"] =  "Washington"
States["Washington"]["Status"] = "Not Found"
States["Washington"]["Votes"] = "66455.52"
States["West Virginia"] ={}
States["West Virginia"]["Name"] =  "West Virginia"
States["West Virginia"]["Status"] = "Not Found"
States["West Virginia"]["Votes"] = "24038.21"
States["Wisconsin"] ={}
States["Wisconsin"]["Name"] =  "Wisconsin"
States["Wisconsin"]["Status"] = "Not Found"
States["Wisconsin"]["Votes"] = "54157.80"
States["Wyoming"] ={}
States["Wyoming"]["Name"] =  "Wyoming"
States["Wyoming"]["Status"] = "Not Found"
States["Wyoming"]["Votes"] = "97093.14"
if (debug == true) then
	PGC.print("\nStates:\n")
	PGC.print(States)
end

local finds = remove_crazy_caches( PGC.GetFinds( profileId, { fields = {'gccode', 'cache_name', 'visitdate', 'region', 'type'}, order = 'NEWESTFIRST', filter = filter  }))

PGC.print(finds)

for _,y in ipairs(finds) do							-- Loop through the found caches and updat States 
  States[y["region"]]["Status"]="Found" 
end

votecount = 0
local html = ""
local log=""
local logFirstLine = "Unfortunately you have not visited enough states greater than 25% of the Area of the United States.   Here are the states you have: \br\br"
local htmlFirstLine = "Unfortunately you have not visited enough states greater than 25% of the Area of the United States.   Here are the states you have:  <br><br>"
 
for _,v in spairs(States, function(t,a,c) return c > a end) do
  
  if (v["Status"] == 'Found') then 
    if v["type"] ~= 'Locationless (Reverse) Cache' then
      WinCount=WinCount+1
      votecount = votecount + v["Votes"]
      html = html .."<b>" .. v["Name"] .. "</b> " .. v["Votes"] .. " votes. <br>"
      log=log  .."**" .. v["Name"] .. "** " .. v["Votes"] .. " votes. \n"
      --if (votecount > VotesNeeded) then
      --  ok = true
      --  logFirstLine  = "#WOOT WOOT, I WON!!#\nI needed " .. VotesNeeded .. " to win and have " .. votecount .. " sq miles of the possible 3,535,948.13 sq miles\n\n" 
      --  htmlFirstLine = "<b>WOOT WOOT, I WON!!</b><br>I needed " .. VotesNeeded .. " to win and have " .. votecount .. " sq miles of the possible 3,535,948.13 sq miles <br><br>" 
      --end
      if (debug == true) then
        PGC.print("\n" .. v["Status"] .. ": " .. v["Name"] .. " " .. v["Votes"] .. " votes. Running Total: " .. votecount)
      end
    end
  else
   	LossCount=LossCount +1 
  end 
end

if (votecount > VotesNeeded) then
  ok = true
  logFirstLine  = "#WOOT WOOT, I WON!!#\nI needed " .. VotesNeeded .. " to win and have " .. votecount .. " sq miles of the possible 3,535,948.13 sq miles\n\n" 
  htmlFirstLine = "<b>WOOT WOOT, I WON!!</b><br>I needed " .. VotesNeeded .. " to win and have " .. votecount .. " sq miles of the possible 3,535,948.13 sq miles <br><br>" 
else
  ok= false
  html = html .. "<br><br><Strong>Your found area is " .. votecount .. " from " .. WinCount .. " states.</strong><br><br>You need to travel to the following states:<br><br>"
  for _,v in spairs(States, function(t,a,c) return c > a end) do

    if (v["Status"] ~= 'Found') then 
      html = html ..'<b><font color="red">' .. v["Name"] .. '</font></b> ' .. v["Votes"] .. ' votes lost. <br>'
    end
  end
end

log = logFirstLine .. log
html = htmlFirstLine .. html

return { ok = ok, log = log, html = html }
Re: GC9NW86 - Challenge to cover 25% of the land area of the US
March 19, 2022 04:11PM
One of the things I really appreciate from these checkers is the maps showing my finds would be totally cool to have the find map displayed. If possible
Re: GC9NW86 - Challenge to cover 25% of the land area of the US
March 30, 2022 04:11PM
Here is a checker:
https://project-gc.com/Challenges/GC9NW86/67432
Please say if this is good for you.
Apologies for the wait, I know me and the other scriptwriters are very busy at the moment.
I did write the script myself, not from you're attempt since it was easier for me, but if you want, you can look at the source to see any differences :)
I have used the figures you stated in your post, and I have also excluded moving caches and locationless caches. A map is also included.
Re: GC9NW86 - Challenge to cover 25% of the land area of the US
March 30, 2022 10:33PM
@DrAcorn
I think you've excluded only the new locationless caches, not the old ones? Try running "IT-gubben" through the checker, it shows lots of locationless caches.
Re: GC9NW86 - Challenge to cover 25% of the land area of the US
March 31, 2022 06:36PM
Good spot, now corrected
Re: GC9NW86 - Challenge to cover 25% of the land area of the US
April 03, 2022 07:05PM
Awesome thanks DrAcorn & Pleu!

Works as expected. Guess I had a typo in my attempt at hacking the electoral college script so no problem with a new one I do the same thing in my work as well.

Two requests if they are not too difficult to add:

1) When a person fails could you print out the percentage they have? I used CatClawsNerd The numbers seem a bit daunting when they get big.

2) I love the project-gc maps would it be possible to display visually what they qualify for.

Regardless of these enhancements. Thanks so much! Will go out and hide the container today and type up the description.
Re: GC9NW86 - Challenge to cover 25% of the land area of the US
April 03, 2022 08:55PM
I have added your first request, unfortunately, I couldn't find a way to implement the second one, since I don't believe polygons are available for some of the areas to use on the map. I hope this is still okay for you.
Re: GC9NW86 - Challenge to cover 25% of the land area of the US
April 03, 2022 09:38PM
No worries. Thanks for thinking about it. The % is perfect. Will place the container and get published.
Re: GC9NW86 - Challenge to cover 25% of the land area of the US
April 04, 2022 05:52PM
Cache was published this morning but looks like the link did not reset and no text is included either did I do something wrong?
Re: GC9NW86 - Challenge to cover 25% of the land area of the US
April 05, 2022 10:42AM
It looks okay to me?
Sorry, only registered users may post in this forum.

Click here to login