Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / The DB Classic Programming Challenge Thread

Author
Message
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 31st Oct 2009 18:56
Quote: "Challenge: FizzBuzz

Deadline: Oct. 30"


It's over Phaelax - time to judge...

TDK

Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 1st Nov 2009 06:45
The 30th was my sister's wedding, so I've been in SC until a an hour ago. If you don't mind, I'm gonna get some sleep after the 10 hour drive and judge sunday morning.

Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 1st Nov 2009 08:17
No, judge it now you slacker!

TGC Forum - converting error messages into sarcasm since 2002.
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 1st Nov 2009 14:09
So you didn't judge just because of a wedding? Come on man - you got to prioritise.

"The fools may crash down upon us in thunderous waves, but we shall Jeku slap them back from whence they came"
-BiggAdd Oct 28th 2009
Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 1st Nov 2009 19:33
I'm installing DB now so I can judge them (new harddrive)

Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 2nd Nov 2009 06:29
October 30th: Strange time for a wedding.
Is your sister a vampire perchance?

TGC Forum - converting error messages into sarcasm since 2002.
Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 2nd Nov 2009 20:12
You'd be surprised how many ppl I've known that get married in october. But it wasn't the most traditional wedding I've been to, that's for sure.

Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 2nd Nov 2009 20:45 Edited at: 2nd Nov 2009 21:52
And so ends the FizzBuzz challenge, with the highest submission rate we've had in awhile. Sorry it took so long to judge, but the wedding is more important than you!

razerx - nice work

demons breath - nice work, similar method as razerx for working out modulus

Latch - Good job, nice presentation
Latch #2 - interesting choice to using select/case

TDK - i think this is the most compact code

OBese87 - presented much like latch and tdk

Ashingda 27 - nested FOR loops, presentation purposes im sure

Runner Up:


Winner:


t10dimensional
15
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 2nd Nov 2009 21:56

My entry works perfectly on my computer.

Razerx
Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 2nd Nov 2009 22:33
You must've read my old comment razerx. I rebooted so I could attach my other harddrive with DBC on it, I only had DBP installed and it didn't like it. All entries worked fine.

t10dimensional
15
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 2nd Nov 2009 22:49
O, I see. Sorry, I went to test it and did'nt notice you had edited it.

Razerx
Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 2nd Nov 2009 23:51
LOL I didn't notice I had the x and y swaped on the for..next statements.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 3rd Nov 2009 04:15
*** New Challenge ***


The next challenge is a simple race. Whoever's program completes the task correctly in the fastest time wins!

All you have to do is sort a list of names alphabetically. The 273 unsorted names are in a code box below. Simply copy and paste them into Notepad then save the file as 'NameList.txt'.

To save you time I've created a 'skeleton' program (in the other code box). Paste this into the DBC editor and save it in the same folder you saved the name list text file.

The skeleton program opens and loads the list of names from the text file into the string array NameList$(). Simply write your entry code between the ##### lines and add any required procedures/functions in the sections defined at the end.

Running The Skeleton Program:

When you press the space bar, the timer starts and your code is executed. When your code finishes, the sorted list of names is saved to a file called 'Sorted.txt' with the time it took as the last line of the file.

If you have a slow machine, it doesn't matter - you can still enter because all entries will be run on the same machine and the fastest one declared the winner. You can open the Sorted.txt file and check the time taken value to see if your latest code change was any quicker than the previous one.

Notes:

1. The names must be fully sorted - not just on the first character (where all the names with the same start letter are together).

2. The array saved is NameList$() - the array used to load the unsorted list into. So, at the end of your code, if you used a different array, be sure that this array contains the sorted names.

Closing Date: In 1 week - Tuesday 10th Nov (Midnight GMT)

The List Of Names To Be Sorted:



The Skeleton Program:



TDK

Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 3rd Nov 2009 04:39 Edited at: 3rd Nov 2009 04:39
You sized the array with 280 but only fill up to 272, threw me off for a minute.

My first entry (and most likely the easiest method), 67ms.


Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 3rd Nov 2009 05:08 Edited at: 3rd Nov 2009 05:20
Ok, theoretically this should work. But apparently DBC doesn't like the "less than equal to" symbol, it keeps throwing me an unrecognized parameter error and I've tracked it down to the chunk contained in this line:

while ((NameList$(i) <= k$) and (i <= endd) and (j > i))




I ran this code through DBP, and it compiles fine. And, while it crashes DBP, it still finishes executing the code and gives a 1ms time stamp.

Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 3rd Nov 2009 09:33 Edited at: 6th Nov 2009 23:57
another quicksort routine:



edit:
I've looked over the list and it seems the names are formatted with capitals and lowercase in a very standard method. I'm gonna dump my check for lower and uppercase occupying the same column in a complete word by removing upper$(). It should boost the speed!

Enjoy your day.
Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 3rd Nov 2009 15:56 Edited at: 3rd Nov 2009 16:35
Entry:


Lol funny I left in some global counters I used to test the speed and thought it was required for the function to work. If you test my code befor I removed the F(0),Q(0),C(0) arrays run it again please it's faster now.

[edit]
After doing a little test, it seems inc/dec are faster than a=a+1. I also changed my entry a bit to inc/dec.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 6th Nov 2009 17:50
Closing time is looming!

Challenge ends in 7 hours (midnight GMT), so last chance to get your entry in.

TDK

Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 7th Nov 2009 00:04
I wonder TDK, since these entries all seem to use quicksort, if on your monster machine you will get 0 ms. On my old clunker the list sorts at about 5 to 6 ms .

Enjoy your day.
Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 7th Nov 2009 05:44
Maybe we just need more names...
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 7th Nov 2009 16:18 Edited at: 7th Nov 2009 16:33
Looks like the forums broke last night. I tried five times to post in this thread and all I got was errors. So I gave up and went to bed.

Looks like all is OK now, so I'll check the entries out now...

TDK

TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 7th Nov 2009 16:47
@TDK

Very very clever! I don't understand what INT() does, do you care to elaborate?

TheComet


Make the paths of your enemies easier with WaypointPro!
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 7th Nov 2009 17:05
you don't know int()?
I'm surprised. It converts floats to integers. Doesn't do any rounding just chops off any numbers after the decimal point.

"With games, we create these elaborate worlds in our minds, and the computer is there to do the bookkeeping." - Will Wright
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 7th Nov 2009 17:32
Quote: "you don't know int()? I'm surprised."


I thought you'd be... but even experienced people have their gaps. Thanks!

TheComet


Make the paths of your enemies easier with WaypointPro!
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 7th Nov 2009 19:03
Results:

There were three full entries:

Phaelax
Latch
Ashingda 27


After running all three, Ashingda 27's entry completed the sort in 3 ms. Latch's entries returned 0 ms but unfortunately Phaelax's entry would not run in DBC.

So, I declare the winner... Latch! Congratulations and feel free to set the next challenge.

As an aside, this challenge was a little harder than the previous one and it had a dramatic effect on the number of entries.

As was discussed earlier in the thread, keeping challenges really simple does encourage others to participate. Many of us simply don't have time for full game challenges and code snippets which stick to specific aspects of a game are much more useful and more likely to attract entries.

Over to you Latch...

TDK

Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 7th Nov 2009 20:11
I'd be happy if anyone can figure out why mine won't work in DBC. Works in DBP, but also crashes at the end.

Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 7th Nov 2009 20:49 Edited at: 8th Nov 2009 00:23
Congrats Latch!

After playing around with our functions, it seems yours is faster for smaller amount sorts and starts slowing down at 3000 and up.

Overall I think yours is more practical as nothing I sort in my programs are over 500 anyways. I think I'll play around with it some more and try to find a way to speed it up more .


@Phaelax
It seems DBC can't use <= on strings.



@Latch
You got any insight on Radix? I'm not sure how we can pick out a single digit without using a long and slow process.

[edit]
Nvm I got a working Radix Sort now.
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 8th Nov 2009 01:57
Quote: "Latch! Congratulations and feel free to set the next challenge."

Thanks!

Quote: "After playing around with our functions, it seems yours is faster for smaller amount sorts and starts slowing down at 3000 and up."

Interesting. Probably because it doesn't divide (partition) the string directly in the middle, but could be anywhere depending on the value of the pivot. With shorter lists, the lack of division to find the middle of the array is a speed saver because there aren't enough partitions to warrant a slow down. But when the list gets larger, finding the middle (looks like that's what yours does) cuts down on the sub sorting of the partitions so the speed savings of the short lists start to reverse. I think that's what happening.

Enjoy your day.
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 8th Nov 2009 02:06
No loop list challenge

Display the numbers 1 through 100 in sequence on the screen without using

Do Loop
Repeat Until
While EndWhile
For Next

Try to post at least 2 methods of doing this. This might make you pause and think for a second, but it shouldn't be too difficult. Also, try not to look at other's code until the challenge is over so everyone comes up with their own methods.

This will be a short one. Deadline is Monday Nov 9 at midnight Tuesday morning GMT. The judging will be based on general efficiency and creativity.

Enjoy your day.
Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Nov 2009 04:31 Edited at: 8th Nov 2009 04:34
Here's one:


And here's number 2:


Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 8th Nov 2009 06:03
#1


#2



New Site! Check it out \/
Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 8th Nov 2009 07:36 Edited at: 8th Nov 2009 08:10
Entry 1:


Entry 2:


Entry 3: ...
Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Nov 2009 20:48
lol @ Ashingda entry 3. I was wondering if anyone would actually do that.

Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 8th Nov 2009 22:11
Ok honestly i though about doing that but then i didn't lol. I wonder what the speed of that compared to the speed of a loop is? because that's part of the comp.

New Site! Check it out \/
Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 9th Nov 2009 03:52
Putting the numbers into columns does add some extra calculations, even though they are only for presentation purposes and nothing to do with the efficiency of the actual loop.

Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 9th Nov 2009 05:30
That is true. Didn't think of that

New Site! Check it out \/
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 9th Nov 2009 13:57
Entry 1


Entry 2


Entry 3


"With games, we create these elaborate worlds in our minds, and the computer is there to do the bookkeeping." - Will Wright
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 9th Nov 2009 16:54
There's still about 8 hours left for a few more entries. This one is going to be tough to judge.

Enjoy your day.
Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 9th Nov 2009 17:07
lol yeah they're all about the same.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 9th Nov 2009 17:28
I've not looked at them yet, but decided not to bother with this one as there seems very little scope for variation. I can only think of recursion and assume everyone else has come to the same conclusion.

And, as Latch says it's going to be rather difficult to judge.

TDK

Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 10th Nov 2009 03:53 Edited at: 10th Nov 2009 03:56
Challenge is closed...

This was a pretty easy one and there's probably not a whole lot of options to get to the goal. Part of the challenge was efficiency. Now this is a hard thing to decide on. Is efficiency how much typing someone had to do to write the program? Is it the speed at which the program runs? Is it the use of internal resources? Is it flexibility?

First, everyone did a form of function recursion. That is a function that calls itself. As far as efficiency, this has a few drawbacks. A recursive function adds to the stack with each call. If not handled properly, you can get a stack overflow. The most flexible, was Phaelax's function because it allowed a cap value - one might be able to nip a stack overflow in the bud by controlling the recursion.

And what really surprised me is that no one relied solely on the static nature of function variables and they passed a value to the function or in Ashingda's case, used globals. So for the recursive function, what I would consider most efficient (not including the display) would be something like:



But that would assume only 1 run; as n would now hold a high value.

So for the recursive function, Phaelax is in the lead because of the flexibility and meeting the basic requirement of displaying all of the numbers from 1 to 100.

Everyone also did a goto type thing. I generally weighed the display formatting equal - except if all of the numbers weren't displayed. From there I had to knitpick a bit. I favored inc variable over variable=variable+1 because DBC's assigned operator '=' is really slow. The gotos are so similar... I'll have to give the edge to Phaelax with the inc. Obese might be in the lead but the display ran off of the screen.

Both Ashingda and Obese squeezed in a 3rd entry. For Ashingda, there's nothing like a little brute force! For Obese - very clever wording for 'fake' loop recreation!

The final results:

Runner up


Winner


Enjoy your day.
Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 10th Nov 2009 04:47 Edited at: 10th Nov 2009 04:50
Challenge:

Create a continuous side scrolling tile-based program that will generate random tiles to be displayed as it scrolls across the screen.

The program with the greatest fps rate will be declared the winner. This is a test of speed, so there will be some conditions.


Conditions:
- Must be in full screen. The screen size must be 800x600. The bit depth is up to you. Hint: (16bit is faster than 32bit)
- The tile size are 16x16. There must be 3 or more different tiles. These images can be just a solid block of color.
- The display of the tiles must fill the whole screen.
- Scrolling must be from the Right going towards Left. Scrolling rate is one pixel at a time.
- The fps rate must be displayed somewhere on the screen.


Anything else not mentioned are all usable. Good luck and happy coding.

This isn't too hard so I'm giving a week to do it.
Deadline is Monday Nov. 16 Midnight (Central Time).



Note: If you have an fps cap, learn how to remove it.
http://forum.thegamecreators.com/?m=forum_view&t=147790&b=10
Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 10th Nov 2009 05:28
Figures, the entry I made fun of is what won

Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 10th Nov 2009 07:33
Quote: "Figures, the entry I made fun of is what won"

It was a hard decision - but that brute force just worked fast with so little overhead.

@Ashingda 27
I wonder if this is a bit complex. Phaelax hit the nail on the head with the swap and the resume tester. The programming brain teasers seem to be a lot of fun - but are hard to make up. Short, quick challenges actually got me interested in this again.

Enjoy your day.
Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 10th Nov 2009 09:33 Edited at: 10th Nov 2009 09:53
I think this challenge could have real merit to it. This may allow us to find out which method works best for scrolling tile maps in DBC. I have a few ideas I'm going to try out.

Yea it is a little more complex than the last few, but I'm down for it if there aren't any suggestions for a different challenge. Any thoughts?

I can think of a math challenge, but it might be too complex for young coders. We've done sorting, what about a search?

Other ideas:
1. square root function
2. Prime generator
3. Thinking problems (i have a few in mind)

Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 10th Nov 2009 17:47
Hmm this might be more complex than I imagined. I just thought it would be benificial because this seems to be a problem area. I'm not just setting up a random challenge that I haven't gotten the answer to.

Well if more people aren't up for this, we can drop it for a simpler one.
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 10th Nov 2009 17:51
I'm up for having a play about with it when I've handed in my coursework (but I'm too busy over the next day or two to really do any challenges 'til the end of the week)

"The fools may crash down upon us in thunderous waves, but we shall Jeku slap them back from whence they came"
-BiggAdd Oct 28th 2009
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 10th Nov 2009 23:18
Quote: "Prime generator"


That might be a problem. Last I heard (which admittedly was several several years ago) there was a mathematics "contest" with a $1000 prize for creating a formula that returns only prime numbers. It has been going on for many many years and still going as far as I know.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 11th Nov 2009 00:30
Quote: "I'm not just setting up a random challenge that I haven't gotten the answer to."


That was exactly what these challenges were set up for. Part of the prize for winning is being able to set a challenge which you don't know how to do yourself.

As for this challenge, sounds reasonable enough. At least it's not a full side-scrolling game!

TDK

Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 11th Nov 2009 05:23 Edited at: 11th Nov 2009 05:41
I guess it's not too tough. There probably won't be any real newsters entering anyway. Alright with me, then. Let's roll with it.

ENTRY
I ran this switching bitflipmode between 0 and 1 in the setup.ini file just for fun. With blitflipmode=0 it ran at about 115 fps . With blitflipmode=1 it ran at about 730 fps. Quite a difference.



Enjoy your day.

Login to post a reply

Server time is: 2024-03-29 06:44:16
Your offset time is: 2024-03-29 06:44:16