Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,16 @@
import rdstdin, re, algorithm, sequtils, strutils
#let templ = readLineFromStdin "Enter your story: "
const templ = """<name> went for a walk in the park. <he or she>
found a <noun>. <name> decided to take it home."""
echo "The story template is:\n", templ
var fields = templ.findAll re"<[^>]+>"
fields.sort(cmp)
fields = deduplicate fields
let values = readLineFromStdin("\nInput a comma-separated list of words to replace the following items\n " & fields.join(",") & ": ").split(",")
var story = templ
for f,v in zip(fields, values).items:
story = story.replace(f, v)
echo "\nThe story becomes:\n\n", story

View file

@ -0,0 +1,11 @@
: madlibs
| story i word |
"" while(System.Console askln dup notEmpty) [ + ] drop ->story
while(story indexOf('<') dup ->i notNull) [
story extract(i, story indexOfFrom('>', i)) ->word
story replaceAll(word, "Word for" . word . System.Console askln) ->story
]
"Your story :" . story println ;

View file

@ -0,0 +1,13 @@
temp="<name> went for a walk in the park. <he or she> found a <noun>. <name> decided to take it home."
k = substr(temp,"<")
while k
replace = substr(temp,k,substr(temp,">")-k + 1)
see "replace:" + replace + " with: "
give with
while k
temp = left(temp,k-1) + with + substr(temp,k + len(replace))
k = substr(temp,replace)
end
k = substr(temp,"<")
end
see temp + nl

View file

@ -0,0 +1,13 @@
var story = ARGF.slurp;
var blanks = Hash.new;
while (var m = /<(.*?)>/.gmatch(story)) {
blanks.append(m[0]);
}
blanks.keys.sort.each { |blank|
var replacement = Sys.scanln("#{blank}: ");
blanks{blank} = replacement;
}
print story.gsub(/<(.*?)>/, {|s1| blanks{s1} });