Hey Petr,
thanks for the idea. Nice, nice one.
Created a dedicated forum.
Eros
Hi guys,
I think some coding challenge from time to time could be nice thing, showing how thinBASIC can be used.
I would recommend basic, common tasks.
Here is my idea:
Assignment
Write a script which will count all characters in text stored in inString.
You can use thinBASIC + all standard modules ( which come with default installation ).
Please use following skeleton, but code should be general - to count occurience of all possible characters from ASCII 0 to 255 ( do not optimize just for characters in "sample" string below )
[code=thinbasic]
dim inString as string = repeat$(1000,"Hi there, how it goes ?"+CHR$(0))
dim t1, t2 as quad
t1 = gettickcount
' ... insert code here ...
t2 = gettickcount
' ... display results here ...
[/code]
Output must look as on attached image ( sorted from most to less used ).
Winner is...
...person achieving shortest time of character count
End of contest
Friday 13th, April 2007 CHANGED
I am looking forward to your tries!,
Petr
P.S. My version is attached below but do not download it till Friday !
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Hey Petr,
thanks for the idea. Nice, nice one.
Created a dedicated forum.
Eros
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Sounds good, I am not good at optimizing but going the other way, slowing down
Might be good idea to test all final scripts on the same computer to see comparative speeds.
I hope have time to get involved, been hectic and still lots to do. Good luck!!
Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server
Hi,
Eros, thanks a lot for new section
kryton - do not give up
If you will need more time I can move the deadline few days more.
Comparsion on one computer would be nice, also it is the only method which should reflect results correctly.
Bye,
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Coding challenger?
I can't be out, what are rules? Can I develop a specific module?
Please (if possible) extend the expiration date, I will be in vacation until the april 10. >
Ciao,
Roberto.
http://www.thinbasic.com
Good idea, but count even characters below 32?
Roberto,
rule is simple: just count every ascii char in inString and for each report number of occurences.
Petr did also a substitute loop to be able to print out chars below code 32.
Ciao
Eros
PS: vacation? ???
Who authorized them ;D
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Hi,
Mike - yes, of course Full old good ASCII ( tabelator as well as cr, lf are used frequently )
Roberto - as you have no authorization for vacations ...
Ok, moved end of contest to Firday 13th to make contest accessible for all.
But I can't accept module as contest entry, you would depress us with some assembly light speed ;D
Just thinBASIC + any of standard modules.
Bye and thanks,
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
OK, here it is my version.
I will entitle it "The power of pointers". See results
Ciao
Eros
UPDATED: added comments
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Wow I see, you are power(s basic) users ;D
Here is my version
[code=thinbasic] uses "Stat"
dim inString as string = repeat$(1000,"Hi there, how it goes ?"+CHR$(0))
dim n as long = len(inString)
dim aData1(n) as byte
dim aData2(n*2) as DWORD
dim aData(256) as string
dim i as long
dim sText as string
dim s as string
dim t1, t2 as quad
t1 = gettickcount
poke$(varptr(aData1(1)),PeeK$(STRPTR(inString),n))
Stat_CopyArray(aData1, aData2)
Stat_Histogram(aData2,1)
for i=1 to 256
if aData2(i+n)>0 then
select case aData2(i)
case 0
s=" NUL"
case 32
s=" SPC"
case else
s=" "+chr$(aData2(i))
end select
aData(i)=ltrim$(str$(aData2(i + n)))+" "+s
end if
next
array sort aData, descend
for i=1 to 256
if len(aData(i)) then
sText=sText+aData(i)+$CRLF
end if
next
t2 = gettickcount
msgbox 0, "Result of text analysis ("+ltrim$(STR$(n))+" bytes)"+$CRLF+$CRLF+sText+$CR+$CR+"Operation took:"+STR$( (t2-t1)/1000, 3)+" seconds", %MB_OK or %MB_ICONINFORMATION, "Results"
[/code]
I don't post result here, please take a pleasure to discovery it by yourself.
Regards,
Roberto
http://www.thinbasic.com
Bookmarks