Rosetta Code/Tasks without examples: Difference between revisions
Rosetta Code/Tasks without examples (view source)
Revision as of 18:57, 3 February 2024
, 3 months ago→{{header|Wren}}: Various changes including some to accommodate changes to the HTML.
Thundergnat (talk | contribs) m (→{{header|Raku}}: New URL for relocated site) |
(→{{header|Wren}}: Various changes including some to accommodate changes to the HTML.) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 437:
const Base = "http://rosettacode.org/wiki/"
const Limit = 3 # number of tasks to print out.
let re2 = re("""(?s)using any language you may know.</div>(.*?)<
for i, task in tasks:
var matches: array[2, string]
Line 882:
{{libheader|Wren-pattern}}
An embedded program so we can use the libcurl library.
<syntaxhighlight lang="
import "./pattern" for Pattern
Line 921:
var unescs = [
["_", " "],
["\%
["\%27", "'"],
["\%C3\%A9", "é"],
Line 937:
}
var url = "
var content = getContent.call(url)
var p1 = Pattern.new("<li><a href/=\"//wiki//[+1^\"]\"")
Line 944:
var tasks = matches.map { |m| m.capsText[0] }.toList
for (task in tasks.take(3)) { // just show the first 3 say
var taskUrl = "
var html = getContent.call(taskUrl)
var text = "using any language you may know.</div>"
var start = html.indexOf(text)
var end = html.indexOf("<
html = html[start + text.count...end]
text = p2.replaceAll(html, "").replace(" ", "").trim()
Line 957:
<br>
which we embed in the following C program, build and run.
<syntaxhighlight lang="c">/* gcc
#include <stdio.h>
Line 1,131:
WrenVM* vm = wrenNewVM(&config);
const char* module = "main";
const char* fileName = "
char *script = readFile(fileName);
WrenInterpretResult result = wrenInterpret(vm, module, script);
Line 1,154:
****** 100 doors ******
There are 100 doors in a row that are all initially closed.
You make 100 passes by the doors.
The first time through, visit every door and toggle the door (if the door is closed, open it; if it is open, close it).
The second time, only visit every 2nd door (door #2, #4, #6, ...), and toggle it.
The third time, visit every 3rd door (door #3, #6, #9, ...), etc, until you only visit the 100th door.
Line 1,165:
Answer the question: what state are the doors in after the last pass? Which are open, which are closed?
Alternate:
As noted in this page's discussion page, the only doors that remain open are those whose numbers are perfect squares.
Opening only those doors is an optimization that may also be expressed;
however, as should be obvious, this defeats the intent of comparing implementations across programming languages.
Line 1,174:
The Problem
The task
Show and compare the computed probabilities of success for the two strategies, here, on this page.
Line 1,198:
References
****** 15 puzzle game ******
Line 1,209:
Implement the Fifteen Puzzle Game.
The 15-puzzle is also known as:
Related Tasks
</pre>
|