DEV Community

Discussion on: 7 challenges for querying with GROQ

Collapse
 
billymoon profile image
Billy Moon • Edited

Great challenges. For most of them my answers were near identical to what's published here, which I think is a testament to the GROQ language itself that there seems to be a kind of natural solution to be arrived at for a specific problem.

I propose another challenge

Challenge 8:

An array of language names, ordered by the length of their longest Pokemon name, languages with longer Pokemon names appearing before shorter Pokemon names.

Answer

Obscured by way of base64 encoding...

atob(`WwogICJmcmVuY2giLAogICJlbmdsaXNoIiwKICAiamFwYW5lc2UiLAogICJjaGluZXNlIgpdCgouLi4gb3IgLi4uCgpbCiAgImVuZ2xpc2giLAogICJmcmVuY2giLAogICJqYXBhbmVzZSIsCiAgImNoaW5lc2UiCl0=`)
Enter fullscreen mode Exit fullscreen mode

Solution

Also obscured by way of base64 encoding...

atob("WwogIHsKICAgICJsYW5ndWFnZSI6ICJlbmdsaXNoIiwKICAgICJsb25nZXN0IjogbGVuZ3RoKCp8b3JkZXIobGVuZ3RoKG5hbWUuZW5nbGlzaCkgZGVzYylbMF0ubmFtZS5lbmdsaXNoKQogIH0sCiAgewogICAgImxhbmd1YWdlIjogImphcGFuZXNlIiwKICAgICJsb25nZXN0IjogbGVuZ3RoKCp8b3JkZXIobGVuZ3RoKG5hbWUuamFwYW5lc2UpIGRlc2MpWzBdLm5hbWUuamFwYW5lc2UpCiAgfSwKICB7CiAgICAibGFuZ3VhZ2UiOiAiY2hpbmVzZSIsCiAgICAibG9uZ2VzdCI6IGxlbmd0aCgqfG9yZGVyKGxlbmd0aChuYW1lLmNoaW5lc2UpIGRlc2MpWzBdLm5hbWUuY2hpbmVzZSkKICB9LAogIHsKICAgICJsYW5ndWFnZSI6ICJmcmVuY2giLAogICAgImxvbmdlc3QiOiBsZW5ndGgoKnxvcmRlcihsZW5ndGgobmFtZS5mcmVuY2gpIGRlc2MpWzBdLm5hbWUuZnJlbmNoKQogIH0sCl18b3JkZXIobG9uZ2VzdCBkZXNjKVtdLmxhbmd1YWdl")
Enter fullscreen mode Exit fullscreen mode