Jump to content

Programming Challenge 1


cold_snipe

Recommended Posts

  • Replies 60
  • Created
  • Last Reply

Top Posters In This Topic

hmm, not gloating at all arrrrrrrrre we?! lol :P

 

i still got a case of the algebra squirts, mrboo :lol:

526304[/snapback]

 

hahaha! well, the algebra stuff was rather trippy!

 

not gloating, not at all :rolleyes: The post did say something about fastest though :) So I know I am winning in that respect so far atleast. Not sure about comments / smartest code / blah though...

Share this post


Link to post
Share on other sites

After reading markie's post, I was inspired to see if I could slim mine down. So I made this:

#include <iostream>


int main()
{

  return 0;
  
}

Which compiles to 463kb with Dev. Meanwhile, markie's whole program compiled (again with the same Dev program) is a mere 18kb.

 

If I compile this:

//#include <iostream>


int main()
{

  return 0;
  
}

it's 15kb. I think iostream is a little bulky :P

 

So basically, I'm thinking C is going to win this battle every time. However, I would like to do some speed comparisons with my new code-in-progress, just for fun. Markie, could you elaborate a little on how you did your comparisons. Is this something you ran at the command line, or something you built into the codes?

Share this post


Link to post
Share on other sites

im too complex for computers :(

526325[/snapback]

 

:lol: demand 128 bit for personal computers...

 

BTW, Verran... you do know that ASCII 33 isn't actually 'a', right? Capital 'A' is 65 and small 'a' is 97... I did mine from 33 up till 126 too so the performance things would be meaningful.

 

So basically, I'm thinking C is going to win this battle every time. However, I would like to do some speed comparisons with my new code-in-progress, just for fun. Markie, could you elaborate a little on how you did your comparisons. Is this something you ran at the command line, or something you built into the codes?

 

Ah, that's probably the cause for the slowness as well then I expect...?

 

I did the speed tests, well, first

 

#include <windows.h>

 

Then 3 variables:

 

LARGE_INTEGER start, end, tps;

 

After the input for the number of characters:

 

QueryPerformanceCounter(&start);

 

Before system("pause");

 

QueryPerformanceCounter(&end);
QueryPerformanceFrequency(&tps);

printf("%d ticks per second\n", tps.QuadPart);
printf("done in %d ticks\n", (end.QuadPart - start.QuadPart));

Share this post


Link to post
Share on other sites

Well, I've been trying a bunch of non-dynamic and non-recursive solutions, and they're really not that much faster. I guess the dynamic memory allocation couldn't slow it down that much, and the recursive calls really aren't much different from a for loop in principle. Maybe C is just a lot faster than C++ in this case. I do not admit defeat, but my language does :P

 

As far as the integer/ASCII values, yeah I know them all. I use this:

ASCIICodes.gif

to cheat! :) I've had a couple different versions. The first one was just a-z, and the other was !-~ or something like that, that's probably where the confusion was.

 

Thanks for the windows tick counter thing too. I got it working very easily, and I'm sure it will come in handy some time in the future.

 

###EDIT

Wow, that image looks like crap when linked to the boards. In a normal image viewer, it's just black on white and very easy to read. Fear not, if you download it, it'll look fine :P

Share this post


Link to post
Share on other sites

Well, I've been trying a bunch of non-dynamic and non-recursive solutions, and they're really not that much faster.  I guess the dynamic memory allocation couldn't slow it down that much, and the recursive calls really aren't much different from a for loop in principle.  Maybe C is just a lot faster than C++ in this case.  I do not admit defeat, but my language does :P

 

Thanks for the windows tick counter thing too.  I got it working very easily, and I'm sure it will come in handy some time in the future.

526392[/snapback]

 

Yeah it's probably just... the stream blah stuff making it slow. I will have to try your recursive thing in C and see if that's any quicker than my nasty iterative one... cause they should be very close in terms of speed... :blush:

 

I remember doing a comparison of something in Java using recursion and iteration before and the iterative version was ever so slightly faster, the difference being constant.

Share this post


Link to post
Share on other sites

I am beginning to believe that I never stood a snowballs chance in hell from the start

526575[/snapback]

 

Bah, it's not about competition, it's about a challenge. I thought I was "winning" til markie showed his little head, but who cares? I loved markie's post because it made me go back through my own code and work on it more. I just enjoy having -something- to code. Now that I'm outta school I don't get challenged with coding projects anymore, and I miss using that part of my brain. I can't wait til I find something else to work on :)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×
×
  • Create New...