Skip to content

Instantly share code, notes, and snippets.

@mornir
Last active January 3, 2020 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mornir/46d558842c8d0cfcf0bd96a56627af1b to your computer and use it in GitHub Desktop.
Save mornir/46d558842c8d0cfcf0bd96a56627af1b to your computer and use it in GitHub Desktop.
GROQ Pokédex Challenges
// Find the weakest Pokémon overall
*[]{
"overall": base.HP + base.Attack + base.Defense + base["Sp. Attack"] + base["Sp. Defense"] + base.Speed,
"name": name.english,
}|order(overall)[0]
// Return an array containing all and only the Pokémon names
*[].name.english
// Return counts for grass, fire and water types
{
"Grass": count(*["Grass" in type]),
"Fire": count(*["Fire" in type]),
"Water": count(*["Water" in type]),
}
// Return all water type Pokémon
*['Water' in type && length(type) == 1]{
id,
"name": name.english,
base
}|order(base.HP desc)
// Return the percentage of single type Pokémon
{
"percentage": count(*[length(type) == 1]) * 100 / count(*[])
}
// List the Pokémon based on the number of letters in their English name
*[]{
"name": name.english,
"length": length(name.english)
}|order(length desc)
// Group the Pokémon in three categories
*[]|order(base.Attack){
"name": name.english,
"attack": base.Attack,
"evaluation": select(
base.Attack > 124 => "strong",
base.Attack > 83 => "average",
"weak"
)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment