@verb #8433:"tell_WWW_page" this none this rxdo #9682 @program #8433:"tell_WWW_page" this none this player:tell("Olympics test set") events = {"Ladies' Downhill Alpine Skiing", "Men's 20km Individual Biathlon", "Four Man Bobsleigh", "Men's Free Program Figure Skating", "Men's Short Program Figure Skating", "Men's Ice Hockey", "Women's Ice Hockey", "Individual K90 Nordic Combined"} nations = #120.countries player:tell(dobjstr) athletes = $www:parse_CGI(dobjstr, "athletes") athletes = athletes == E_PROPNF ? 20 | toint(athletes) countries = $www:parse_CGI(dobjstr, "countries") countries = countries == E_PROPNF ? 6 | toint(countries) names = #120.students pays = {} for x in [1..countries] pays = {@pays, {nations[random($)], {}}} nations[pays[$][1] in nations..pays[$][1] in nations] = {} endfor nathletes = athletes while (nathletes > 0) nathletes = nathletes - 1 k = random(length(pays)) name = names[random($)] names[name in names..name in names] = {} pays[k][2] = {@pays[k][2], {name, {}, 0}} endwhile player:tell("") for y in (pays) player:tell("") endfor player:tell("
Athletes", athletes, "Countries", countries, "
", y[1], "") for z in (y[2]) player:tell(z[1], " / ") endfor player:tell("
") "Eliminate countries with no competitors." countries = {} for foo in (pays) if (foo[2] != {}) countries = {@countries, {@foo, 0}} endif endfor if (length(countries) < 3) player:tell("Um, shit, we couldn't generate enough countries or athletes or something. Try again.") return endif sports = {} player:Tell("results.txt file
") player:tell("
")
medals = {"Gold", "Silver", "Bronze"}
values = {10, 5, 1}
for foo in (events)
  medal = 1
  while (medal < 4)
    winners = random(5) == 1 ? random(2) | 1
    names = {"foo"}
    for x in [1..winners]
      "pick a winning country"
      name = "foo"
      while (name in names)
        country = random(length(countries))
        athlete = random(length(countries[country][2]))
        name = countries[country][2][athlete][1]
      endwhile
      names = {@names, name}
      countries[country][3] = countries[country][3] + values[medal]
      countries[country][2][athlete][2] = {@countries[country][2][athlete][2], foo}
      countries[country][2][athlete][3] = countries[country][2][athlete][3] + values[medal]
      player:tell(tostr(medals[medal], " ", foo, " = ", name))
    endfor
    medal = medal + winners
  endwhile
endfor
player:tell("
athletes.txt file
")
for country in (countries)
  for athlete in (country[2])
    player:tell(athlete[1])
    player:tell(country[1])
    player:tell(length(athlete[2]))
    for event in (athlete[2])
      player:tell(event)
    endfor
  endfor
endfor
player:tell("
Expected output
")
sorted = $list_utils:sort_alist(countries, 3)
for x in [0..length(sorted) - 1]
  realpos = length(sorted) - x
  player:tell(x + 1, ". ", sorted[realpos][1], " ", sorted[realpos][3], " points")
endfor
player:tell("")
"Last modified by Dax (#789) on Tue May  3 14:09:37 2005 MDT."
.