Data update
This commit is contained in:
parent
72eb4943cb
commit
4d5544505c
2347 changed files with 62432 additions and 16731 deletions
35
Task/Amb/Ballerina/amb.ballerina
Normal file
35
Task/Amb/Ballerina/amb.ballerina
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import ballerina/io;
|
||||
|
||||
string[] finalRes = [];
|
||||
|
||||
function amb(string[][] wordsets, string[] res) returns boolean {
|
||||
if wordsets.length() == 0 {
|
||||
finalRes.push(...res);
|
||||
return true;
|
||||
}
|
||||
string s = "";
|
||||
int l = res.length();
|
||||
if l > 0 { s = res[l - 1]; }
|
||||
res.push("");
|
||||
foreach string word in wordsets[0] {
|
||||
res[l] = word;
|
||||
if l > 0 && s[s.length() - 1] != res[l][0] { continue; }
|
||||
if amb(wordsets.slice(1), [...res]) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function main() {
|
||||
var wordsets = [
|
||||
[ "the", "that", "a" ],
|
||||
[ "frog", "elephant", "thing" ],
|
||||
[ "walked", "treaded", "grows" ],
|
||||
[ "slowly", "quickly" ]
|
||||
];
|
||||
|
||||
if amb(wordsets, []) {
|
||||
io:println(string:'join(" ", ...finalRes));
|
||||
} else {
|
||||
io:println("No amb found");
|
||||
}
|
||||
}
|
||||
31
Task/Amb/EasyLang/amb.easy
Normal file
31
Task/Amb/EasyLang/amb.easy
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
func ambtest a$ b$ .
|
||||
if substr a$ len a$ 1 = substr b$ 1 1 : return 1
|
||||
return 0
|
||||
.
|
||||
proc amb &opts$[][] pos prev$ &res$[] &found .
|
||||
if pos = 0
|
||||
found = 1
|
||||
res$[] = [ ]
|
||||
return
|
||||
.
|
||||
for curr$ in opts$[pos][]
|
||||
if prev$ = "" or ambtest curr$ prev$ = 1
|
||||
amb opts$[][] (pos - 1) curr$ res$[] found
|
||||
if found = 1
|
||||
res$[] &= curr$
|
||||
return
|
||||
.
|
||||
.
|
||||
.
|
||||
found = 0
|
||||
return
|
||||
.
|
||||
proc main .
|
||||
sets$[][] = [ [ "the" "that" "a" ] [ "frog" "elephant" "thing" ] [ "walked" "treaded" "grows" ] [ "slowly" "quickly" ] ]
|
||||
h = len sets$[][]
|
||||
amb sets$[][] h "" res$[] found
|
||||
if found = 1
|
||||
print res$[]
|
||||
.
|
||||
.
|
||||
main
|
||||
|
|
@ -82,12 +82,12 @@ public program()
|
|||
new object[]{"walked", "treaded", "grows"},
|
||||
new object[]{"slowly", "quickly"})
|
||||
.seek::(a,b,c,d => joinable(a,b) && joinable(b,c) && joinable(c,d) )
|
||||
.do::(a,b,c,d) { console.printLine(a," ",b," ",c," ",d) }
|
||||
.do::(a,b,c,d) { Console.printLine(a," ",b," ",c," ",d) }
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
console.printLine("AMB is angry")
|
||||
Console.printLine("AMB is angry")
|
||||
};
|
||||
|
||||
console.readChar()
|
||||
Console.readChar()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ val wordsets = [
|
|||
]
|
||||
|
||||
val alljoin = fn words: for[=true] i of len(words)-1 {
|
||||
if words[i][-1] != words[i+1][1]: break = false
|
||||
if words[i][-1] != words[i+1][1]: break val=false
|
||||
}
|
||||
|
||||
# amb expects 2 or more arguments
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue