Skip to content

Instantly share code, notes, and snippets.

@ciscou
Created June 6, 2022 09:02
Show Gist options
  • Save ciscou/c69609575a3116291b02a52515a78e4a to your computer and use it in GitHub Desktop.
Save ciscou/c69609575a3116291b02a52515a78e4a to your computer and use it in GitHub Desktop.
# before running, download and unzip the latest TSV export from https://www.worldcubeassociation.org/results/misc/export.html
# usage: cat WCA_export_Results.tsv | ruby spanish_podia.rb
s = gets
s.chomp!
headers = {}
s.split("\t").each_with_index do |header, i|
headers[header] = i
end
with_podium = {}
all = {}
while s = gets
s.chomp!
row = s.split("\t")
# must be Spanish
next unless row[headers["personCountryId"]] == "Spain"
all[row[headers["personId"]]] = true
# the round must be a final or combined final (see RoundTypes.tsv)
next unless %w[c f].include?(row[headers["roundTypeId"]])
# result must be in top 3 positions
next unless row[headers["pos"]].to_i <= 3
# best must not be DNF / DNS
next unless row[headers["best"]].to_i > 0
with_podium[row[headers["personId"]]] = true
end
puts with_podium.length
puts all.length
puts with_podium.length.fdiv(all.length) * 100.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment