Older Contests
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP ContestsOlder Contests

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old November 23rd, 2002, 04:58 AM
-vertigo- -vertigo- is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Louth, Lincolnshire
Posts: 314 -vertigo- User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 24 sec
Reputation Power: 3
The end of my contest

Hi guys

This is the situation as it stands.

When I first saw this competition, I wanted to see if I could solve the problem in a good way. For me, a good way means writing an algorithm that is good enough to get close to the minimum moves without testing all combinations.

If I achieved this, then I would have been satisfied woth my work. As it is, I have found that for stacks without duplicates, I can sort them very well, almost always getting within 1 move of the minimum.

When the stack has duplicate values, however, I can't seem to work out a way to reliably give good results. The only other alternative would be to try all permutations of weights for each duplicate set, but this doesn't always work (as diclophis found with 68427586). I keep thinking to myself, 'there must be a better way'. After many hours of work, I still have not managed to achieve the goal I set for this contest. As I feel I have not produced a good solution for the problem at hand, which has duplicates in, I will not be entering.

At this stage, I realise that you may get the impression that I am all talk and no action. This is entirely untrue. I AM a good programmer and I HAVE put a lot of effort into finding a good solution (about 60 hours).

To those of you who have a well coded program you are proud of, I implore you to enter and wish you the best of luck.

I've enjoyed this contest; unfortunately I couldn't crack it. I look forward to the next one.

To the creators of PHP, I've noticed two things which I found annoying.
In C++, when I return values from a function, I prefer not to test on the actual value, rather I define macros for each return value with a name that means something. eg. #define ELSINGLE 1. I couldn't find out how to do that in PHP, so I used a global variable. eg. $elsingle = 1;.

Also, it doesn't seem possible to overload constructors. I had to use a child class to implement another constructor.

Of course, apart from this contest, most of my PHP experience has been with PHP3. There may be ways to do these things now that I am not aware of.

Anyway, till next time.
Neil Cahill aka -vertigo-

PS. About the wise quote below, it is not anything some famous person said; rather I am quoting myself. Since I'm such a wise guy, it becomes a wise quote.

Reply With Quote
  #2  
Old November 23rd, 2002, 10:29 AM
JRA JRA is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 22 JRA User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: The end of my contest

Hi Vertigo

Although I haven't posted here I have been following the conversations.
I was looking forward to competing against your code

I respect that you were trying for a close to perfect algorithm.
My goal was just to beat the brute force algoritm mentioned on the boards.

The point is your code doesn't have to be amazing - just better than thte others

I hope you reconsider entering something - especially after spending so much time on it.

With regards to use of macros in c++, from what you say I believe you are looking for something like this:
php Code:
Original - php Code
  1.  
  2. define ("ELSINGLE", 1);


Can't help with overload constructors

regards,
John

Reply With Quote
  #3  
Old November 24th, 2002, 11:57 AM
zombie zombie is offline
Codewalkers Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2007
Location: serbia
Posts: 1,876 zombie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: The end of my contest

-vertigo-

if you spent 60 hours on your solution, i would suggest you enter the contest.

you never know how bad did others do!!

Reply With Quote
  #4  
Old November 24th, 2002, 02:32 PM
-vertigo- -vertigo- is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Louth, Lincolnshire
Posts: 314 -vertigo- User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 24 sec
Reputation Power: 3
RE: The end of my contest

Thanks for the replies.

The truth is, I had worked many hours on trying to get the best algorithm, but it was not completely coded. In fact, I only started coding after the first week.

Usually with a problem as difficult as this, I find that if I start coding to early, I usually end up rewriting from scratch.

So, although I knew how to sort no-duplicate lists, I had not coded the final modifications which saved 1-2 moves about 20% of the time. When I wrote the previous post, I had realised that although the code was good for non-duplicate lists, to modify it for lists with duplicates and trying multiple weight combinations would have used a LOT of memory. So I would essentially have to recode from scratch anyway.

As I said, I wanted to have an algorithm which didn't bruteforce. So, it wasn't particularly conservative with memory.

I put myself in a spot, because the way I wrote my code, it could only really be used without brute-forceing. Otherwise, I would not rely so much on the algorithm, rather on finding the best of several duplicates and making that process fast.

As I said, I enjoyed coding it as I haven't seriously coded for nearly two years. Next competition I will seriously try to get an entry in.

Cheers

Reply With Quote
  #5  
Old November 24th, 2002, 03:50 PM
-vertigo- -vertigo- is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Louth, Lincolnshire
Posts: 314 -vertigo- User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 24 sec
Reputation Power: 3
RE: The end of my contest

I was slightly mistaken in my previous post. I could of course branch before I sort anything, instead of when one of a duplicate set comes to the top of a stack.

Then it would need exactly the same memory, just longer execution time.

Loooking back, I wouldn't have done my program the same way. It was implemented as an object, containing a list of elements. When adjacent elements become compatable, they merge. eg. when 231 becomes 321, the sorted element 23 and the single 1 merge. I certainly don't think this was the best way to do it. The code also became very long, almost 1000 lines.

Especially if I planned to brute-force, I would have worked with one global array throughout.

Even had I tried to simply sort all combos of weighted dups, my algorithm was not completely coded. It was fine in my head, but to get that into code is not always easy.

I seriously doubt I could have revamped my program in the two days which remained.

They say every failure is one step closer to success. Hopefully next time will be better.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP ContestsOlder Contests > The end of my contest


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 8 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek