Rosetta Code/Count examples: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (Update link) |
No edit summary |
||
Line 2,121: | Line 2,121: | ||
s)) |
s)) |
||
</lang> |
</lang> |
||
=={{header|Ring}}== |
|||
<lang ring> |
|||
# Project: Rosetta Code/Count examples |
|||
# Date : 2018/07/11 |
|||
# Author: Gal Zsolt (~ CalmoSoft ~) |
|||
# Email : <calmosoft@gmail.com> |
|||
load "stdlib.ring" |
|||
ros= download("http://rosettacode.org/wiki/Category:Programming_Tasks") |
|||
pos = 1 |
|||
num = 0 |
|||
totalros = 0 |
|||
rosname = "" |
|||
rostitle = "" |
|||
while true |
|||
nr = searchstring(ros,'<li><a href="/wiki/',pos) |
|||
if nr = 0 |
|||
exit |
|||
else |
|||
pos = nr + 1 |
|||
ok |
|||
nr = searchname(nr) |
|||
nr = searchtitle(nr) |
|||
end |
|||
see nl |
|||
see "Total: " + totalros + " examples." + nl |
|||
func searchstring(str,substr,n) |
|||
newstr=right(str,len(str)-n+1) |
|||
nr = substr(newstr, substr) |
|||
if nr = 0 |
|||
return 0 |
|||
else |
|||
return n + nr -1 |
|||
ok |
|||
func searchname(sn) |
|||
nr2 = searchstring(ros,'">',sn) |
|||
nr3 = searchstring(ros,"</a></li>",sn) |
|||
rosname = substr(ros,nr2+2,nr3-nr2-2) |
|||
return sn |
|||
func searchtitle(sn) |
|||
st = searchstring(ros,"title=",sn) |
|||
rostitle = substr(ros,sn+19,st-sn-21) |
|||
rostitle = "rosettacode.org/wiki/" + rostitle |
|||
rostitle = download(rostitle) |
|||
sum = count(rostitle,"Edit section:") |
|||
num = num + 1 |
|||
see "" + num + ". " + rosname + ": " + sum + " examples." + nl |
|||
totalros = totalros + 1 |
|||
return sn |
|||
func count(cstring,dstring) |
|||
sum = 0 |
|||
while substr(cstring,dstring) > 0 |
|||
sum = sum + 1 |
|||
cstring = substr(cstring,substr(cstring,dstring)+len(string(sum))) |
|||
end |
|||
return sum |
|||
</lang> |
|||
Output: |
|||
<pre> |
|||
1. 100 doors: 331 examples. |
|||
2. 15 Puzzle Game: 48 examples. |
|||
3. 15 puzzle solver: 18 examples. |
|||
4. 2048: 40 examples. |
|||
5. 24 game: 95 examples. |
|||
6. 24 game/Solve: 59 examples. |
|||
7. 4-rings or 4-squares puzzle: 42 examples. |
|||
8. 9 billion names of God the integer: 54 examples. |
|||
9. 99 Bottles of Beer: 393 examples. |
|||
10. A+B: 250 examples. |
|||
...... |
|||
872. XML/XPath: 54 examples. |
|||
873. Y combinator: 88 examples. |
|||
874. Yahoo! search interface: 20 examples. |
|||
875. Yin and yang: 59 examples. |
|||
876. Zebra puzzle: 58 examples. |
|||
877. Zeckendorf arithmetic: 11 examples. |
|||
878. Zeckendorf number representation: 64 examples. |
|||
879. Zero to the zero power: 100 examples. |
|||
880. Zhang-Suen thinning algorithm: 26 examples. |
|||
881. Zig-zag matrix: 112 examples. |
|||
Total: 27004 examples. |
|||
</pre> |
|||
=={{header|Ruby}}== |
=={{header|Ruby}}== |