Raspberry BASIC

Author Topic: SALC Rasbian 32  (Read 526 times)

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 159
    • View Profile
    • ScriptBasic
Re: SALC Rasbian 32
« Reply #15 on: December 03, 2019, 07:35:46 PM »
C Update  (AIR submission)

Code: C
  1. // C Update - 1mil3.c - AIR
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6.  
  7. char *strrev(char *str)
  8. {
  9.     if (!str || ! *str)
  10.         return str;
  11.  
  12.     int i = strlen(str) - 1, j = 0;
  13.  
  14.     char ch;
  15.     while (i > j) {
  16.         ch = str[i];
  17.         str[i] = str[j];
  18.         str[j] = ch;
  19.         i--;
  20.         j++;
  21.     }
  22.     return str;
  23. }
  24.  
  25.  
  26. int main() {
  27.     int a[1000001] = {0};
  28.     char *t=NULL;
  29.     char tmp[2] = {0};
  30.     char s[27] = {0};
  31.     FILE *t_stream;
  32.     size_t len;
  33.  
  34.     t_stream = open_memstream(&t, &len);
  35.  
  36.     for (int x = 0; x < 1000001; x++) {
  37.         a[x] = x;
  38.         tmp[0] = (char)(x%26)+65;
  39.  
  40.         strncat(s,tmp,2);
  41.  
  42.         if (strlen(s) == 26) {
  43.             fprintf(t_stream, "%s",s);
  44.             s[0] = '\0';
  45.         }
  46.  
  47.     }
  48.  
  49.     fclose(t_stream);
  50.  
  51.     strrev(t);
  52.  
  53.     printf("r LEN: %lu\n",strlen(t));
  54.     printf("Front: %.*s\n", 26, t);
  55.     printf("Back:  %s\n", t + strlen(t) - 26);
  56.     printf("UBVal: %d\n",a[1000000]);
  57.  
  58.     free(t);
  59.  
  60. }
  61.  


pi@RPi4B:~/c-dev/examples $ gcc -O3 1mil3.2.c -o 1mil3.2
pi@RPi4B:~/c-dev/examples $ ls -l 1mil3.2
-rwxr-xr-x 1 pi pi 8296 Dec  3 11:31 1mil3.2
pi@RPi4B:~/c-dev/examples $ /usr/bin/time ./1mil3.2
r LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:  ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
0.14user 0.02system 0:00.18elapsed 97%CPU (0avgtext+0avgdata 5888maxresident)k
0inputs+0outputs (0major+1565minor)pagefaults 0swaps
pi@RPi4B:~/c-dev/examples $

ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 159
    • View Profile
    • ScriptBasic
Re: SALC Rasbian 32
« Reply #16 on: December 04, 2019, 01:29:49 AM »
Perl

Code: Perl
  1. # Perl - 1mil3.pl
  2.  
  3. my $s = "";
  4. my $t = "";
  5. my $a = [1000000];
  6.  
  7. for (my $x = 1; $x <= 1000000; $x++) {
  8.   $s = $s . chr((($x - 1) % 26) + 65);
  9.   $a[$x] = $x;
  10.   if (length($s) == 26) {
  11.     $t = $t . $s;
  12.     $s = "";
  13.   }
  14. }
  15.  
  16.  
  17. my $r = scalar reverse $t;
  18.  
  19. printf("r LEN: %d\n", length($r));
  20. printf("Front: %s\n", substr($r, 0, 26));
  21. printf("Back:  %s\n", substr($r, -26));
  22. printf("UBVal: %d\n", $a[1000000]);
  23.  


pi@RPi4B:~/perl-dev/examples $ /usr/bin/time perl 1mil3.pl
r LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:  ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
1.13user 0.07system 0:01.22elapsed 99%CPU (0avgtext+0avgdata 33636maxresident)k
0inputs+0outputs (0major+7705minor)pagefaults 0swaps
pi@RPi4B:~/perl-dev/examples $

ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 159
    • View Profile
    • ScriptBasic
Re: SALC Rasbian 32
« Reply #17 on: December 04, 2019, 06:23:02 AM »
Java

