SRL Archive - Other Scripts

The League of Scripters


mixster

2009-09-17 20:37:07

Welcome!

This topic will be the home to the "League of Scripters" unofficial competition & league, where every week I'll be putting up a problem, which is open for anyone to try and solve!

The emphasis on the problems is not to give hard tasks, but tasks that have plenty of room for improving their speed. As all skilled scripters will know, Scar's main flaw is in its slow pace, so being able to take a slow function and speeding it up a lot is a vital ability for kick ass scripts.

Points will be awarded for the first submissions and for the fastest scripts. As I am unsure of how many people will enter, I can't give exact numbers, but probably the points will be distributed for the first half of entries and for the fastest third of entries, with the fastest script getting a bit more points than the first entry.

Everyone is open to submit a script to solve the problem and you are allowed 2 submissions, with the first being completely ignored if you send in a second. 3rd submissions onwards will not be counted, so don't be too rash in deciding to submit. If a script doesn't work, then it can't get any points, but Scar version based changes will be corrected as needed.

All entries are to be PM'd to me. Unless stated, you are fine with me publishing your script for each other to learn from. If you disagree, please say so in the PM, however you must then consent to me being able to send it to an independent judge in case anyone thinks I'm being biased or if I am unable to judge for whatever reason.

Plugins are not allowed at all. However, you may rely on external sauces as long as they accessible from within Scar - this is as much about ingenuity as it is about scripting ability. Likewise, all scripts must be Scar scripts and be in the form of a function. I'll be using Scar 3.15b to run the speed tests. If you feel that my times differ from yours, bear in mind I probably have a much worse computer. Likewise, if you feel that my Scar version may affect the times, do say and I'll run re-tests through a newer version, but I don't see any future problems that would be affected by changes in Scar version.

It will hopefully run a while and at the moment there are no prizes, but there is a possibility for prizes in the future.

Any questions, ask else try to leave the topic spam free - no need to tell me you are planning to participate as I'll get the idea when you send in a submission :)

League table:
Nielsie = 18 + 5; 23
Raymond = 12;
Cardin = 10;
Bullzeye = 10;
Killerdou = 10;
DansTheMan = 8;
Senrath = 6;
RM = 6;
Markus = 4;
Toot = 2;
Widget = 2;
ToF = 1;
Nadeem = 0;

Problem 5
Your problem, whether or not you choose to accept it, is two fold this week. These are not tiered tasks - you may enter one and one only. The points awarded will depend on how many people submit for the same problem - the more that enter the same, the more points awarded for the winner.

The problems will be classed as problem A and problem B.
Problem A
A most unfortunate problem has arisen - RS has updated and no longer uses the same font even in the same piece of uptext! All that you know is that they use some what consistent colours much like they do now, but they differ enough from char to char that someone will have to make a whole new approach to text finding to do this! Luckily, someone has, but they are ahving trouble getting the input to use and this is where you come in!

Problem A requires an algorithm that takes in a bitmap of the top left quarter or so of the main screen and returns a TPA of all points where there is text. It is to be believed that no other text apart from the uptext is present, however similar colours may also be there, so the more accurate the better. Likewise, it shouldn't be restricted to just one uptext colour as we all know that the colours differ for different things ie main bit that is in white, a little yellow bit to show the default NPC action then another little white bit for how many other options there are. For testing, it should be able to work with the current RS uptext. This function should therefore have a layout similar to:
function mixsters_UptextFilterer(bitmap: Integer): TPointArray;

Problem B
Ok, so the scene continues from Problem A - RS has updated and uptext has been ruined. However, some intelligent individual notices that all the characters can successfully be converted to a consistent font. How to do this? Why, it's "easy" - the chars have a border colour that goes all the way around them and if he grabs this border and passes it through his own complex function, he can generate a TPA outline of the character that is consistent to a font. However, to match it against a font, he need an ingenious way to turn the TPA border into a solidly filled TPA.

This is where you come in. You must create an algorithm that takes in a TPA of a single character's outline. You must then fill in the TPA so that a TPA of the character is returned with a solid fill. Be careful though, some tricky characters like 'H' or 'O' don't have a completely solid fill - they too much be returned correctly. As far as this problem goes, you can use a TPA generated from an item's border for testing or draw your own shapes and use them. For presentation, the function should resemble:
function mixsters_TPAFiller(input: TPointArray): TPointArray;
But processing as a procedure with input as a var is also fine.

The deadline will be in one week, but if there is a general mood of it being a bit pressurising, I will be fine with extending it.

On another note, I think this will be the last of this season. Unless someone else wants to run it for a month or so, I think I will put it away and focus on the Jr comp as well as refining my current layout and organisation for this competition so that it can make a come back and hopefully run a lot smoother and generate a real buzz :)

Problem 4 results
1 entry.
nielsie95 was the only entrant and I am quite sure it runs (had to get someone else to test though since Scar was being silly). Congratulations to nielsie! 5 points awarded, though I really could of and should of given more, but then he would get too far in front :) Script can be found here.

Problem 3 winning script by nielsie can still be found here.

Sir R. M8gic1an

2009-09-17 21:11:00

I am still awaiting the first couple of problems as it is past 6PM :)

~RM

senrath

2009-09-17 21:18:16

From: Rasta Magician
I am still awaiting the first couple of problems as it is past 6PM :)

~RM


He said they'd go up Friday.

Naum

2009-09-17 21:22:51

From: senrath
He said they'd go up Friday.


So Thursday is the 17th, wow?

6pm GMT = ~15 mins from when I post this topic if you are unsure of how it relates to you


Mixster, silly boy! Change Friday to Thursday, or 17th to 18th!

Sir R. M8gic1an

2009-09-17 21:23:56

From: mixster
Friday 17th of September 2009


Someone's been taking too many narcotics >.>

~RM

mixster

2009-09-17 22:16:02

No one saw anything.
Long days do that to me - I was just trying to be somewhat accurate :(

mixster

2009-09-18 20:48:27

Week one:
Lower: Generate all prime numbers, 2 through 1000 (inclusive). Script must be able to handle prime number generation from 2 to x. Also, only 2 can be used for the starting "prime number" array - all others must use an algorithm to find them. The script should produce an array of integers which holds the prime numbers. As a checking point, there should be 168 primes found.

Upper: Break down the number 1578833364 into all of its prime factors. The prime factors are all under 1000, but it should work it out as it goes as the highest prime may be much lower than that and so calculating the extra primes would be wasteful. As a checking point, 7 numbers are multiplied to make the number (may or may not be multiple number of same primes).

Harry

2009-09-18 20:50:17

So basically, a unique /r/equest?

nielsie95

2009-09-18 21:53:23

I have entered :)

caused

2009-09-18 22:02:12

hah, we did that in school once. Gotta give it a try with scar.. when i find the time though….

Sir R. M8gic1an

2009-09-18 22:51:20

I only found 96 primes :(

edit: nvm, got them all :)

took: 328 ms


~RM

R0b0t1

2009-09-19 02:38:42

Would compete but too lazy.

Dan Cardin

2009-09-19 04:32:44

i thought i was too lazy, but ended up with some more knowledge in the end, so im good.

mixster

2009-09-19 15:23:15

So far a handful of entries - will be open till Wednesday midnight GMT for anyone thinking it's too late or they don't have the time.
I would also like to encourage Jr Members to participate - prove to the Members that you can compete with them!

Nadeem

2009-09-19 17:47:42

oooh this is awesome :) will submit mine soon :)

Edit2:
Completed! :p



~NS

Torrent of Flame

2009-09-19 20:10:04

Submitted.

Time Running: 31 ms.
Successfully executed

Without printing the Primes, keeping them in a TIntegerArray.

Dan Cardin

2009-09-20 06:04:55

From: Torrent of Flame
Submitted.

Time Running: 31 ms.
Successfully executed

Without printing the Primes, keeping them in a TIntegerArray.

our Method`s are identical. Mine is 31ms aswell. Using outside knowledge seems like cheating.

senrath

2009-09-20 07:20:43

Heh, the Lower problem took me longer than the Upper one because I had accidentally told my script to find all prime numbers from 2 to 2000 instead of 1000. Oops.

Nava2

2009-09-20 08:06:12

Is this anything like the league of extraordinary gentlemen?

ZaSz

2009-09-20 08:22:34

The league of extraordinary scripters.

Widget

2009-09-20 12:02:09

The league of extramediocre scripters :D

mixster

2009-09-20 13:02:19

I was actually going to call it the League of Extra Ordinary Scripters, but it sounded slightly patronising to me :)

Torrent of Flame

2009-09-20 15:00:53

Dan Cardin, huh? Mine flickers between 16-40ms randomly. It isnt a constant time.

Torrent of Flame

2009-09-20 15:04:43

Hmmmm. The algorithm must be similar then.

senrath

2009-09-20 15:20:00

From: Torrent of Flame
Hmmmm. The algorithm must be similar then.


Probably. There really aren't all that many ways to go about these two problems.

Torrent of Flame

2009-09-20 15:37:18

From: senrath
Probably. There really aren't all that many ways to go about these two problems.


Exactly, there is only a little amount of algorithm research google can turn up, so most are probably similar.

Nadeem

2009-09-20 17:05:39

I used a bit of Sieve of Eratosthenes and Sieve of Atkin algorithim in the most simplest form I could get it in :P Those two seem to be the most common. I was thinking of using the Wilson's Theorem but found out its only for Wilson Prime numbers…

Are we allowed to re-submit? :p I might add and tune a bit more since everyone is getting similar results.



~NS

nielsie95

2009-09-20 17:22:30

We never learned about primes (yet), so I just brew something up using the Wikipedia description (I guess it's the Sieve of Eratosthenes).

senrath

2009-09-20 17:31:00

I just applied a naive primality test to each number from 3 to n (1000 in this case).

Gu3st...

2009-09-20 21:39:08

I was hoping for more advanced scripting :/
Like "Make a script that will fill the gaps between the lines in this pic: http://img16.imageshack.us/img16/1754/asdfasdfo.png "

ian.

2009-09-20 21:50:26

From: Zyt3x
I was hoping for more advanced scripting :/
Like "Make a script that will fill the gaps between the lines in this pic: http://img16.imageshack.us/img16/1754/asdfasdfo.png "



var
x, y: Integer;
begin
for x := 29 to 621 do
for y := 87 to 735 do
if(GetColor(x, y) = 16777215)then
ClickMouse(x, y, True);
end.

Gu3st...

2009-09-20 21:51:46

From: ian.

var
x, y: Integer;
begin
for x := 29 to 621 do
for y := 87 to 735 do
if(GetColor(x, y) = 16777215)then
ClickMouse(x, y, True);
end.
that would change the color clWhite to black, not to fill the gaps…

Torrent of Flame

2009-09-20 21:53:29

From: Zyt3x
I was hoping for more advanced scripting :/
Like "Make a script that will fill the gaps between the lines in this pic: http://img16.imageshack.us/img16/1754/asdfasdfo.png "


You tried either of them yet? And made it fast, ie, under 50ms?

senrath

2009-09-20 21:55:49

From: Zyt3x
that would change the color clWhite to black, not to fill the gaps…

It would fill the gaps quite well. It would just do other things as well.

ian.

2009-09-20 21:57:19

From: Zyt3x
that would change the color clWhite to black, not to fill the gaps…


Well I would say that all the white is a gap.. so if you run that in paint/gimp/ps (with correct coords) it will turn it all black.. :p

Gu3st...

2009-09-20 22:09:26

From: Torrent of Flame
You tried either of them yet? And made it fast, ie, under 50ms?
Yes, already did that. Not for this competition, and it was a long time ago so I do not have the script anymore.

bullzeye95

2009-09-20 23:37:20

Do the algorithms need to be able to accept any number (up to the maximum number an integer can hold of course), or can they be optimized to the numbers you are giving us? For example, you have said that there are 7 prime factors for 1578833364. Are we allowed to set the length of the array that holds these numbers to 7, or must we make the function/script able to find the factors of numbers that have more than 7 factors?

Dan Cardin

2009-09-21 00:05:37

From: Torrent of Flame
Dan Cardin, huh? Mine flickers between 16-40ms randomly. It isnt a constant time.
mine is 31 ms always. This contest would be better if one wasnt supposed to look stuff up. My entry before i did was crap, but it was better because it used only my own knowledge.

mixster

2009-09-21 01:23:12

Lots of stuff to reply to, fun times!

From: bullzeye95
Do the algorithms need to be able to accept any number (up to the maximum number an integer can hold of course), or can they be optimized to the numbers you are giving us? For example, you have said that there are 7 prime factors for 1578833364. Are we allowed to set the length of the array that holds these numbers to 7, or must we make the function/script able to find the factors of numbers that have more than 7 factors?

As I didn't define it and entries have done both, I would say it can be tailored to this specific problem, but preferred to not be. It was a bit of a miss on my part and I'll try to make sure it doesn't happen again. Either way though, it shouldn't overly affect the end time too much, so it's up to you.

From: Zyt3x
I was hoping for more advanced scripting :/
Like "Make a script that will fill the gaps between the lines in this pic: http://img16.imageshack.us/img16/1754/asdfasdfo.png "

This was really just a starter one to see how many people would actually enter. An easy to do, hard to do well problem is perfect as most people can have a go and succeed, but those with the know-how can do it oh so much better than those who do not.

From: Dan Cardin
mine is 31 ms always. This contest would be better if one wasnt supposed to look stuff up. My entry before i did was crap, but it was better because it used only my own knowledge.

From: Torrent of Flame
Exactly, there is only a little amount of algorithm research google can turn up, so most are probably similar.

From: senrath
Probably. There really aren't all that many ways to go about these two problems.

It takes real skill to take the same code and make it more efficient, which is pretty useful when it comes to scripting. It's all well and good finding an algorithm online and converting it into Scar, but knowing the little tweaks that take a bit of time from here and there really shows.

From: Torrent of Flame
Mine flickers between 16-40ms randomly. It isnt a constant time.

I can tell you that it just about always flickers between values, but I run them multiple times then get the most common quick time, which will usually emerge from being run 5 times. If you have very little open, including system stuff, then you should end up getting pretty constant times, but it of course also depends on what you are using to time it (I'm using Nielsie's timing stuff that relate to API calls from a while back).

Dan Cardin

2009-09-21 03:54:47

From: mixster
It takes real skill to take the same code and make it more efficient, which is pretty useful when it comes to scripting. It's all well and good finding an algorithm online and converting it into Scar, but knowing the little tweaks that take a bit of time from here and there really shows.

still silly.

Torrent of Flame

2009-09-22 23:55:43

b..b..b..but i did make it more efficient, it was like running at 100ms when I reserached it :<

Markus

2009-09-23 21:29:15

100ms??
I can do both challenges in around 7ms O.o

Widget

2009-09-23 22:16:47

7ms? I can't get mine past 14 =\

Markus

2009-09-23 22:41:04

Depends on the computer ofcourse.
My "lower" submission gets me 6.7ms (started at 14.5ms but managed to get it a lot down), and the "upper" 7.15ms (haven't spent much time optimising it though).

Torrent of Flame

2009-09-23 23:05:42

From: Markus
Depends on the computer ofcourse.
My "lower" submission gets me 6.7ms (started at 14.5ms but managed to get it a lot down), and the "upper" 7.15ms (haven't spent much time optimising it though).


It started at 100ms and it averages like 25ms now. Also Markus, do remember you're a pro scripter.

mixster

2009-09-23 23:50:57

Announcing the entry deadline as 3pm GMT tomorrow (18 hours time as of this post). If it's not in by then, then it is not to be run for the final testing time. I am having a bit of laptop trouble, but as long as you PM'ed me the entry I'll be able to access and so time it accurately.

So, as the deadline is early afternoon tomorrow, the results will be up later in the afternoon and the next problem will be up day after tomorrow! You can expect a large increase in difficulty, but also what many will view as a better test of scripting ability (hopefully).

Gu3st...

2009-09-24 00:05:12

From: mixster
This was really just a starter one to see how many people would actually enter. An easy to do, hard to do well problem is perfect as most people can have a go and succeed, but those with the know-how can do it oh so much better than those who do not.
Ah, thank you for explaining that to me :)

mastaraymond

2009-09-24 00:37:35

From: mixster
Announcing the entry deadline as 3pm GMT tomorrow (18 hours time as of this post). If it's not in by then, then it is not to be run for the final testing time. I am having a bit of laptop trouble, but as long as you PM'ed me the entry I'll be able to access and so time it accurately.

So, as the deadline is early afternoon tomorrow, the results will be up later in the afternoon and the next problem will be up day after tomorrow! You can expect a large increase in difficulty, but also what many will view as a better test of scripting ability (hopefully).

Better be so ;)

Dan Cardin

2009-09-24 01:39:02

increase in difficulty isnt necessarily necessary. Just something that takes a lot more thinking with more ways to do it. I guess thats still kind of describing more difficulty, but i would rather have something thats very doable by most people that just takes a lot of bit of thinking/good scripting to not suck rather than something that is just technically difficult which would limit the number of ways to accomplish it usually.

Sandstorm

2009-09-24 01:54:35

Lol, mine is getting roughly 210 milliseconds, and it's missing the first ten-ninety primes (depending on what you put in) :(.

Edit:

Aha! Forgot a + 1, finds all the primes now, but still takes 210 milliseconds xD.

Edit2:

Fastest time is 146 milliseconds now :D. Averaging 165-170.

~Sandstorm

bullzeye95

2009-09-24 03:12:22

2.2ms, 1ms when not transferring results from the boolean array to the integer array.
/me PMs mixster and hopes he has the fastest script

EDIT: That's for the lower one. I get 0.39ms for the upper one.

Sandstorm

2009-09-24 03:28:07

Christ Bullzeye, API calls or something? Make sure to let us know how you did it o.o.

~Sandstorm

bullzeye95

2009-09-24 03:29:58

From: Sandstorm
Christ Bullzeye, API calls or something? Make sure to let us know how you did it o.o.

~Sandstorm


Nah, pure SCAR. If I win (which I probably won't on the prime factorization one, because I didn't optimize it much, but I might win the other one), I'll post it if mixster doesn't, but he said he will post them.

Markus

2009-09-24 10:35:03

You're cheating with a E8400 OC'ed to 3.8ghz. At least I'm still running at stock :p

Widget

2009-09-24 11:26:48

I think I might be doing it the same way as Bullzeye then, except i'm on a 3.0GHz stock E8400 and mine is 8 times slower xD

bullzeye95

2009-09-24 15:28:10

From: Markus
You're cheating with a E8400 OC'ed to 3.8ghz. At least I'm still running at stock :p


No0b, you just fail at making fast c0dez :rolleyes:

nielsie95

2009-09-24 17:24:58

Very nice timings!
Mine's stuck at 30ms for the lower one.

mixster

2009-09-24 21:01:58

Results for first week released!
Congratulations Bullzeye who submitted the fastest script for upper problem and DansTheMan who did so for lower!
Further congratulations to other competitors and a small additional special thanks to Nielsie for the awesome timing being used :)

bullzeye95

2009-09-24 23:49:14

Mixster, did I get the fastest time for the lower also, even though I didn't formally submit that one? Because judging by the times I'm getting on DansTheMan's, mine is about twice as fast, but I can't seem to find my flash drive with my script on it to compare..

Also, W0Ot I'm winning.

senrath

2009-09-25 00:02:32

Wait, we were only allowed to submit for one problem or the other? Lame. Can you scrap my lower submission and regrade me on my upper submission, then?

Markus

2009-09-25 00:10:54

Protest!
mixster: I sent you my upper one but you didn't rate/time it :(
oh well, it was fun :p Looking forward to the next league!

nielsie95

2009-09-25 00:34:59

Nice, Bullzeye :)

Gu3st...

2009-09-25 01:25:30

Good job! :)
And that was extremely fast : o

mixster

2009-09-25 01:33:46

From: bullzeye95
Mixster, did I get the fastest time for the lower also, even though I didn't formally submit that one? Because judging by the times I'm getting on DansTheMan's, mine is about twice as fast, but I can't seem to find my flash drive with my script on it to compare..

Can only enter for either upper or lower, so I went with your upper.

From: senrath
Wait, we were only allowed to submit for one problem or the other? Lame. Can you scrap my lower submission and regrade me on my upper submission, then?

Same as above, though I went for your lower. I can't adjust right now due to the bizarre state of my laptop, but I shall attempt to before I release the next problem

From: Markus
Protest!
mixster: I sent you my upper one but you didn't rate/time it :(
oh well, it was fun :p Looking forward to the next league!

I went for the latest one I had in my inbox, which was the lower one :(

senrath

2009-09-25 01:42:28

From: mixster

Same as above, though I went for your lower. I can't adjust right now due to the bizarre state of my laptop, but I shall attempt to before I release the next problem


Might wanna edit the first post to emphasize that fact, as I'm obviously not the only one who missed that little rule.

bullzeye95

2009-09-25 02:35:54

From: mixster
Can only enter for either upper or lower, so I went with your upper.


I know, I was just wondering if mine was faster than Dan's, not asking for points for it.

Widget

2009-09-25 12:21:51

From: mixster
Everyone is open to submit a script to solve the easy or hard problem and you are allowed 2 submissions, with the first being completely ignored if you send in a second. This means you can do a different problem if you want to or it can just be an improved version. 3rd submissions onwards will not be counted, so don't be too rash in deciding to submit. If a script doesn't work, then it can't get any points.


You used my first version, which is rather slow compared to the second =\

Markus

2009-09-25 18:37:29

mixster: you didn't rate my upper script :(

Oh well, Primegen v2 is 5.25ms now (compared to the old 6.75ms), so it's getting faster and faster :p
Already three times as fast as the original version.

mixster

2009-09-25 20:06:54

Bah, sorry for all the mix ups. I really was in a but of a rush to get through them all yesterday - laptop hdd playing up means I have to spend half my time on DSL, which I haven't got to run Scar yet, so I was speedily getting through everything. I'll attempt to correct all problems as soon as possible - hopefully by Monday at latest.

At this moment, I'm going to work on finalising the problem for this week. As the upper and lower has caused probably a lot more problems than it has, I'll try to just set one that is somewhat in the middle of the two this time and everyone can see how that works. Likewise, I'll be setting out a more strict outline for submissions so that everyone's can easily be compared and so on and so forth - this problem should be up in under an hour as long as my laptop doesn't die :)

Ok, so first problem fixed. Using the correct script from Widget, he got 24ms and so ToF and Nadeem were pushed down a place. First post league table has been fixed using this.

Markus: Like I said, I used your second PM entry. You should have PM'ed me the right one :)

Senrath: Adjusted to only 1 problem now, but if you want me to I can still run your upper entry and then correct the table as needed regarding this.

Bullzeye: You can always run it yourself, but I did not run as your PM said to use the upper amongst other things, so pretty much left the lower alone.

People at large: Only 1 problem now - having two seemed to have caused confusion. However, I am contemplating having 2 levels again, with the lower being Scar scripts and the upper being sauces that can be compiled using FPC (Free Pascal Compiler). Unsure as to how this will go, but we will see :)

Naum

2009-09-26 00:28:07

Does the function, that finds and groups the points, have to be made entirely by ourselves, or can we use anything from the pre-loaded plugins (SplitTPA etc)?

senrath

2009-09-26 01:07:23

I would like you rerun with my upper, if it's not too much trouble.

mixster

2009-09-26 13:31:46

From: NaumanAkhlaQ
Does the function, that finds and groups the points, have to be made entirely by ourselves, or can we use anything from the pre-loaded plugins (SplitTPA etc)?


Anything that comes with standard Scar & SRL, so WizzyPlugin stuff is fine.

Edit: After having a discussion with Raymond, I have decided to half ban plugin related things.
I did in the first post state that no plugins were to be allowed and so primarily for that reason, using WizzyPlugin functions are banned. However, everything in WizzPlugin does have its sauce published freely, so you can implement anything in the WizzyPlugin in Scar then use that. Direct calls to SplitTPA or TPAToATPA or the like will be invalid for submissions. If you do use them, then I will allow an additional entry to correct this as I did say it was ok, then change it after a while.

Killerdou

2009-09-27 12:13:55

Don't bother with SplitTPA, my algo is faster in pure scar :)~1 second right now vs splittpa's 1.7 seconds :) Working on a way to make it even faster :)
Edit: 0.85 seconds now :)

mastaraymond

2009-09-27 13:03:58

From: Killerdou
Don't bother with SplitTPA, my algo is faster in pure scar :)~1 second right now vs splittpa's 1.7 seconds :) Working on a way to make it even faster :)
Edit: 0.85 seconds now :)

And I thought 60 secs was fast in pure scar :o

mixster

2009-09-27 13:26:13

Don't worry - he told me he was cheating!

Killerdou

2009-09-27 14:11:31

Cheating as in, I do what you want me to do, but not the way you want me to do it :)

Edit: 0.75 seconds now :)
Edit2: 0.70 secs

Markus

2009-09-30 20:40:50

*Hands over a SplitTPA from Wizplugin with his name splashed on it*

mixster

2009-10-02 01:14:30

Problem 2 has been concluded! See bottom of first post for details and attachment for submitted scripts! If you didn't download the test image, but still wanted to see Raymond's in action, Killerdou has a string version in his you can mod into Ray's or convert back to an image, save and use that.

Hoping to see more entrants for next weeks problem, so do come back soon!

bullzeye95

2009-10-02 01:51:37

Damn, I assumed it ended tomorrow, a week after it was given…
Meh, didn't really feel like working with TPAs anyways, and apparently neither did many other people :rolleyes:

EDIT: Waitwut Ray got ponits for
function raymonds_TPASplitter(tp: TPointArray; dist: Integer): array of TPointArray;
begin
Result := SplitTPA(tp,dist);
end;
?? Didn't you say in the first post that you're allowed to use outside resources other than plugins?

Dan Cardin

2009-10-02 02:48:50

huh?! i didnt even know we had new problems! You should really advertise their starting more. What was it, its not in the first post anymore.

Killerdou

2009-10-02 08:57:03

http://pastebin.com/m5cc6d4b6 :)

mastaraymond

2009-10-02 15:23:08

From: bullzeye95
Damn, I assumed it ended tomorrow, a week after it was given…
Meh, didn't really feel like working with TPAs anyways, and apparently neither did many other people :rolleyes:

EDIT: Waitwut Ray got ponits for
function raymonds_TPASplitter(tp: TPointArray; dist: Integer): array of TPointArray;
begin
Result := SplitTPA(tp,dist);
end;
?? Didn't you say in the first post that you're allowed to use outside resources other than plugins?

http://pastebin.com/f6118c7d9

Bobarkinator

2009-10-02 16:00:53

I think you should include the problem in a text file in the .rar file. Because I never got a chance to look at problem #2

mixster

2009-10-02 21:22:29

My bad regarding Ray's - since it was virtually just Ray until yesterday, I hadn't saved an up to date version.
DanCardin, it's a weekly thing - of course there will be new problems often!
Bobarkinator, I thought I had, my bad - basically the problem was just TPA into an ATPA with grouped points, as SplitTPA does.

New problem coming up shortly!

Dan Cardin

2009-10-02 22:30:26

i dont check this thread unless it comes up with new posts, so it would greatly helpful if you could bump it with the newest problems in the post.

mixster

2009-10-02 23:19:57

Lies, I can just make a post saying "There's a new problem!" and you can read that and see that it is most likely that I have uploaded a new problem.

Anyway, there is a new problem! String sorting in 3 different ways with the option of case sensitivity or not. Check first post for details and post any queries here!

Dan Cardin

2009-10-03 02:45:42

is it just me or is alphabetizing abnormally difficult? i thought it would be easy, but now that i get to doing it, all my Method`s are rather convoluted.

nielsie95

2009-10-03 12:18:23

With case insensitivity uppercase comes before lowercase, but is that just with the same word? For example:

Hello
Hug
hello
Zuperman

or should the lower hello be under the upper Hello? I think as it is now would be correct?

And you say characters like dots should have an equal value, but should there be looked further than that? For example:

=zz
.lol

should lol come before zz?

And just to be sure:

HELLO

comes before HELLO1?

Oh, and how do you define a word? Is lol-o-matic one word?

mixster

2009-10-03 18:31:50

With case insensitivty, hello = HELLO. With case sensitivity, HELLO would come before hello. Hello, Hug, hello, Zebra would be the correct way to order them. With =zz and .lol, I meant that it should be thought as 0zz and 0lol, so you then go onto the next char, thus meaning that it would be .lol then =zz. Words are defined by spaces only. If they are follow by punctuation, then that punctuation is part of the word. Likewise, shorter words that start the same would be come before longer ones, ie "hello" and "hell" would be ordered to "hell", "hello". "The quick brown fox", "The quick brown fox jumped over the lazy dog" would be the correct order for those two.

If there are any other questions, do ask :)

Dan Cardin

2009-10-03 20:20:42

i personally am going to be giving an order to my non alphanumerics i hope thats alright.

nielsie95

2009-10-03 20:54:49

Thanks for clarifying :)
I entered.

1,4ms for the given example (s := ['A', 'b', 'a', '.', '6', '5']).

mixster

2009-10-03 23:15:50

From: Dan Cardin
i personally am going to be giving an order to my non alphanumerics i hope thats alright.


It's not really all right. There were two purposes to it:
1) To stop people purely relying on ordinal values of chars
2) It means that words can be better sorted in general - "hello world" and "hello-world" - which one, in common terms, would be classed first alphabetically? I would think of them as equal.
In most cases though, it's just because things like "hey, how are you?" and "hey - how are you?" would be correctly ordered when relying upon ',' being equal to ' '.
The only time it would really have any impact is when stuff like "hey, there" and "hey. there" comes up - which one should go first? Eek!

Dan Cardin

2009-10-04 02:28:49

well from all ive heard of alphabetizing, spaces go before anything. As for not having them ordered because of ordinal values, that really doesnt matter. 1 or 2 lines from the code in my head would be able to not have their order matter. but it seems to me that alphabetizing should have a static output as long as the actual strings remain the same, regardless of their order, but with not allowing them to have an order, the output will change depending on what comes where.

mixster

2009-10-04 18:47:44

You still haven't told me which you think would logically come first - "," or ".". How about '&' and '@'? It's for the very reason that there are so many non-alphanumeric characters that don't really affect the string at all that I don't want them sorted by them.
Also, it may only be 1 or 2 more lines of code, but it's still something else to test entries on :)

I'll generally only be using strings that make use of spaces, quotation marks, inverted commas, hyphens, commas and periods (heh) though, so it's not that important. However, they will most likely be things like "Hey, how are you?" and "Hey. Having a good day?" - I would like them to be sorted based on alphanumeric characters rather than non ones.

Nadeem

2009-10-04 22:18:35

omgsh i totally forgot about this O:

anyway im going to submit mine soon (:



~NS

Dan Cardin

2009-10-05 03:11:58

inverted commas? and what if they are the same? should it not matter? or are we to do them specifically in their origional order? (i keep acting like im entering, but if i dont find some time to actually write some stuff, i shant be able to ={)

mixster

2009-10-05 22:03:33

Well, it was basically just that if char x of string A is non-alphanumeric, where as char x of string B is, then string A comes before it. If they are both non-alphanumeric, then the next char is checked. If they are both alphanumeric, then they are compared to see alphabeticness :)

mixster

2009-10-07 19:31:46

Reminding everyone that all entries must be sent in in the next 24 hours or so!
Only the one entry so far, so it's all to gain with any submission!

Due to board going down for a bit, extending to Saturday 3pm GMT (22 hours from this edit) and will then post up next challenge at the same time as entry time closes.

Ron

2009-10-10 11:18:51

Problem3 kindof.


// http://www.villavu.com/forum/showthread.php?t=50949
{
to do:
- order the words from highest occ to lowest occ
- if its the same occ then alphabetize the strings
- number of occurrences of a string in a string
}
program HalfAssedProblem3ByRon;

const
strA = 'abcABD56.ask39DUIAS';
strB = 'hello hello how are you? you are an asshole are are!';

function str_alphabetize(str : String) : String;
var
str2 : String;
i, n : Integer;
arrDec : Array of Integer;
begin
n := length(str);
SetArrayLength(arrDec, n);
for i := 1 to n do
arrDec[ i - 1 ] := ord(str[ i ]);
BubbleSort(arrDec);
for i := 0 to n - 1 do
str2 := str2 + chr(arrDec[ i ]);
Result := str2;
end;

// case sensitive
function In2DArray( value : string; arr : T2DStringArray; twodindex : integer ) : integer;
var
i, n : integer;
begin
n := getarraylength(arr);
result := -1;
for i := 0 to n - 1 do
begin
if ( arr[ i ][ twodindex ] = value ) then
begin
result := i;
break;
end;
end;
end;

function str_numOfOccurrences( str : String ) : T2DStringArray;
var
word : string;
arr : T2DStringArray;
n, posSpace, index : Integer;
lastWord : Boolean;
begin
str := trim(str);
posSpace := pos(' ', str);
if ( posSpace = 0 ) then
begin
result := [str, '1'];
exit;
end;
n := 0;
while ( posSpace > 0 ) or ( lastWord ) do
begin
// grab str if last word since the rest of the str has been deleted
if ( lastWord ) then
word := str
else // otherwise copy word from 0th place to position of space
// delete word from string and grab next position
begin
word := copy(str, 0, posSpace - 1);
delete(str, 1, posSpace);
posSpace := pos(' ', str);
end;
// check if word is in array
index := In2DArray( word, arr, 0 );
WriteLn('Word: ' + word + ' | index = ' + IntToStr(index));
// if word is in array then increment its count by 1
if ( index > -1 ) then
begin
arr[ index ][ 1 ] := inttostr(strtoint(arr[ index ][ 1 ]) + 1);
end else // if not, increase array length
begin
inc(n);
setarraylength(arr, n);
setarraylength(arr[ n - 1 ], 2);
arr[ n - 1 ] := [word, '1'];
end;
// if the position of space ever equals zero, that means there is
// 1 word remaining, flick lastword on and break out of loop
if ( posSpace = 0 ) then
begin
if not( lastWord ) then
lastWord := True
else
break;
end;
end;
result := arr;
end;

var
a : T2DStringArray;
i, i2, n : integer;

begin
ClearDebug;
WriteLn(str_alphabetize(strA));
a := str_numOfOccurrences(strB);
WriteLn('---');
n := GetArrayLength(a);
for i := 0 to n - 1 do
WriteLn(a[ i ][ 0 ] + ' | ' + a[ i ][ 1 ])
end.

~Ron

nielsie95

2009-10-10 11:19:13

Was I the only one to submit? Also, there's no new challenge?

EDIT: Ah, hello Ron.

mixster

2009-10-10 14:04:45

Sorry, just running a bit late.
New challenge going up shortly - even though Ron didn't send in a pm (naughty Ron!), I'll accept his entry. Other two being nielsie and Dan Cardin. Results will go up a bit after I post the challenge.

Ron

2009-10-10 17:43:56

Sweeet thx mixster for accepting it but it's not completed tho.

Hello nielsie. :)

Dan Cardin

2009-10-10 20:51:58

with Nielsie's
s := ['say lol 1', 'h^ehehe', 's.ay ONE two three', 'say lol', 'say heho! (not!)', 'Hey', 'Hello', 'Hai', 'Hoi ', 'hello', 'hEY', 'hello', 'Hoi', '.lo l123', '.lol ', '.lol.', '.lolA', '.lola', '.567', '567', '0123', '…lol', 'bye', 'cya', 'zebra', 'ZONK!'];
gives an out of range error, and with the input you gave, it outputs this
…lol
.567
.lo l123
.lol
.lol.
.lola
.lolA
0123
567
bye
cya
h^ehehe
Hai
hello
hello
Hello
hEY
Hey
Hoi
Hoi
s.ay ONE two three
say heho! (not!)
say lol
say lol 1
zebra
ZONK!
where, afaik Hello shouldnt be before hello. Anyways. Mine was far from perfect, and much less so than yours Nielsie :). And Mixster is a cheat if he wont count my very very slight error in putting my setting result lines backwards yet allows Ron to enter.

ANYWAYS. Questions on the new one. Firstly, we are in simple terms doing this -
[*]finding the longest path and that one is Jack's
[*]telling you how long it is.
[*]finding how many other different ways there are (jill)
is that correct?

Aswell as, you're going to need to give an example of the map you'll be giving. I'd rather have a map that looks like (i actually dont like that either, but i dont like your format. as 1 there is no way in and out of the maze, 2 i think it would be funner if the entrance and exit would have to be found rather than you give them, 3 i dont want to parse like your example wants me to).
XXXXXXXXXXXXXX XXXXXXXX
X X X XXXXX XX XX
XXXXXXXXXXXXXX XXXXXX
XXXXXXXXXX XXXXXX
XXXXXXX XXXXXXXXXXXX
XXXXXXX XXXX
XXXXXXXXXXXXXXXXX XXXX
XXXXXX X X X X
XXXXXXXXXXXXXXXXX XXXXX
EDIT…type that into SCAR from the actual text and it will look right…


your map looks much different from mine. So i'll need a specific format that you'll be putting your map in.

nielsie95

2009-10-11 05:15:24

Hey, you're right, there was still a bug in there :huh:. About the hello-Hello: Mixster said "With case insensitivty, hello = HELLO.", so that shouldn't matter.

If anyone is still interested in the fixed version, I attached it.

mixster

2009-10-11 05:30:58

From: Dan Cardin
with Nielsie's
gives an out of range error, and with the input you gave, it outputs this
where, afaik Hello shouldnt be before hello. Anyways. Mine was far from perfect, and much less so than yours Nielsie :). And mixster is a cheat if he wont count my very very slight error in putting my setting result lines backwards yet allows Ron to enter.

I still did let you enter - I just didn't let you make me alter your script after you entered it. I even double checked with you that it worked, to which you said yes! I tested each with the input used in the script. nielsie's was the only one which actually did what it was supposed to given the input - it didn't occur to me that giving it different input may crash it, especially after no one elses worked!

ANYWAYS. Questions on the new one. Firstly, we are in simple terms doing this -
[*]finding the longest path and that one is Jack's
[*]telling you how long it is.
[*]finding how many other different ways there are (jill)
is that correct?

In a nutshell, yes.


Aswell as, you're going to need to give an example of the map you'll be giving. I'd rather have a map that looks like (i actually dont like that either, but i dont like your format. as 1 there is no way in and out of the maze, 2 i think it would be funner if the entrance and exit would have to be found rather than you give them, 3 i dont want to parse like your example wants me to).
EDIT…type that into SCAR from the actual text and it will look right…

your map looks much different from mine. So i'll need a specific format that you'll be putting your map in.

I will have my map as an array of Boolean / TBooleanArray. False for unwalkable, true for walkable. The starting position and finishing position will be input into the function as a TPoint with the y refering to bool[y] and x refering to bool[y][x].

From: nielsie95
Hey, you're right, there was still a bug in there :huh:. About the hello-Hello: mixster said "With case insensitivty, hello = HELLO.", so that shouldn't matter.

If anyone is still interested in the fixed version, I attached it.

Indeed - case insensitivity means Hello = hello.

Dan Cardin

2009-10-11 10:52:00

woops! i hadnt seen the case insensitivity enabled!

And OH @ the start and end positions! I figured it was more of a enter and exit the maze sort of deal where there would just be an opening on 2 sides and those would be the places.

Ron

2009-10-11 12:57:09

@Dan, hahaha. I wasn't even trying to submit. I was bored and just did that to pass the time and figured I'd post it. If you didn't notice, I received none of mixster's precious points. :P

For the map, you do not need a 2 to show it's the end of the line. You can use a TStringList to load the maze file and interpret each number line by line.

We did something like this in my java class and instead of using so many numbers, we only used 0s and 1s. It brought up a jpanel and would draw the entire map out including the person walking through the maze. Then it would have the person go through and figure out the maze by trying each path and if/when it ended, it would double back and pick a new path until it got to the end of the maze. That was a fun program to write. :)

mixster

2009-10-11 13:58:42

You still need the 2's as Scar can't read strings over multiple lines - you could remove then save as a file and use #13 and #10 to explode by :)
A parser for it would literally be <10 lines though, so I don't think it should be much of an issue, especially as it isn't a requirement for the challenge.
semi-pseudocode being:
arr := explode maze, 2;
for y in each of arr do
for x in each of arr[y] do
if arr[y][x] is 0, then set bool2Darr[y][x] to false else set to true
if arr[y][x] is 3 set begin, if 4 set finish

This also differs from a traditional maze though as it has multiple paths, so you have a few different ways to try :)

Edit: bah, add code so it indents…

Ron

2009-10-12 00:57:48

Im not sure if you understood what I wrote, so I'll just show the code to prove it. This is very standard code so i wouldn't be surprised to see something similar in someone's submission.


program RonIYF;

var
browse : TOpenDialog;

procedure parse( fileName : String );
var
a : TStringList;
row, col, numRow, numCol : Integer;
line : String;
begin
a := TStringList.Create;
if (LoadFromFile(a, fileName)) then
begin
numRow := a.Count;
for row := 0 to numRow - 1 do
begin
AddToReport('row ' + IntToStr(row));
numCol := length(a[ row ]);
AddToReport('start numCol = ' + IntToStr(numCol));
line := '';
for col := 1 to numCol do
begin
case a[ row ][ col ] of
'0' : line := line + ' ';
'1' : line := line + '|';
else
AddToReport(a[ row ][ col ] + ', not allowed.');
end;
ReplaceDebugLine(row, line);
Wait(10);
end;
WriteLn(' ');
end;
end;
a.Free;
end;

begin
ClearDebug;
ClearReport;
ChangeReportWidth(200);
browse := TOpenDialog.Create(nil);
browse.Filter := 'All Files|*.*';
if ( browse.Execute ) then
parse( browse.FileName )
else
WriteLn('select a file.');
browse.Free;
end.

Use this file:

111111111111111111111111111111
110000011110000111001111111101
101111101101111011000111111101
101111101101111011010011111101
101111101101111011011001111101
101111011101111011011100111101
100000111101111011011110011101
101101111101111011011111001101
101110111101111011011111100101
101111011101111011011111110001
101111101110000111011111111001
111111111111111111111111111111

It loads the file, reads it line by line without having to check the last letter, and displays the result by replacing 0's with spaces and 1's with vertical bars.

mixster

2009-10-12 04:45:12

bah, you know I love you Ron, but I don't think you're reading the challenge!
The problem is basically to create a maze solving algorithm, not a parser. Also, you are supposed to PM your entry to me rather than post in the topic so that there should be no doubt that one entry wasn't copied etc :(

senrath

2009-10-12 04:47:11

From: mixster
bah, you know I love you Ron, but I don't think you're reading the challenge!
The problem is basically to create a maze solving algorithm, not a parser. Also, you are supposed to PM your entry to me rather than post in the topic so that there should be no doubt that one entry wasn't copied etc :(


He was just showing that it's possible to make a parser without having to use the "2" at the end of each line.

mixster

2009-10-12 05:34:13

But I didn't doubt that it was possible - I just said that it would pretty much be the same amount of code and doesn't really make much of a difference at all since I'll be parsing the map myself and the submission itself doesn't have to :(

I see your point and retract my earlier statement though

nielsie95

2009-10-18 11:14:31

Is the maze always a rectangle?

mixster

2009-10-18 12:45:24

Yes - it will always be rectangular, probably not square.

Also, one more week for entries! Don't forget and it's not too late to start! :)

Dan Cardin

2009-10-18 19:39:21

will it always have walls surrounding it?

mixster

2009-10-19 02:42:43

Erm, yes.

mixster

2009-10-24 08:43:07

No more entries to be accepted!
This time I got one entrant, so nielsie will probably win unless he was silly enough to submit a non-functioning script. On a similar note, I think if there is only one entrant next week, then I'll end this LoS and try again at a different time.

In the mean time, expect the new challenge to be posted up later tonight!

Dan Cardin

2009-10-24 13:40:51

ill entrance mine when i finish it. I got lazy and forgot about it half way through the week. Not to want to get points, but i want to finish it nonetheless.

bullzeye95

2009-10-24 14:25:14

From: mixster
No more entries to be accepted!
This time I got one entrant, so nielsie will probably win unless he was silly enough to submit a non-functioning script. On a similar note, I think if there is only one entrant next week, then I'll end this LoS and try again at a different time.


I think the issue is, people just want something small, like the first challenge. Something that's easy to make, but takes skill to make fast. Like a sorting algorithm or something.

mixster

2009-10-24 14:28:20

That's what I was thinking, but it's hard to think of small problems since they usually have perfect algorithms produced to solve them already :)
Going to spend the next couple of hours going over ideas and the like then I'll post it up.

mixster

2009-10-24 15:45:41

Ok, problem 5 is up and it tells a great tale - RuneScape has been updated and uptext is no longer detectable! Help the two fictional heroes once more allow uptext collection to work by creating either a uptext filterer that takes a bitmap of uptext and returns a TPA of all text points. Alternatively, create a TPA "filler" that takes a TPA of an outline and fills it in to return a "full" TPA!

Dan Cardin

2009-10-25 16:54:59

gah silly rs-ish things.

mixster

2009-10-25 19:01:17

RS orientated, but by no means RS specific :)
Problem B is most definitely possible for usage outside of RS silly

Dan Cardin

2009-10-25 20:42:14

aha! I didnt read part B because it started
Ok, so the scene continues from Problem A
I am quite sorry at my silly response.

mastaraymond

2009-10-28 12:13:02

Might join, if I find some time this week:staycool: