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
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 10th Oct 2009 01:13
Quote: " I've not done any of this for a couple of years"

Hasn't been that long has it?
Welcome back

TGC Forum - converting error messages into sarcasm since 2002.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 10th Oct 2009 01:33
Quote: "Could you upload the dba file please."


You can't copy and paste?

So what are we gonna do guys? New challenge or wait until we have a complete entry?

demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 10th Oct 2009 04:38 Edited at: 12th Oct 2009 14:37
@Obese: late 2007 mate yeah

and it's good to know I was missed.

Definitely gonna grab my copy of DB when I get back home next though. The forums here are amazing. Good community spirit and all that...

Edit: I've got a couple of pieces of coursework in for tomorrow, but if the deadline's being extended a couple of days I'll try and whip up a quick entry. It won't be pretty, but at least it will (hopefully) be functional, and mean that there's more than one entry for the challenges. It's a sad state of affairs though. No matter what the traffic on the boards in general, to only have one entry on the DBC challenges? It makes me want to cry.

Edit again: Never mind. Got to concentrate on my course for a bit, and I'm still trying to ease my way back into programming, maybe I'll leave the challenges alone for a while...

"A West Texas girl, just like me"
-Bush
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 16th Oct 2009 19:33
"hello?" [echo]hello?-ello?-lo?-o?[/echo]
No one is here, the DBC logo is all dusty and no one has fed the DBC Challenge cat!
And what's this note on the door?
Quote: "You have not been submitting your challenge entries on time. You have until the midnight 24/10/09 to submit a calculator program or you will be evicted from this metaphor.
Yours sincerely,

L. Bamber
(Bamber & Bamber & co.)
"


TGC Forum - converting error messages into sarcasm since 2002.
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 16th Oct 2009 19:47
Hahahaha, nice... whats this about a calculator? i thought it was saved game data lol. i don't have anything but just wondering

New Site! Check it out \/
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 17th Oct 2009 06:27
Quote: "Hahahaha, nice... whats this about a calculator? i thought it was saved game data lol. i don't have anything but just wondering"

I don't know, I thought people weren't interested in that challenge but maybe thats not the reason only Phaelax entered.
Or we could just say post any cool things you've been working on that you haven't posted, just to get something on this board.
I've written an Elite style galaxy viewer with procedurally generated planet names and descriptions. It's pretty cool I haven't had a chance to upload yet though.

TGC Forum - converting error messages into sarcasm since 2002.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 17th Oct 2009 20:41
The reason for the 'drought' in here is simple - we have simply lost sight of the original reason for the thread.

It was started to see how we could all come up with coding solutions for specific programming tasks. Somewhere along the line the challenges just got bigger and turned into writing complete games.

To be honest, no-one has the time to do this.

If challenges were more basic and could be written in a few minutes, a lot more people would have a go.

So, it's all down to choosing the challenges - which I admit is often more difficult than actually solving them.

So try to simplify your challenges. If you are stuck, there's always "Write a function which...".

TDK_Man

t10dimensional
15
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 17th Oct 2009 20:54 Edited at: 17th Oct 2009 20:55
He's right, the main reason I don't enter most challenges is because I have no idea where to start.

If we keep the challenges where they can be done easily by noob but be complicated if someone wanted it to be more people would enter.

Like the DarkNOOBs challenge, the paint program. It can be a simple dot program or it could be like MS paint.

Razerx
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 17th Oct 2009 21:16
I say anyone picking the challenge's should look over the old ones if you they have never done it before. some that i remember were, creating a clock, making a text editor, and a bouncing ball. all of these are simple BUT can be made more complex if there is someone with the know-how and the determination to do it.

New Site! Check it out \/
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 17th Oct 2009 21:16
We already had a paint program though (p25), and out of the people that have posted on here recently I know me and obese entered that one. Something along those lines might be good.

I think something to display data might be good. Like where you could choose bar graphs, line graphs, pie charts etc. but then see who could come up with inventive ways of displaying it as well... Just have a basic set of information and then an assortment of graphical representations thereof.

"A West Texas girl, just like me"
-Bush
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 17th Oct 2009 21:21
I agree paint is good but aren't there a lot of people here that have already done that one?

creating a HUD is a good one i think. or maybe a little game menu. i know a lot of people have trouble with those

New Site! Check it out \/
t10dimensional
15
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 17th Oct 2009 21:43
The paint program was a example. I was'nt suggesting it.

The menu idea sounds good but should'nt we make up a game that the menu will be for so it will be easier to judge. Like a menu for a space game or somthing like that.

Razerx
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 17th Oct 2009 21:45
Even a paint program is far too complicated. Full working programs should be avoided.

Far better would be to have the challenge writing a routine to create a single option from a paint program. Eg:

* An airbrush (spraycan) function

More experienced coders could add options to alter the spray area size or the spray area shape (random pixels sprayed in a rectangel is easy. How about into a circle?) and so on.

* Area Select