Code: Java
  1. // Java - 1mil3.java
  2.  
  3. class onemil3
  4.   {
  5.   public static void main(String args[])
  6.   {
  7.   String s = "";
  8.   String t = "";
  9.   int c = 0;
  10.   int[] a = new int[1000001];
  11.  
  12.   for (int x = 1; x <= 1000000; x++) {
  13.     c = ((x - 1) % 26) + 65;          
  14.     s = s + (char) c;
  15.     a[x] = x;
  16.     if(s.length() == 26) {
  17.       t = t + s;
  18.       s = "";
  19.     }
  20.   }
  21.  
  22.   StringBuilder r = new StringBuilder();
  23.   r.append(t);
  24.   r = r.reverse();
  25.  
  26.   System.out.println("r LEN: " + r.length());
  27.   System.out.println("Front: " + r.substring(0, 26));
  28.   System.out.println("Back:  " + r.substring(r.length() - 26));  
  29.   System.out.println("UBVal: " + a[1000000]);
  30.   }
  31. }
  32.  


pi@RPi4B:~/java-dev/examples $ /usr/bin/time java onemil3
r LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:  ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
43.79user 2.03system 0:34.78elapsed 131%CPU (0avgtext+0avgdata 144432maxresident)k
0inputs+96outputs (0major+33910minor)pagefaults 0swaps
pi@RPi4B:~/java-dev/examples $



This version is using the StringBuilder class rather than adding a character or alphabet string to the result string. Night and day.

Code: Java
  1. // Java - 1mil3.java
  2.  
  3. class onemil3
  4.   {
  5.   public static void main(String args[])
  6.   {
  7.   StringBuilder s = new StringBuilder();
  8.   StringBuilder t = new StringBuilder();
  9.   int c = 0;
  10.   int[] a = new int[1000001];
  11.  
  12.   for (int x = 1; x <= 1000000; x++) {
  13.     c = ((x - 1) % 26) + 65;          
  14.     s.append((char) c);
  15.     a[x] = x;
  16.     if(s.length() == 26) {
  17.       t.append(s);
  18.       s.delete(0, s.length());
  19.     }
  20.   }
  21.  
  22.   StringBuilder r = new StringBuilder();
  23.   r.append(t);
  24.   r = r.reverse();
  25.  
  26.   System.out.println("r LEN: " + r.length());
  27.   System.out.println("Front: " + r.substring(0, 26));
  28.   System.out.println("Back:  " + r.substring(r.length() - 26));  
  29.   System.out.println("UBVal: " + a[1000000]);
  30.   }
  31. }
  32.  


pi@RPi4B:~/java-dev/examples $ javac 1mil3.java
pi@RPi4B:~/java-dev/examples $ /usr/bin/time java onemil3
r LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:  ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
0.49user 0.14system 0:00.53elapsed 119%CPU (0avgtext+0avgdata 31948maxresident)k
0inputs+64outputs (0major+5024minor)pagefaults 0swaps
pi@RPi4B:~/java-dev/examples $

« Last Edit: December 04, 2019, 07:18:20 AM by John Spikowski »
ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 159
    • View Profile
    • ScriptBasic
Re: SALC Rasbian 32
« Reply #18 on: December 07, 2019, 03:06:32 AM »
I was curious if I expanded out the expression to concatenate strings in ScriptBasic would it help?  NOT and good to know for future use.

Example

Was:  t &= s

Changed  To:  t = t & s

&= seems to be ScriptBasic's StringBuilder function.

Code: Script BASIC
  1. ' ScriptBasic - 1mil.sb
  2.  
  3. s = ""
  4. t = ""
  5. SPLITA STRING(1000001,"0") BY "" TO a
  6.  
  7. FOR x = 1 TO 1000000
  8.   s = s & CHR(((x - 1) % 26) + 65)
  9.   a[x] = x
  10.   IF LEN(s) = 26 THEN
  11.     t = t & s
  12.     s = ""
  13.   END IF
  14. NEXT
  15. t = STRREVERSE(t)
  16. PRINT "t LEN: ",LEN(t),"\n"
  17. PRINT "Front: ",LEFT(t, 26),"\n"
  18. PRINT "Back:  ",RIGHT(t, 26),"\n"
  19. PRINT "UBVal: ",a[1000000],"\n"
  20.  


