Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
|
|
@ -0,0 +1,35 @@
|
|||
BEGIN # Sailors, coconuts a and a monkey problem - translation of Kotlin #
|
||||
|
||||
INT coconuts := 11;
|
||||
FOR ns FROM 2 TO 9 DO
|
||||
[ 1 : ns ]INT hidden; FOR i FROM 1 TO UPB hidden DO hidden[ i ] := 0 OD;
|
||||
coconuts := ( ( coconuts OVER ns ) * ns ) + 1;
|
||||
BOOL next ns := FALSE;
|
||||
WHILE NOT next ns DO
|
||||
INT nc := coconuts;
|
||||
BOOL break s := FALSE;
|
||||
FOR s TO ns WHILE NOT next ns AND NOT break s DO
|
||||
IF nc MOD ns = 1 THEN
|
||||
hidden[ s ] := nc OVER ns;
|
||||
nc -:= hidden[ s ] + 1;
|
||||
IF s = ns AND nc MOD ns = 0 THEN
|
||||
print( ( whole( ns, 0 ), " sailors require a minimum of " ) );
|
||||
print( ( whole( coconuts, 0 ), " coconuts", newline ) );
|
||||
FOR t TO ns DO
|
||||
print( ( " Sailor ", whole( t, 0 ) ) );
|
||||
print( ( " hides ", whole( hidden[ t ], 0 ), newline ) )
|
||||
OD;
|
||||
print( ( " The monkey gets ", whole( ns, 0 ), newline ) );
|
||||
print( ( " Finally, each sailor takes ", whole( nc OVER ns, 0 ) ) );
|
||||
print( ( newline, newline ) );
|
||||
next ns := TRUE
|
||||
FI
|
||||
ELSE
|
||||
break s := TRUE
|
||||
FI
|
||||
OD;
|
||||
IF NOT next ns THEN coconuts +:= ns FI
|
||||
OD
|
||||
OD
|
||||
|
||||
END
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
cocos = 11
|
||||
|
||||
for marineros = 2 to 9
|
||||
dim oculta(marineros)
|
||||
cocos = int(cocos / marineros) * marineros + 1
|
||||
while true
|
||||
nc = cocos
|
||||
for s = 1 to marineros + 1
|
||||
if nc mod marineros = 1 then
|
||||
oculta[s-1] = int(nc / marineros)
|
||||
nc -= oculta[s-1] + 1
|
||||
if (s = marineros) and (nc mod marineros = 0) then
|
||||
print marineros; " sailors require a minimum of "; cocos; " cocos"
|
||||
for t = 1 to marineros
|
||||
print chr(9); "Sailor "; t; " hides "; oculta[t - 1]
|
||||
next t
|
||||
print chr(9); "The monkey gets "; marineros
|
||||
print chr(9); "Finally, each sailor takes "; int(nc / marineros); chr(10)
|
||||
exit while
|
||||
end if
|
||||
else
|
||||
exit for
|
||||
end if
|
||||
next s
|
||||
cocos += marineros
|
||||
end while
|
||||
next marineros
|
||||
end
|
||||
|
|
@ -1,28 +1,30 @@
|
|||
Dim As Integer cocos = 11
|
||||
Dim As Integer cocos, marineros, nc, s, t
|
||||
|
||||
For ns As Integer = 2 To 9
|
||||
Dim As Integer oculta(ns)
|
||||
cocos = Int(cocos / ns) * ns + 1
|
||||
cocos = 11
|
||||
For marineros = 2 To 9
|
||||
Dim As Integer oculta(marineros)
|
||||
cocos = (cocos \ marineros) * marineros + 1
|
||||
Do
|
||||
Dim As Integer nc = cocos
|
||||
For s As Integer = 1 To ns+1
|
||||
If nc Mod ns = 1 Then
|
||||
oculta(s-1) = Int(nc / ns)
|
||||
nc = nc - (oculta(s-1) + 1)
|
||||
If s = ns And Not (nc Mod ns) Then
|
||||
Print ns; " marineros requieren un m¡nimo de"; cocos; " cocos"
|
||||
For t As Integer = 1 To ns
|
||||
Print !"\tEl marinero"; t; " se esconde"; oculta(t - 1)
|
||||
nc = cocos
|
||||
For s = 1 To marineros + 1
|
||||
If nc Mod marineros = 1 Then
|
||||
oculta(s-1) = nc \ marineros
|
||||
nc -= oculta(s-1) + 1
|
||||
If (s = marineros) And (nc Mod marineros = 0) Then
|
||||
Print marineros; " sailors require a minimum of "; cocos; " coconuts"
|
||||
For t = 1 To marineros
|
||||
Print !"\tSailor "; t; " hides "; oculta(t - 1)
|
||||
Next t
|
||||
Print !"\tEl mono obtiene"; ns
|
||||
Print !"\tFinalmente, cada marinero se lleva"; Int(nc / ns); !"\n"
|
||||
Print !"\tThe monkey gets "; marineros
|
||||
Print !"\tFinally, each sailor takes "; (nc \ marineros) & Chr(10)
|
||||
Exit Do
|
||||
End If
|
||||
Else
|
||||
Exit For
|
||||
End If
|
||||
Next s
|
||||
cocos += ns
|
||||
cocos += marineros
|
||||
Loop
|
||||
Next ns
|
||||
Next marineros
|
||||
|
||||
Sleep
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
I.(=<.)%&5 verb def'4*(y-1)%5'^:5 i.10000
|
||||
i.&1(=<.)%&5 (4*<:%5:)^:5 i.10000
|
||||
3121
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
I.(=<.)%&6 verb def'5*(y-1)%6'^:6 i.1000000
|
||||
233275 513211 793147
|
||||
i.&1(=<.)%&6 (5*<:%6:)^:6 i.1000000
|
||||
233275
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue