# Count examples

```ruby
var lwp = require('LWP::UserAgent').new(agent => 'Mozilla/5.0');
 
var site = 'https://rosettacode.org';
var list_url = '/mw/api.php?action=query&list=categorymembers&'+
               'cmtitle=Category:Programming_Tasks&cmlimit=500&format=xml';
 
var content = lwp.get(site + list_url).decoded_content;
 
while (var m = content.match(/cm.*?title="(.*?)"/g)) {
    (var slug = m[0]).gsub!(' ', '_');
    var count = lwp.get("#{site}/wiki/#{slug}").decoded_content.count(/toclevel-1/g);
    say "#{m[0]}: #{count} examples";
}
```

#### Output:

```
100 doors: 2180 examples
24 game: 760 examples
24 game/Solve: 450 examples
9 billion names of God the integer: 320 examples
99 Bottles of Beer: 2330 examples
A+B: 1800 examples
ABC Problem: 720 examples
Abstract type: 680 examples
...
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://trizen.gitbook.io/sidef-lang/programming_tasks/r/rosetta-code/count_examples.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
