Warning: session_start(): open(/var/lib/php/sessions/sess_rinhvu6bl33ht6np4foahcksak, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!752
!include #1003283 // class C
sclass OccTree {
int count;
new HashMap followUp;
void add(L script) {
OccTree node = this;
++count;
for (C c : script)
(node = node.followUp(c)).count++;
}
OccTree followUp(C c) {
OccTree node = followUp.get(c);
if (node == null)
followUp.put(c, node = new OccTree);
ret node;
}
C randomChoice() {
MultiSet ms = new MultiSet(false);
for (C c : keys(followUp))
ms.add(c, followUp.get(c).count);
ret msOneOf(ms);
}
}
p {
L script = poemToC("#1003260");
new OccTree tree;
tree.add(script);
tree.add(poemToC("Usr: hello"));
tree.add(poemToC("Usr: hallo"));
//printStructure(tree);
print(asciiHeading("Random"));
print(unparsePoem(poemFromC(randomScript(tree))));
}
static L randomScript(OccTree tree) {
C c;
new L script;
while ((c = tree.randomChoice()) != null) {
script.add(c);
tree = tree.followUp(c);
}
ret script;
}