A small program which will let you draw a dotted line rubber band box to select an area of the screen and cut/copy it to somewhere else.

* A Flip/Mirror Option

And many others...

That's three challenges there.

TDK

demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 17th Oct 2009 21:51 Edited at: 17th Oct 2009 21:54
I think all of TDK's ideas would be good - I'd be happy to do any. And I think a menu might be a good challenge too, but razerx I think limitations such as this might take some of the fun out - I for one always liked seeing what people came up with and the originality some people applied to meeting the criteria.

EDIT: Phaelax technically would have won the last challenge wouldn't he? Or does Obese set it again due to lack of interest? Either way I vote we get this ball rolling again.

"A West Texas girl, just like me"
-Bush
t10dimensional
15
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 18th Oct 2009 01:26
I'll enter on this next challenge for sure. I'm just finishing my current project(Yahtzee) so I'll have plenty of time.

Razerx
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 18th Oct 2009 04:30
We could make a community paint program in week by week installments
The winner of each week gets their code in the program!
Even if we didn't actually put a program together it would be cool to go through all the different tools week by week.

I vote airbrush to start with.

@TDK
You are so right, we have forgotten the true meaning of the challenges.

I've always wanted to draw filled triangles, would that be a good challenge?

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: 18th Oct 2009 06:01
I think the others would be better than filled triangles. But that might be because I can only think of one way to do it and it would be slow...

Nevertheless I think someone needs to set a challenge soon.

"A West Texas girl, just like me"
-Bush
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 18th Oct 2009 21:54
Quote: "I've always wanted to draw filled triangles, would that be a good challenge?"


Filled shapes challenge, I'd enter. But has this been done yet? It sounds familiar.

And I've said for years the challenges have become too big, that's why I stopped the DBP. All they set anymore are big games.

Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 20th Oct 2009 02:51 Edited at: 21st Oct 2009 00:33
Here's my airbrush. I got the circle maths from a filled circle function I found on phaelax's site and adapted it for this. It was from that procedural tree program, it's awesome, did you write that Phaelax?
[edit - speed improved]


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: 20th Oct 2009 18:05
Damn it OBese - I just looked at your code, it's pretty much exactly what I was planning to do. Probably more effective and less long winded than mine was going to be to be fair... So not only did you do it first, you did it better...

"A West Texas girl, just like me"
-Bush
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 20th Oct 2009 21:35
Obese:



I know speed isn't a big factor here but, for habit perposes wouldn't




be faster?

New Site! Check it out \/
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 20th Oct 2009 22:47
caleb seems to be getting into speed optimizations. Honestly, that's good.

TheComet


Make the paths of your enemies easier with WaypointPro!
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 20th Oct 2009 23:47 Edited at: 21st Oct 2009 20:23
Here's a variation on an airbrush



Enjoy your day.
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 21st Oct 2009 00:38
@Caleb
Oh yeah, I did that so it would spray on any mouseclick, but I seem to remember any positive value will return true so you're right. Thanks. I put radius^2 and diameter calculations outside of the for loop for a bit of a speed boost too.

TGC Forum - converting error messages into sarcasm since 2002.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 22nd Oct 2009 08:22
Not my exact code, but I've written similar for the DBP paint challenge a few years ago.

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 27th Oct 2009 04:49
Challenge: FizzBuzz

Deadline: Oct. 30


This is a very simple logic problem that someone might ask you in an interview to weed out the resume liars.

Display 1 through 100 in sequential order. If the number is a multiple of 3, then display "Fizz". When the number is a multiple of 5, display "buzz". If the number is a multiple of both 3 and 5, then display "FizzBuzz". Otherwise, display the number as normal.

This should only take you 5 minutes at the most. The reason I'm making the deadline Friday is to give people time to actually see this challenge and participate. For your own sake, try not to view other people's code for the answer, it defeats the purpose of this challenge.

Winner will be judged based on code quality.


p.s. Why have I set a challenge? Because nobody has touched this thread for a week.

t10dimensional
15
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 27th Oct 2009 05:44 Edited at: 27th Oct 2009 05:48
ENTRY



Razerx
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 27th Oct 2009 11:28 Edited at: 27th Oct 2009 11:29
Basic idea with no fiddly bits added yet (will do that after uni today):



I'll look at sparkling it up a little later visually, but just to get something in...

"A West Texas girl, just like me"
-Bush
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 27th Oct 2009 13:23
Entry


Enjoy your day.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 27th Oct 2009 18:18
Entry:



TDK

Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 27th Oct 2009 18:43
Entry


That's a pretty good little test!

TGC Forum - converting error messages into sarcasm since 2002.
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 27th Oct 2009 21:34 Edited at: 28th Oct 2009 03:37
entry 2

EDIT: oops! I left in a memblock command from a test I was doing

Similar to my first entry but using Select


Enjoy your day.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 28th Oct 2009 00:30
6 entries in 1 day? That's gotta be a record for us!

Looking at some of the entries, I just realized DBC doesn't have a modulus command.

TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 28th Oct 2009 01:14
Quote: "I just realized DBC doesn't have a modulus command"


No it doesn't. My first version used my own MOD function but decided to integrate it into the main code...

Just one of the reasons why we all love DBC so much!

TDK

t10dimensional
15
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 28th Oct 2009 04:05
Seems like keeping it simple worked.

Razerx
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 28th Oct 2009 04:42
Seems like most people came up with the same method to be fair - looks like it might be because there are only a couple of ways you can do something like this to be fair, but still... I like the high audience participation levels on this one.

Also I was going to post an updated code, but it's now been my 20th birthday for 2 hours and 40 minutes, and I'm in no danger of sobering up enough to think properly for at least 48 hours, so my entry as it was earlier is my final entry.

"A West Texas girl, just like me"
-Bush
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 28th Oct 2009 06:42
Here's another challenge to think about, swap the values of A and B without using a temp variable.

Apparently, over 90% of "programmers" who apply for such a position cannot answer this simple problem.

Digger412
16
Years of Service
User Offline
Joined: 12th Jun 2007
Location:
Posted: 28th Oct 2009 07:03 Edited at: 28th Oct 2009 07:05
Dang TDK, that's some nice math! Sweet, simple, and to the point! Hehe, we all have something to learn from you .

EDIT: Whoops, didn't know I wasn't on the last page...still nice though.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 28th Oct 2009 13:46
No temp variable swap:



TDK

demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 28th Oct 2009 15:35 Edited at: 28th Oct 2009 15:37
No use of variables at all? (apart from A and B obviously)... Sounds interesting. No ideas at the moment but I'll keep thinking on it. The only thing I could come up with earlier was sort of doing C=A-B, A=A-C and B=B+C, or something along those lines. Then I realised that you might count C as a temporary variable...

"A West Texas girl, just like me"
-Bush
t10dimensional
15
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 29th Oct 2009 00:17 Edited at: 29th Oct 2009 00:20
This is what i got at first:



Then I figure it out figured it out by remembering my algebra.

c=a+b
what does a=?




edit:

TDK seems to complicate everything. At first when looking at his code I thought I had the wrong answer.

Razerx
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 29th Oct 2009 02:26
Quote: "TDK seems to complicate everything"


How so?

You are using floats but feeding integers into them. IMHO this complicates matters as your snippet doesn't actually work with floats.



That's why I stuck to integers!

TDK

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 29th Oct 2009 03:37
TDK actually has the more efficient answer I was looking for.



So simple and yet it seems to easily confuse people.

Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 29th Oct 2009 04:07 Edited at: 29th Oct 2009 04:21
Swap Entry

I feel smart now lol
I hope it actually works

[edit]
woohoo! Where do you get these from Phaelax? They're like puzzles from a newspaper put for coding

@TDK
[edit]oops better put that question in a code snippet as it could be a spoiler.


TGC Forum - converting error messages into sarcasm since 2002.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 29th Oct 2009 04:35
Quote: "Where do you get these from Phaelax?"

Someone at work sametimed me his brainf**k code solving the FizzBuzz problem. I looked up to see what FizzBuzz was and just came across different articles and user comments mentioning different things related to hiring programmers.

Glad to see these sparked a little interest in the thread.

t10dimensional
15
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 29th Oct 2009 06:24
Quote: "You are using floats but feeding integers into them. IMHO this complicates matters as your snippet doesn't actually work with floats."


That was just what I had at first.

I got this:



in my second code snippet.

Quote: "Inc A,B: B=A-B: Dec A,B"


I was confused because I did'nt know you could put another number after INC and DEC so I had to look it up. Sorry about that.


@Phaelax

Lets get some more puzzles, I like these.

Razerx
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 29th Oct 2009 06:50
OBese87:

I don't know. I would think there's very little in it. I'm just so used to using Inc instead of X=X+ and Dec instead of X=X- that I use them without any thought to speed.

TDK

Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 29th Oct 2009 16:47 Edited at: 29th Oct 2009 17:19
Entry:


Wow TDK that's .... so short!

[Edit] omg am I a page too late!? Anyways I learn something from all this

Learn:



About the A B variable swap :
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 30th Oct 2009 04:40 Edited at: 30th Oct 2009 04:42
@Ashingda
That's quite a unique way of doing the fizzbuzz.
Using a file in the variable swap is interesting because there might be a situation where you'd use that. For example, if you had loads of data files that you read into arrays and half way through you decided to change the order you read the data in, you could use this to sort the data. However the way you used the file is like having a third variable so I don't think it's valid.

TGC Forum - converting error messages into sarcasm since 2002.
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 30th Oct 2009 05:14 Edited at: 30th Oct 2009 05:16
Here's a swap using bit shifting. It's just for 16 bit unsigned integers. If DBC actually allowed shift operations, it would probably be super fast but limited.



Enjoy your day.

Login to post a reply

Server time is: 2024-04-23 19:10:42
Your offset time is: 2024-04-23 19:10:42