pi@RPi4B:~/sbrt/examples $ timex scriba  1mil3.sb
t LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:  ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
127.51user 35.17system 2:42.93elapsed 99%CPU (0avgtext+0avgdata 171488maxresident)k
0inputs+0outputs (0major+4122875minor)pagefaults 0swaps
pi@RPi4B:~/sbrt/examples $

 
« Last Edit: December 07, 2019, 03:41:48 AM by John Spikowski »
ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 159
    • View Profile
    • ScriptBasic
Re: SALC Rasbian 32
« Reply #19 on: December 07, 2019, 08:44:32 PM »
BaCon Update (AIR submission)

Code: Text
  1. ' BaCon - 1mil3-2.bac - AIR
  2.  
  3. OPTION PARSE FALSE
  4.  
  5. s$ = ""
  6. t$ = ""
  7.  
  8. DECLARE a[1000001] TYPE NUMBER
  9. DECLARE len TYPE uint
  10. DECLARE *stream TYPE FILE
  11.  
  12. stream = open_memstream(&t$,&len)
  13.  
  14. FOR x = 1 TO 1000000
  15.   s$ = s$ & CHR$(MOD((x - 1), 26) + 65)
  16.   a[x] = x
  17.   IF LEN(s$) = 26 THEN
  18.     fprintf(stream,s$)
  19.     s$ = ""
  20.   END IF
  21. NEXT
  22. CLOSE FILE stream
  23.  
  24. r$ = REVERSE$(t$)
  25. FREE t$
  26. PRINT "r LEN: ",len
  27. PRINT "Front: ",LEFT$(r$, 26)
  28. PRINT "Back:  ",RIGHT$(r$, 26)
  29. PRINT "UBVal: ",a[1000000]
  30.  


pi@RPi4B:~/bacon-dev/examples $ bacon 1mil3-2.bac
Converting '1mil3-2.bac'... done, 30 lines were processed in 0.064 seconds.
Compiling '1mil3-2.bac'... cc  -c 1mil3-2.bac.c
cc -o 1mil3-2 1mil3-2.bac.o -lbacon -L. -lm 
Done, program '1mil3-2' ready.
pi@RPi4B:~/bacon-dev/examples $ ls -l 1mil3-2
-rwxr-xr-x 1 pi pi 114748 Dec  7 12:40 1mil3-2
pi@RPi4B:~/bacon-dev/examples $ timex ./1mil3-2
r LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:  ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
0.48user 0.03system 0:00.51elapsed 99%CPU (0avgtext+0avgdata 8012maxresident)k
0inputs+0outputs (0major+2068minor)pagefaults 0swaps
pi@RPi4B:~/bacon-dev/examples $

ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 159
    • View Profile
    • ScriptBasic
Re: SALC Rasbian 32
« Reply #20 on: December 08, 2019, 06:02:34 AM »
ScriptBasic Update

Code: Script BASIC
  1. ' ScriptBasic - 1milsf.sb
  2.  
  3. OPEN  "t_file" FOR OUTPUT AS #1
  4.  
  5. s = ""
  6. SPLITA STRING(1000001,"0") BY "" TO a
  7.  
  8. FOR x = 1 TO 1000000
  9.   s &= CHR(((x - 1) % 26) + 65)
  10.   a[x] = x
  11.   IF LEN(s) = 26 THEN
  12.     PRINT #1, s
  13.     s = ""
  14.   END IF
  15. NEXT
  16. CLOSE(1)
  17.  
  18. flen = FILELEN("t_file")
  19. OPEN "t_file" FOR INPUT AS #1
  20. t = INPUT(flen, 1)
  21. CLOSE(1)
  22. t = STRREVERSE(t)
  23.  
  24. PRINT "t LEN: ",LEN(t),"\n"
  25. PRINT "Front: ",LEFT(t, 26),"\n"
  26. PRINT "Back:  ",RIGHT(t, 26),"\n"
  27. PRINT "UBVal: ",a[1000000],"\n"
  28.  


pi@RPi4B:~/sbrt/examples $ timex scriba 1milsf.sb
t LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:  ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
7.03user 0.84system 0:07.89elapsed 99%CPU (0avgtext+0avgdata 171504maxresident)k
0inputs+1976outputs (0major+43080minor)pagefaults 0swaps
pi@RPi4B:~/sbrt/examples $

« Last Edit: December 09, 2019, 12:18:15 AM by John Spikowski »
ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 159
    • View Profile
    • ScriptBasic
Re: SALC Rasbian 32
« Reply #21 on: December 08, 2019, 10:46:40 PM »
Python3 Update (AIR submission)

Code: Python
  1. # Python 3 - 1mil3-2.py - AIR
  2.  
  3. def main():
  4.     t = []
  5.     r =""
  6.     a = [None] * 1000001
  7.     b = bytearray(26)
  8.     decode = bytearray.decode
  9.     blah = range(1000001)
  10.     append = list.append
  11.  
  12.     for x in blah:
  13.         alpha = x % 26
  14.         b[alpha] = alpha + 65
  15.         a[x] = x
  16.         if alpha == 25:
  17.             append(t, decode(b[::-1]))
  18.  
  19.     r = ''.join(t)
  20.  
  21.     print("r LEN: {}".format(len(r)))
  22.     print("Front: {}".format(r[:26]))
  23.     print("Back:  {}".format(r[-26:]))
  24.     print("UBVal: {}".format(a[1000000]))
  25.  
  26. if __name__ == "__main__":
  27.     main()
  28.  


pi@RPi4B:~/python-dev/examples $ timex python3 1mil3-2,py
r LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:  ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
0.68user 0.08system 0:00.78elapsed 99%CPU (0avgtext+0avgdata 29952maxresident)k
0inputs+0outputs (0major+6541minor)pagefaults 0swaps
pi@RPi4B:~/python-dev/examples $

ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 159
    • View Profile
    • ScriptBasic
Re: SALC Rasbian 32
« Reply #22 on: December 09, 2019, 07:26:17 PM »
Ruby (AIR submission)

Code: Ruby
  1. # Ruby - 1mil3.rb - AIR
  2.  
  3. a = [10000001]
  4. s = ""
  5. t = ""
  6.  
  7.  
  8. (0..1000001).each do |x|
  9.         a << x+1
  10.         s << (x%26)+65
  11.         if s.length == 26
  12.                 t << s.reverse
  13.                 s.clear
  14.         end
  15. end
  16.  
  17. puts "t LEN: #{t.length}"
  18. puts "Front: #{t[0,26]}"
  19. puts "Back:  #{t[-26,26]}"
  20. puts "UBVal: #{a[1000000]}"
  21.  


pi@RPi4B:~/ruby-dev/examples $ timex ruby 1mil3.rb
t LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:  ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
0.98user 0.04system 0:01.18elapsed 86%CPU (0avgtext+0avgdata 12024maxresident)k
7168inputs+0outputs (16major+2164minor)pagefaults 0swaps
pi@RPi4B:~/ruby-dev/examples $

ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 159
    • View Profile
    • ScriptBasic
Re: SALC Rasbian 32
« Reply #23 on: December 09, 2019, 11:12:38 PM »
C Update (AIR submission)

Code: C
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <glib.h>
  4. #include <glib/gprintf.h>
  5.  
  6. int main(int argc, char **argv) {
  7.         GString *s = g_string_new(NULL);
  8.         GString *t = g_string_new(NULL);
  9.         int a[1000001] = {0};
  10.  
  11.         for (int x = 0; x < 1000001; x++) {
  12.                 a[x] = x;
  13.                 g_string_append_c(s,(char)(x%26)+65);
  14.                 if (s->len == 26) {
  15.                         g_string_append(t,g_strreverse(s->str));
  16.                         g_string_assign(s,"");
  17.                 }
  18.         }
  19.  
  20.         g_printf("r LEN: %d\n",t->len);
  21.         g_printf("Front: %.*s\n", 26, t->str);
  22.         g_printf("Back:  %s\n", t->str + t->len - 26);
  23.         g_printf("UBVal: %d\n",a[1000000]);
  24.  
  25.         g_string_free (s,TRUE);
  26.         g_string_free (t,TRUE);
  27. }
  28.  


