1
Programming Challenges / SALC Ubuntu 64
« on: December 15, 2019, 08:16:57 AM »
I reworked the FreeBasic submission, and ran it on my Ubuntu PI4:
riveraa@dpi:~/tmp$ timex ./1mil3
r LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back: ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
0.16user 0.02system 0:00.18elapsed 98%CPU (0avgtext+0avgdata 11596maxresident)k
0inputs+0outputs (0major+2623minor)pagefaults 0swaps
AIR.
EDIT: Cleaned up code.
Code: FreeBasic
- ' FreeBasic - 1mil3.bas
- DIM SHARED a(1000001) AS INTEGER
- function Reverse( byref source as string ) as string
- dim as integer first = 0, last = Len(source)-1
- while( first < last )
- Swap source[first], source[last]
- first += 1 : last -= 1
- wend
- return source
- end function
- sub mil()
- dim as string s,t,r
- dim as integer x,c
- FOR x = 1 TO 1000000
- c = (x - 1) MOD 26
- s &= CHR(c + 65)
- a(x) = x
- IF c = 25 THEN
- t &= s
- s = ""
- c = 0
- ENDIF
- NEXT
- r = Reverse(t)
- PRINT "r LEN: " & LEN(r)
- PRINT "Front: " & LEFT(r, 26)
- PRINT "Back: " & RIGHT(r, 26)
- PRINT "UBVal: " & a(1000000)
- end sub
- mil()
riveraa@dpi:~/tmp$ timex ./1mil3
r LEN: 999986
Front: ZYXWVUTSRQPONMLKJIHGFEDCBA
Back: ZYXWVUTSRQPONMLKJIHGFEDCBA
UBVal: 1000000
0.16user 0.02system 0:00.18elapsed 98%CPU (0avgtext+0avgdata 11596maxresident)k
0inputs+0outputs (0major+2623minor)pagefaults 0swaps
AIR.
EDIT: Cleaned up code.