Home
Help
Search
Login
Register
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Forum Registration: support@scriptbasic.org
Raspberry BASIC
»
Raspberry BASIC
»
Programming Challenges
»
SALC Ubuntu 64
« previous
next »
Print
Pages:
1
[
2
]
Author
Topic: SALC Ubuntu 64 (Read 17154 times)
John Spikowski
BASIC Developer
Posts: 234
Re: SALC Ubuntu 64
«
Reply #15 on:
December 17, 2019, 03:36:12 AM »
JavaScript
(Ubuntu 64 RPi 4B 4GB)
Code: Javascript
// JavaScript - 1mil4.js
function
reverseString
(
str
)
{
let strn
=
""
;
for
(
let
char
of str
)
{
strn
=
char
+
strn
;
}
return
strn
;
}
var
s
=
""
;
var
t
=
""
;
var
a
=
[
1000001
]
;
for
(
x
=
1
;
x
<=
1000000
;
x
++
)
{
s
+=
String
.
fromCharCode
(
(
(
x
-
1
)
%
26
)
+
65
)
;
a
[
x
]
=
x
;
if
(
s.
length
==
26
)
{
t
+=
s
;
s
=
""
;
}
}
r
=
reverseString
(
t
)
;
console.
log
(
"r LEN: "
+
r.
length
)
;
console.
log
(
"Front: "
+
r.
substring
(
0
,
26
)
)
;
console.
log
(
"Back: "
+
r.
substring
(
-
0
,
26
)
)
;
console.
log
(
"UBVal: "
+
a
[
1000000
]
)
;
ubuntu@rpi4b:~/salc/javascript-dev$ timex node 1mil4.js
r LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back: ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
0.97user 0.21system 0:01.20elapsed 98%CPU (0avgtext+0avgdata 118448maxresident)k
88inputs+0outputs (1major+27106minor)pagefaults 0swaps
ubuntu@rpi4b:~/salc/javascript-dev$
Logged
ScriptBasic Project Manager/Facilitator
John Spikowski
BASIC Developer
Posts: 234
Re: SALC Ubuntu 64
«
Reply #16 on:
December 17, 2019, 05:15:02 AM »
I split the topic into 4 groups
Just REM
One Mil Dash
SALC (String Array Language Challenge) Rasbain 32 bit on the RPi 4B 4GB
SALC Ubuntu 64 bit on the RPi 4B 4GB
A fifth round might be each language has to create a simple GUI. (not a popup message box) Maybe a login dialog.
«
Last Edit: December 17, 2019, 05:26:20 AM by John Spikowski
»
Logged
ScriptBasic Project Manager/Facilitator
John Spikowski
BASIC Developer
Posts: 234
Re: SALC Ubuntu 64
«
Reply #17 on:
December 18, 2019, 04:07:10 AM »
Nim 1,1,1
(Ubuntu 64 RPi 4B 4GB)
Code: Text
# Nim 1.1.1 - onemil4.nim
proc reverse*(str: string): string =
result = ""
for index in countdown(str.high, 0):
result.add(str[index])
type
milarray = array[1000001, int]
var
s = ""
t = ""
r:string
a:milarray
for x in 0..1000000:
a[x] = x
s &= chr((x mod 26) + 65)
if s.len == 26:
t &= s
s = ""
r = t.reverse
echo "r Len: ",r.len
echo "Front: ",r[0..25]
echo "Back: ",r[r.len-26..r.len-1]
echo "UBVal: ",a[1000000]
ubuntu@rpi4b:~/salc/nim-dev$ timex ./onemil4
r Len: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back: ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
0.04user 0.03system 0:00.07elapsed 98%CPU (0avgtext+0avgdata 14136maxresident)k
0inputs+0outputs (0major+3290minor)pagefaults 0swaps
ubuntu@rpi4b:~/salc/nim-dev$
«
Last Edit: December 18, 2019, 02:21:59 PM by John Spikowski
»
Logged
ScriptBasic Project Manager/Facilitator
John Spikowski
BASIC Developer
Posts: 234
Re: SALC Ubuntu 64
«
Reply #18 on:
December 19, 2019, 08:36:36 AM »
JADE C++
(Ubuntu 64 RPi 4B 4GB)
Code: C++
#include <jade.hpp>
MAIN
STRING s,t,r
;
ARRAY
<
int
>
a
;
FOR
(
VAR x
=
0
TO x
<
1000001
STEP x
++
)
DO
a.
push_back
(
x
)
;
s
+
=
(
CHAR
)
(
x
%
26
)
+
65
;
IF
(
LEN
(
s
)
==
26
)
THEN
t
+
=
s
;
s
=
""
;
END
END
r
=
REVERSE$
(
t
)
;
PRINT
(
"r LEN: "
,LEN
(
t
)
)
;
PRINT
(
"Front: "
, LEFT$
(
r,
26
)
)
;
PRINT
(
"Back: "
, RIGHT$
(
r,
26
)
)
;
PRINT
(
"UBVal: "
,a
[
1000000
]
)
;
END
riveraa@rpi:~/Projects/jade$ timex ./mil64
r LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back: ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
0.05user 0.01system 0:00.07elapsed 98%CPU (0avgtext+0avgdata 10136maxresident)k
0inputs+0outputs (0major+3069minor)pagefaults 0swaps
Logged
ScriptBasic Project Manager/Facilitator
John Spikowski
BASIC Developer
Posts: 234
Re: SALC Ubuntu 64
«
Reply #19 on:
December 19, 2019, 10:29:19 PM »
GO
(Ubuntu 64 RPi 4B 4GB)
Code: Go
// GO - 1mil4.go - AIR
package
main
import
(
"fmt"
"strings"
)
// Reverse returns its argument string reversed rune-wise left to right.
// From: https://github.com/golang/example/blob/master/stringutil/reverse.go
func
Reverse
(
s
string
)
string
{
r
:=
[]
rune
(
s
)
for
i
,
j
:=
0
,
len
(
r
)
-
1
;
i
<
len
(
r
)
/
2
;
i
,
j
=
i
+
1
,
j
-
1
{
r
[
i
],
r
[
j
]
=
r
[
j
],
r
[
i
]
}
return
string
(
r
)
}
func
main
()
{
var
s strings
.
Builder
var
r
=
""
var
t strings
.
Builder
var
a
[
1000001
]
int
for
x
:=
0
;
x <
1000001
;
x
++
{
a
[
x
]
=
x
s
.
WriteByte
(
byte
((
x
%
26
)
+
65
))
if
s
.
Len
()
==
26
{
t
.
WriteString
(
s
.
String
())
s
.
Reset
()
}
}
r
=
Reverse
(
t
.
String
())
fmt
.
Println
(
"r LEN: "
,
len
(
r
))
fmt
.
Println
(
"Front: "
,
r
[
0
:
26
])
fmt
.
Println
(
"Back: "
,
r
[
len
(
r
)
-
26
:])
fmt
.
Println
(
"UBVal: "
,
a
[
1000000
])
}
ubuntu@rpi4b:~/salc/go-dev$ go build 1mil4.go
ubuntu@rpi4b:~/salc/go-dev$ ls -l
total 1932
-rwxr-xr-x 1 ubuntu ubuntu 2123629 Dec 19 14:26 1mil4
-rw-r--r-- 1 ubuntu ubuntu 887 Dec 19 14:25 1mil4.go
ubuntu@rpi4b:~/salc/go-dev$ timex ./1mil4
r LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back: ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
0.11user 0.02system 0:00.12elapsed 109%CPU (0avgtext+0avgdata 19272maxresident)k
0inputs+0outputs (0major+4599minor)pagefaults 0swaps
ubuntu@rpi4b:~/salc/go-dev$
Logged
ScriptBasic Project Manager/Facilitator
John Spikowski
BASIC Developer
Posts: 234
Re: SALC Ubuntu 64
«
Reply #20 on:
December 21, 2019, 04:35:48 AM »
8th
(Ubuntu 64 RPi 4B 4GB)
Code: Text
1000000 constant LIMIT
a:new 0 a:push var, a
0 b:new true b:writable var, s
0 b:new true b:writable var, t
: iterate
s @ "" 2 pick n:1- 26 n:mod 65 n:+ s:+ b:append
b:len 26 n:< not if
t @ swap b:append drop
0 b:new true b:writable s !
else
drop
then
a:push ;
: app:main
a @ ' iterate 1 LIMIT loop
t @ b:rev >s s:len "r LEN: %d\n" s:strfmt .
dup 26 s:lsub "Front: %s\n" s:strfmt .
26 s:rsub "Back: %s\n" s:strfmt .
LIMIT a:@ nip "UBVal: %d\n" s:strfmt .
bye ;
ubuntu@rpi4b:~/salc/8th-dev$ timex ./1mil4
r LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back: ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
1.00user 0.10system 0:01.12elapsed 98%CPU (0avgtext+0avgdata 66508maxresident)k
0inputs+0outputs (0major+15444minor)pagefaults 0swaps
ubuntu@rpi4b:~/salc/8th-dev$
Logged
ScriptBasic Project Manager/Facilitator
John Spikowski
BASIC Developer
Posts: 234
Re: SALC Ubuntu 64
«
Reply #21 on:
December 21, 2019, 08:18:16 AM »
Free Pascal
(Ubuntu 64 RPi 4B 4GB)
Code: Pascal
// Free Pascal -1mil4 - AIR
program
mil
;
Uses
StrUtils
;
var
s
:
AnsiString
;
t
:
AnsiString
;
c
:
AnsiChar
;
a
:
array
[
0
..
1000001
]
of
int32
;
x
:
int32
;
begin
s
:
=
''
;
t
:
=
''
;
for
x
:
=
0
to
1000001
do
begin
c
:
=
chr
(
(
x
mod
26
)
+
65
)
;
a
[
x
]
:
=
x
;
s
+=
c
;
if
Length
(
s
)
=
26
then
begin
t
+=
ReverseString
(
s
)
;
s
:
=
''
;
end
;
end
;
writeln
(
'r len: '
,
Length
(
t
)
)
;
writeln
(
'Front: '
,
LeftStr
(
t
,
26
)
)
;
writeln
(
'Back: '
,
RightStr
(
t
,
26
)
)
;
writeln
(
'UBVal: '
,
a
[
1000000
]
)
;
end
.
riveraa@rpi:~/Projects/fpc/1mil3$ fpc -XX -CX -O3 mil64.pas
Free Pascal Compiler version 3.0.4+dfsg-22 [2019/01/24] for aarch64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Linux for AArch64
Compiling mil64.pas
Assembling mil
Linking mil64
31 lines compiled, 0.4 sec
riveraa@rpi:~/Projects/fpc/1mil3$ timex ./mil64
r len: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back: ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
0.15user 0.02system 0:00.17elapsed 98%CPU (0avgtext+0avgdata 5616maxresident)k
0inputs+0outputs (0major+1423minor)pagefaults
Logged
ScriptBasic Project Manager/Facilitator
John Spikowski
BASIC Developer
Posts: 234
Re: SALC Ubuntu 64
«
Reply #22 on:
December 21, 2019, 08:22:20 AM »
Rust
(Ubuntu 64 RPi 4B 4GB)
Code: Text
// Rust - 1mil4 - AIR
fn main() {
let mut s = "".to_string();
let mut t = "".to_string();
let mut a = [0;1000001];
for x in 0..1000001 {
a[x] = x;
let b = ( x%26 ) as u8;
let c = ( b+65 ) as char;
s.push( c );
if s.len() == 26 {
let reversed: String = s.chars().rev().collect();
t.push_str( &reversed );
s.clear();
}
}
println!( "r LEN: {}", t.len() );
println!( "Front: {}", &t[..26] );
println!( "Back: {}", &t[t.len()-26..]);
println!( "UBVal: {}", a[1000000] );
}
riveraa@rpi:~/Projects/rust/1mil3$ rustc -O mil64.rs
riveraa@rpi:~/Projects/rust/1mil3$ timex ./mil64
r LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back: ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
0.02user 0.01system 0:00.04elapsed 100%CPU (0avgtext+0avgdata 10440maxresident)k
0inputs+0outputs (0major+2371minor)pagefaults 0swaps
Logged
ScriptBasic Project Manager/Facilitator
John Spikowski
BASIC Developer
Posts: 234
Re: SALC Ubuntu 64
«
Reply #23 on:
December 21, 2019, 08:32:48 AM »
Current results of the Ubuntu 64 bit and Rasbain 32 bit
String Array Language Challenge
on the RPi 4B 4GB,
«
Last Edit: December 22, 2019, 08:56:30 PM by John Spikowski
»
Logged
ScriptBasic Project Manager/Facilitator
AIR
BASIC Developer
Posts: 16
Code Jockey
Re: SALC Ubuntu 64
«
Reply #24 on:
December 22, 2019, 06:04:08 AM »
Lua5.3
Code: Lua
a
=
{
}
local
s
=
""
local
t
=
{
""
}
for
i
=
0
,
1000000
do
a
[
i
]
=
i
local
c
=
(
i
%
26
)
s
=
s
..
string.char
(
c
+
65
)
if
c
==
25
then
table.insert
(
t
,
string
.
reverse
(
s
)
)
s
=
""
end
end
local
r
=
table.concat
(
t
)
print
(
"r LEN: "
,
#
r
)
print
(
"Front: "
,
string.sub
(
r
,
1
,
26
)
)
print
(
"Back: "
,
string.sub
(
r
,-
26
)
)
print
(
"UBVal: "
,
a
[
1000000
]
)
riveraa@rpi:~/Projects/lua$ timex lua mil.lua
r LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back: ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
0.61user 0.02system 0:00.64elapsed 99%CPU (0avgtext+0avgdata 20812maxresident)k
0inputs+0outputs (0major+4981minor)pagefaults 0swaps
AIR.
Logged
AIR
BASIC Developer
Posts: 16
Code Jockey
Re: SALC Ubuntu 64
«
Reply #25 on:
December 23, 2019, 04:50:25 AM »
VALA
Code: Vala
int
main
(
string
[
]
args
)
{
var
a
=
new
int
[
1000000
]
;
var
s
=
new
StringBuilder
(
)
;
var
t
=
new
StringBuilder
(
)
;
int
c
;
for
(
int
x
=
0
;
x
<
1000001
;
x
++
)
{
a
[
x
]
=
x
;
c
=
x
%
26
;
s.
append_c
(
(
char
)
c
+
65
)
;
if
(
c
==
25
)
{
t.
append
(
s.
str
.
reverse
(
)
)
;
s.
truncate
(
)
;
}
}
string
r
=
t.
str
;
stdout.
printf
(
"r LEN: %d
\n
"
,r.
length
)
;
stdout.
printf
(
"Front: %s
\n
"
,r.
substring
(
0
,
26
)
)
;
stdout.
printf
(
"Back: %s
\n
"
, r.
substring
(
r.
length
-
26
,
26
)
)
;
stdout.
printf
(
"UBVal: %d
\n
"
, a
[
1000000
]
)
;
return
0
;
}
riveraa@rpi:~/Projects/vala$ valac -X -O3 mil64.vala
r LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back: ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
0.03user 0.00system 0:00.03elapsed 97%CPU (0avgtext+0avgdata 7704maxresident)k
0inputs+0outputs (0major+1581minor)pagefaults 0swaps
AIR.
Logged
Print
Pages:
1
[
2
]
« previous
next »
Raspberry BASIC
»
Raspberry BASIC
»
Programming Challenges
»
SALC Ubuntu 64