pi@RPi4B:~/c-dev/examples $ gcc -O3 1mil3-3.c  $(pkg-config --libs --cflags glib-2.0) -o 1mil3-3
pi@RPi4B:~/c-dev/examples $ ls -l 1mil3-3
-rwxr-xr-x 1 pi pi 8308 Dec  9 15:05 1mil3-3
pi@RPi4B:~/c-dev/examples $ timex ./1mil3-3
r LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:  ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
0.03user 0.02system 0:00.07elapsed 95%CPU (0avgtext+0avgdata 6384maxresident)k
0inputs+0outputs (0major+1336minor)pagefaults 0swaps
pi@RPi4B:~/c-dev/examples $

ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 159
    • View Profile
    • ScriptBasic
Re: SALC Rasbian 32
« Reply #24 on: December 10, 2019, 02:18:47 AM »
Rust (AIR submission)

Code: Text
  1. // Rust - 1mil3 - AIR
  2.  
  3. fn main() {
  4.     let mut s = "".to_string();
  5.     let mut t = "".to_string();
  6.     let mut a = [0;1000001];
  7.  
  8.     for x in 0..1000001 {
  9.         a[x] = x;
  10.         let b   = ( x%26 ) as u8;
  11.         let c = ( b+65 ) as char;
  12.         s.push( c );
  13.         if s.len() == 26 {
  14.             let reversed: String = s.chars().rev().collect();
  15.             t.push_str( &reversed );
  16.             s.clear();
  17.         }
  18.     }
  19.     println!( "r LEN: {}",  t.len() );
  20.     println!( "Front: {}",  &t[..26] );
  21.     println!( "Back:  {}",  &t[t.len()-26..]);
  22.     println!( "UBVal: {}",  a[1000000] );
  23.  
  24. }
  25.  

-rwxr-xr-x 1 pi pi 2582500 Dec  9 17:47 1mil3

pi@RPi4B:~/rust-dev/examples $ timex ./1mil3
r LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:  ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
0.10user 0.02system 0:00.12elapsed 96%CPU (0avgtext+0avgdata 6336maxresident)k
0inputs+0outputs (0major+1392minor)pagefaults 0swaps
pi@RPi4B:~/rust-dev/examples $


ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 159
    • View Profile
    • ScriptBasic
Re: SALC Rasbian 32
« Reply #25 on: December 10, 2019, 06:38:31 AM »
Swift Update (AIR submission)

Code: Text
  1. // Swift 5.1.2 - 1mil3-3.swift
  2.  
  3. var s = ""
  4. var t = ""
  5. var a = [Int](repeating: 0, count: 1000001)
  6.  
  7. for x in 1...1000000 {
  8.   let c = (x - 1) % 26
  9.   s.append(String(UnicodeScalar(UInt8(c + 65))))
  10.   a[x] = x
  11.   if c == 25 {
  12.     t.append(String(s.reversed()))
  13.     s = ""
  14.   }
  15. }
  16.  
  17. print("t LEN: ", t.count)
  18. print("Front: \(t.prefix(26))")
  19. print("Back:  \(t.suffix(26))")
  20. print("UBVal: ", a[100000])
  21.  


pi@RPi4B:~/swift-dev/examples $ swiftc -O 1mil3-3.swift
pi@RPi4B:~/swift-dev/examples $ ls -l main
-rwxr-xr-x 1 pi pi 29316 Dec  9 22:37 main
pi@RPi4B:~/swift-dev/examples $ timex ./main
t LEN:  999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:  ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal:  100000
23.26user 0.03system 0:23.31elapsed 99%CPU (0avgtext+0avgdata 12012maxresident)k
0inputs+0outputs (0major+1890minor)pagefaults 0swaps
pi@RPi4B:~/swift-dev/examples $

ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 159
    • View Profile
    • ScriptBasic
Re: SALC Rasbian 32
« Reply #26 on: December 10, 2019, 06:49:19 AM »
Free Pascal (AIR submission)

Code: Pascal
  1. // Free Pascal -1mil3 - AIR
  2.  
  3. program mil;
  4.  
  5. Uses StrUtils;
  6.  
  7. var
  8.     s:AnsiString;
  9.     t:AnsiString;
  10.     c:AnsiChar;
  11.     a:array[0..1000001] of int32;
  12.     x:int32;
  13. begin
  14.     s := '';
  15.     t := '';
  16.     for x := 0 to 1000001 do
  17.     begin
  18.         c :=  chr( (x mod 26)+65 );
  19.         a[x] := x;
  20.         s += c;
  21.         if Length(s) = 26 then
  22.         begin
  23.             t += ReverseString(s);
  24.             s := '';
  25.         end;
  26.     end;
  27.  
  28.     writeln( 'r len: ', Length(t) );
  29.     writeln( 'Front: ', LeftStr(t,26) );
  30.     writeln( 'Back:  ', RightStr(t,26) );
  31.     writeln( 'UBVal: ', a[1000000]);
  32. end.
  33.  


pi@RPi4B:~/freepascal-dev/examples $ ls -l
total 80
-rwxr-xr-x 1 pi pi 78352 Dec  9 20:31 1mil3
pi@RPi4B:~/freepascal-dev/examples $ timex ./1mil3
r len: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:  ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
0.20user 0.02system 0:00.23elapsed 99%CPU (0avgtext+0avgdata 5604maxresident)k
8inputs+0outputs (0major+1431minor)pagefaults 0swaps
pi@RPi4B:~/freepascal-dev/examples $

ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 159
    • View Profile
    • ScriptBasic
Re: SALC Rasbian 32
« Reply #27 on: December 11, 2019, 06:29:50 PM »
8th Update (Jalih submission)

Code: Text
  1. 1000000 constant LIMIT
  2.  
  3. a:new 0 a:push var, a
  4. 0 b:new true b:writable var, s
  5. 0 b:new true b:writable var, t
  6.  
  7.  
  8. : iterate
  9.   s @ "" 2 pick n:1- 26 n:mod 65 n:+ s:+ b:append
  10.   b:len 26 n:< not if
  11.     t @ swap b:append drop
  12.     0 b:new true b:writable s !
  13.   else
  14.     drop
  15.   then
  16.   a:push ;
  17.  
  18. : app:main
  19.   a @ ' iterate 1 LIMIT loop
  20.   t @ b:rev >s s:len "r LEN: %d\n" s:strfmt .
  21.   dup 26 s:lsub "Front: %s\n" s:strfmt .
  22.   26 s:rsub "Back:  %s\n" s:strfmt .
  23.   LIMIT a:@ nip "UBVal: %d\n" s:strfmt .
  24.   bye ;
  25.  


pi@RPi4B:~/8th-dev/examples $ timex ./1mil3-2
r LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:  ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
2.09user 0.16system 0:02.28elapsed 99%CPU (0avgtext+0avgdata 53140maxresident)k
0inputs+0outputs (0major+12124minor)pagefaults 0swaps
pi@RPi4B:~/8th-dev/examples $


I thought Rust executables were huge. 8th takes the lead in this category.

-rwxr-xr-x 1 pi pi 7344807 Dec  9 21:02 1mil3-2
ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 159
    • View Profile
    • ScriptBasic
Re: SALC Rasbian 32
« Reply #28 on: December 11, 2019, 06:49:05 PM »
Current String / Array language challenge results.
ScriptBasic Project Manager/Facilitator

AIR

  • BASIC Developer
  • *
  • Posts: 16
  • Code Jockey
    • View Profile
Re: SALC Rasbian 32
« Reply #29 on: December 15, 2019, 01:22:50 AM »
I installed Ubuntu Server 19.10.1, which is 64bit, on my other RasPi 4b (4GB).

Interestingly, the arch is "aarch64".

None of the 32bit RasPi submissions run on it though.

One of the things I wanted to see is how the Swift submission would run on it.

Here's what I got:

riveraa@dpi:~/Projects/Swift/1mil3$ file ./mil
./mil: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0, not stripped

riveraa@dpi:~/Projects/Swift/1mil3$ timex ./mil
r LEN:  999986
Front:  ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:   ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal:  100000
0.66user 0.02system 0:00.68elapsed 99%CPU (0avgtext+0avgdata 16292maxresident)k
0inputs+0outputs (0major+2795minor)pagefaults 0swaps

riveraa@dpi:~/Projects/Swift/1mil3$ uname -a
Linux dpi 5.3.0-1014-raspi2 #16-Ubuntu SMP Tue Nov 26 11:18:23 UTC 2019 aarch64 aarch64 aarch64 GNU/Linux
riveraa@dpi:~/Projects/Swift/1mil3$


Food for thought...

AIR.