Raspberry BASIC

Author Topic: SALC Rasbian 32  (Read 982 times)

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 160
    • View Profile
    • ScriptBasic
SALC Rasbian 32
« on: November 28, 2019, 05:03:24 AM »
I 'm going to take this challenge one more round and add a string and array  to the mix.

FYI:  This site is a forum and not my blog. Without contributing members it will soon become dormant. It only takes a minute to register. It's okay to be a member of multiple forums and I'm pretty sure the RPi moderators won't ban you if you appear here.
« Last Edit: November 28, 2019, 05:44:40 AM by John Spikowski »
ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 160
    • View Profile
    • ScriptBasic
Re: SALC Rasbian 32
« Reply #1 on: November 28, 2019, 07:28:13 AM »
ScriptBasic

The array part takes 4 seconds of the total time.,

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


pi@RPi4B:~/sbrt/examples $ /usr/bin/time scriba 1mil3.sb
r LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:  ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
15.64user 34.88system 0:50.55elapsed 99%CPU (0avgtext+0avgdata 172504maxresident)k
536inputs+0outputs (2major+4122825minor)pagefaults 0swaps
pi@RPi4B:~/sbrt/examples $

« Last Edit: December 03, 2019, 06:55:52 AM by John Spikowski »
ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 160
    • View Profile
    • ScriptBasic
Re: SALC Rasbian 32
« Reply #2 on: November 28, 2019, 07:11:56 PM »
8th  (Jalih submission)

Code: Text
  1. : plus-minus
  2.   n:1+
  3.   swap
  4.   n:1-
  5.   swap
  6.   2dup n:= if
  7.     "Middle\n" .
  8.   then ;
  9.  
  10. : app:main
  11.   1000000 0
  12.   ' plus-minus 1000000 times
  13.   "Plus: %d\nMinus: %d\n" s:strfmt .
  14.   bye ;
  15.  


pi@RPi4B:~/8th-dev/examples $ /usr/bin/time ./mil
Middle
Plus: 1000000
Minus: 0
0.41user 0.03system 0:00.45elapsed 96%CPU (0avgtext+0avgdata 6944maxresident)k
0inputs+0outputs (0major+340minor)pagefaults 0swaps
pi@RPi4B:~/8th-dev/examples $

ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 160
    • View Profile
    • ScriptBasic
Re: SALC Rasbian 32
« Reply #3 on: November 28, 2019, 09:00:08 PM »
BaCon

Code: Text
  1. ' BaCon - 1mil3.bac
  2.  
  3. s$ = ""
  4. t$ = ""
  5. DECLARE a[1000001] TYPE NUMBER
  6.  
  7. FOR x = 1 TO 1000000
  8.   s$ = s$ & CHR$(MOD((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. r$ = REVERSE$(t$)
  16. PRINT "r LEN: ",LEN(r$)
  17. PRINT "Front: ",LEFT$(r$, 26)
  18. PRINT "Back:  ",RIGHT$(r$, 26)
  19. PRINT "UBVal: ",a[1000000]
  20.  


pi@RPi4B:~/bacon-dev/examples $ bacon 1mil3.bac
Converting '1mil3.bac'... done, 21 lines were processed in 0.053 seconds.
Compiling '1mil3.bac'... cc  -c 1mil3.bac.c
cc -o 1mil3 1mil3.bac.o -lbacon -L. -lm 
Done, program '1mil3' ready.
pi@RPi4B:~/bacon-dev/examples $ ls -l 1mil3
-rwxr-xr-x 1 pi pi 109628 Nov 29 20:32 1mil3
pi@RPi4B:~/bacon-dev/examples $ /usr/bin/time ./1mil3
r LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:  ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
12.99user 0.00system 0:13.02elapsed 99%CPU (0avgtext+0avgdata 9356maxresident)k
0inputs+0outputs (0major+2157minor)pagefaults 0swaps
pi@RPi4B:~/bacon-dev/examples $

« Last Edit: November 30, 2019, 04:42:27 AM by John Spikowski »
ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 160
    • View Profile
    • ScriptBasic
Re: SALC Rasbian 32
« Reply #4 on: November 29, 2019, 12:43:11 AM »
FreeBasic

Code: FreeBasic
  1. ' FreeBasic - 1mil3.bas
  2.  
  3. DIM s AS STRING
  4. DIM t AS STRING
  5. DIM r AS STRING
  6. DIM SHARED a(1000001) AS INTEGER
  7. DIM x AS INTEGER
  8.  
  9. FOR x = 1 TO 1000000
  10.   s &= CHR(((x - 1) MOD 26) + 65)
  11.   a(x) += x
  12.   IF LEN(s) = 26 THEN
  13.     t &= s
  14.     s = ""
  15.   ENDIF
  16. NEXT
  17.  
  18. FOR x = LEN(t) TO 1 STEP -1
  19.   r &= MID(t,x,1)
  20. NEXT
  21.  
  22. PRINT "r LEN: " & LEN(r)
  23. PRINT "Front: " & LEFT(r, 26)
  24. PRINT "Back:  " & RIGHT(r, 26)
  25. PRINT "UBVal: " & a(1000000)
  26.  


pi@RPi4B:~/freebasic-dev/examples $ fbc 1mil3.bas
pi@RPi4B:~/freebasic-dev/examples $ ls -l 1mil3
-rwxr-xr-x 1 pi pi 30640 Nov 28 16:40 1mil3
pi@RPi4B:~/freebasic-dev/examples $ /usr/bin/time ./1mil3
r LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:  ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
0.53user 0.05system 0:00.60elapsed 96%CPU (0avgtext+0avgdata 7848maxresident)k
0inputs+0outputs (0major+2623minor)pagefaults 0swaps
pi@RPi4B:~/freebasic-dev/examples $

ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 160
    • View Profile
    • ScriptBasic
Re: SALC Rasbian 32
« Reply #5 on: November 29, 2019, 02:24:05 AM »
PHP Update

Code: PHP
  1. <?php
  2.  
  3. # PHP -1mil3-2.php
  4.  
  5. $s = "";
  6. $t = "";
  7. $a = array();
  8.  
  9. for ($x = 1; $x <= 1000000; $x++) {
  10.   $s .= chr((($x - 1) % 26) + 65);
  11.   $a[$x] = $x;
  12.   if(strlen($s) == 26) {
  13.     $t .= $s;
  14.     $s = "";
  15.   }
  16. }
  17.  
  18. $r = strrev($t);
  19.  
  20. echo "r LEN: ", strlen($r), "\n";
  21. echo "Front: ", substr($r, 0, 26), "\n";
  22. echo "Back:  ", substr($r, -26), "\n";
  23. echo "UBVal: ", $a[1000000],"\n";
  24.  
  25. ?>
  26.  


pi@RPi4B:~/php-dev/examples $ timex php 1mil3-2.php
r LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:  ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
0.43user 0.12system 0:00.57elapsed 98%CPU (0avgtext+0avgdata 38820maxresident)k
0inputs+0outputs (0major+9720minor)pagefaults 0swaps
pi@RPi4B:~/php-dev/examples $

« Last Edit: December 07, 2019, 10:19:10 PM by John Spikowski »
ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 160
    • View Profile
    • ScriptBasic
Re: SALC Rasbian 32
« Reply #6 on: November 29, 2019, 11:45:38 PM »
Python 3

Code: Python
  1. # Python 3 - 1mil3.py
  2.  
  3. s = ""
  4. t = ""
  5. a = [None] * 1000001
  6.  
  7. for x in range(1000001):
  8.   s += chr(((x) % 26) + 65)
  9.   a[x] = x
  10.   if len(s) == 26:
  11.     t += s
  12.     s = ""
  13.  
  14. r = "".join(reversed(t))
  15.  
  16. print("r LEN: {}".format(len(r)))
  17. print("Front: {}".format(r[:26]))
  18. print("Back:  {}".format(r[-26:]))
  19. print("UBVal: {}".format(a[1000000]))
  20.  


pi@RPi4B:~/python-dev/examples $ /usr/bin/time python3 1mil3,py
r LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:  ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
1.87user 0.09system 0:01.97elapsed 99%CPU (0avgtext+0avgdata 32660maxresident)k
0inputs+0outputs (0major+7192minor)pagefaults 0swaps
pi@RPi4B:~/python-dev/examples $

« Last Edit: November 30, 2019, 11:56:07 PM by John Spikowski »
ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 160
    • View Profile
    • ScriptBasic
Re: SALC Rasbian 32
« Reply #7 on: November 30, 2019, 07:42:29 PM »
The Swift round two post has been updated. The compiler now correctly prints middle.

The swift-5.1.2_armv7.tgz file is 206 MB.  I will have to upload it to the server and provide a link to download. This build is the current release with the latest updates as of build time.

AIR submitted an improvement to the Python script to not require numpy.

« Last Edit: November 30, 2019, 11:57:42 PM by John Spikowski »
ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 160
    • View Profile
    • ScriptBasic
Re: SALC Rasbian 32
« Reply #8 on: November 30, 2019, 09:26:43 PM »
8th (Jalih submission)

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


pi@RPi4B:~/8th-dev/examples $ /usr/bin/time ./1mil3
r LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:  ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
10.33user 30.38system 0:40.75elapsed 99%CPU (0avgtext+0avgdata 61464maxresident)k
0inputs+0outputs (0major+3677030minor)pagefaults 0swaps
pi@RPi4B:~/8th-dev/examples $

ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 160
    • View Profile
    • ScriptBasic
Re: SALC Rasbian 32
« Reply #9 on: December 01, 2019, 07:28:32 PM »
C (AIR submission)

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


pi@RPi4B:~/c-dev/examples $ gcc -O3 1mil3.c -o 1mil3
pi@RPi4B:~/c-dev/examples $ ls -l 1mil3
-rwxr-xr-x 1 pi pi 8140 Dec  1 11:23 1mil3
pi@RPi4B:~/c-dev/examples $ /usr/bin/time ./1mil3
r LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back: ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
45.56user 63.56system 1:49.17elapsed 99%CPU (0avgtext+0avgdata 23956maxresident)k
0inputs+0outputs (0major+7535448minor)pagefaults 0swaps
pi@RPi4B:~/c-dev/examples $

« Last Edit: December 01, 2019, 07:34:08 PM by John Spikowski »
ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 160
    • View Profile
    • ScriptBasic
Re: SALC Rasbian 32
« Reply #10 on: December 01, 2019, 09:45:22 PM »
Swift 5.1.2

Looking for a faster string reverse.

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

with string reverse

pi@RPi4B:~/swift-dev/examples $ /usr/bin/time ./main
r LEN:  999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:  ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal:  100000
322.51user 0.07system 5:22.70elapsed 99%CPU (0avgtext+0avgdata 13836maxresident)k
0inputs+0outputs (0major+3470minor)pagefaults 0swaps
pi@RPi4B:~/swift-dev/examples $


without string reverse

pi@RPi4B:~/swift-dev/examples $ /usr/bin/time ./main
r LEN:  999986
Front: ABCDEFGHIJKLMNOPQRSTUVWXYZ
Back:  ABCDEFGHIJKLMNOPQRSTUVWXYZ
UBVal:  100000
36.12user 0.04system 0:36.17elapsed 99%CPU (0avgtext+0avgdata 12800maxresident)k
0inputs+0outputs (0major+2925minor)pagefaults 0swaps
pi@RPi4B:~/swift-dev/examples $


ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 160
    • View Profile
    • ScriptBasic
Re: SALC Rasbian 32
« Reply #11 on: December 02, 2019, 12:50:07 AM »
GO Update (AIR submission)

Code: Go
  1. // GO - 1mil3-2.go - AIR
  2.  
  3. package main
  4.  
  5. import (
  6.     "fmt"
  7.     "strings"
  8. )
  9.  
  10. // Reverse returns its argument string reversed rune-wise left to right.
  11. // From: https://github.com/golang/example/blob/master/stringutil/reverse.go
  12. func Reverse(s string) string {
  13.     r := []rune(s)
  14.     for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
  15.         r[i], r[j] = r[j], r[i]
  16.     }
  17.     return string(r)
  18. }
  19.  
  20. func main() {
  21.     var s strings.Builder
  22.     var r = ""
  23.     var t strings.Builder
  24.     var a [1000001]int
  25.  
  26.     for x := 0; x < 1000001; x++ {
  27.         a[x] = x
  28.  
  29.         s.WriteByte(byte((x % 26) + 65))
  30.  
  31.         if s.Len() == 26 {
  32.             t.WriteString(s.String())
  33.             s.Reset()
  34.         }
  35.     }
  36.  
  37.     r = Reverse(t.String())
  38.  
  39.     fmt.Println("r LEN: ", len(r))
  40.     fmt.Println("Front: ", r[0:26])
  41.     fmt.Println("Back:  ", r[len(r)-26:])
  42.     fmt.Println("UBVal: ", a[1000000])
  43.  
  44. }
  45.  


pi@RPi4B:~/go-dev/examples $ go build 1mil3-2.go
pi@RPi4B:~/go-dev/examples $ ls -l 1mil3-2
-rwxr-xr-x 1 pi pi 1763559 Dec  4 18:33 1mil3-2
pi@RPi4B:~/go-dev/examples $ /usr/bin/time ./1mil3-2
r LEN:  999986
Front:  ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:   ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal:  1000000
0.10user 0.08system 0:00.16elapsed 112%CPU (0avgtext+0avgdata 16868maxresident)k
0inputs+0outputs (0major+4032minor)pagefaults 0swaps
pi@RPi4B:~/go-dev/examples $

« Last Edit: December 05, 2019, 02:39:59 AM by John Spikowski »
ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 160
    • View Profile
    • ScriptBasic
Re: SALC Rasbian 32
« Reply #12 on: December 02, 2019, 05:26:34 AM »
Nim (AIR submission)

Code: Text
  1. proc reverse*(str: string): string =
  2.   result = ""
  3.   for index in countdown(str.high, 0):
  4.     result.add(str[index])
  5.  
  6. type
  7.     milarray = array[1000001, int]
  8.  
  9. var
  10.     s = ""
  11.     t = ""
  12.     r:string
  13.     a:milarray
  14.  
  15. for x in 0..1000000:
  16.     a[x] = x
  17.  
  18.     s &= chr((x mod 26) + 65)
  19.  
  20.     if s.len == 26:
  21.         t &= s
  22.         s = ""
  23.  
  24.  
  25. r = t.reverse
  26. echo "r Len: ",r.len
  27. echo "Front: ",r[0..25]
  28. echo "Back:  ",r[r.len-26..r.len-1]
  29. echo "UBVal: ",a[1000000]
  30.  


pi@RPi4B:~/nim-dev/examples $ nim c -d:release onemil3.nim
Hint: used config file '/etc/nim/nim.cfg' [Conf]
Hint: system [Processing]
Hint: onemil3 [Processing]
Hint:  [Link]
Hint: operation successful (12410 lines compiled; 0.566 sec total; 10.754MiB peakmem; Release Build) [SuccessX]
pi@RPi4B:~/nim-dev/examples $ ls -l onemil3
-rwxr-xr-x 1 pi pi 57548 Dec  1 21:21 onemil3
pi@RPi4B:~/nim-dev/examples $ /usr/bin/time ./onemil3
r Len: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:  ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
0.06user 0.05system 0:00.12elapsed 99%CPU (0avgtext+0avgdata 10048maxresident)k
0inputs+0outputs (0major+2294minor)pagefaults 0swaps
pi@RPi4B:~/nim-dev/examples $

ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 160
    • View Profile
    • ScriptBasic
Re: SALC Rasbian 32
« Reply #13 on: December 03, 2019, 01:42:35 AM »
JavaScript

Code: Javascript
  1. // JavaScript - 1mil3.js
  2.  
  3. function reverseString(str){
  4.     let strn ="";
  5.     for(let char of str){
  6.         strn = char + strn;
  7.     }
  8.     return strn;
  9. }
  10.  
  11. var s = "";
  12. var t = "";
  13. var a = [1000001];
  14.  
  15. for (x = 1; x <= 1000000; x++) {
  16.   s += String.fromCharCode(((x - 1) % 26) + 65);
  17.   a[x] = x;
  18.   if(s.length == 26) {
  19.         t += s;
  20.         s = "";
  21.   }
  22. }
  23.  
  24. r = reverseString(t);
  25.  
  26. console.log("r LEN: " + r.length);
  27. console.log("Front: " + r.substring(0, 26));
  28. console.log("Back:  " + r.substring(-0, 26));
  29. console.log("UBVal: " + a[1000000]);
  30.  


pi@RPi4B:~/javascript-dev/examples $ /usr/bin/time node 1mil3.js
r LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:  ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
2.50user 0.27system 0:03.13elapsed 88%CPU (0avgtext+0avgdata 78340maxresident)k
38664inputs+0outputs (153major+19367minor)pagefaults 0swaps
pi@RPi4B:~/javascript-dev/examples $

ScriptBasic Project Manager/Facilitator

John Spikowski

  • BASIC Developer
  • ***
  • Posts: 160
    • View Profile
    • ScriptBasic
Re: SALC Rasbian 32
« Reply #14 on: December 03, 2019, 05:01:29 AM »
JADE (AIR submission)

Code: C++
  1. #include <jade.hpp>
  2.  
  3. MAIN
  4.     STRING s,t,r;
  5.     ARRAY<int> a;
  6.  
  7.     FOR( VAR x = 0 TO x<1000001 STEP x++ ) DO
  8.         a.push_back(x);
  9.         s += (CHAR)(x%26)+65;
  10.  
  11.         IF ( LEN(s) == 26 ) THEN
  12.             t += s;
  13.             s = "";
  14.         END
  15.     END
  16.  
  17.     r = REVERSE$(t);
  18.  
  19.     PRINT("r LEN: ",LEN(t));
  20.     PRINT("Front: ", LEFT$(r,26));
  21.     PRINT("Back:  ", RIGHT$(r,26));
  22.     PRINT("UBVal: ",a[1000000]);
  23. END
  24.  


pi@RPi4B:~/jade-dev/examples $ g++ -O3 -std=c++11 mil.cpp -ljade -o mil
pi@RPi4B:~/jade-dev/examples $ /usr/bin/time ./mil
r LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back:  ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
0.08user 0.04system 0:00.12elapsed 98%CPU (0avgtext+0avgdata 9012maxresident)k
0inputs+0outputs (0major+3762minor)pagefaults 0swaps
pi@RPi4B:~/jade-dev/examples $

ScriptBasic Project Manager/Facilitator