View Single Post
Old 14-08-2009, 10:46   #16
LemonyBrainAid
Inactive
 
Join Date: Jul 2004
Location: 127.0.0.1
Services: 50MB Virgin w/ TiVo 1TB
Posts: 1,255
LemonyBrainAid has a bronze arrayLemonyBrainAid has a bronze arrayLemonyBrainAid has a bronze array
LemonyBrainAid has a bronze arrayLemonyBrainAid has a bronze arrayLemonyBrainAid has a bronze arrayLemonyBrainAid has a bronze array
Re: Programming Challenges?

Quote:
Originally Posted by Damien View Post
I prefer using Int32 because I prefer the highlighting in Visual Studio for it . As for var, there is little point in this case because I know the type of the variable, for the sake of clear code it is easier to explicitly declare it. Anyone reading the code will be very clear on what data type this is. (Also, Not everyone uses C# 3.5, which introduced Implicitly typed variables)
At the end of the day, it's your code, your choice, this is just how I've been taught by SAMS, Microsoft and tutorials across the web

The main advantage of using var is that unlike VB, it doesn't mean 'Variant' - CSC actually determines the most appropriate type for it based on your code - meaning less error margin. (i.e. say I used an integer then later in the code parsed values of over 2,147,483,648, it would auto assign it to be a double)

And I think you're getting your version numbers mixed, .NET 3.0 introduced C# 3.0 and .NET 3.5 is the most current version.

Quote:
Originally Posted by Damien View Post
My example was writing to a String Builder which had a debug at the end. I changed it to console at the end. Probably should have added that.
That's fair enough

---------- Post added at 10:46 ---------- Previous post was at 10:44 ----------

Quote:
Originally Posted by danielf View Post
For large Ns, try quicksort.

Spoiler: 

(defun quick-sort (a-list)
(let ((pivot nil)
(lesser nil)
(greater nil))
(when a-list
(cond ((= (length a-list) 1)
(list (first a-list)))
(t
(setf pivot (first a-list))
(dolist (item (rest a-list))
(if (<= item pivot)
(push item lesser)
(push item greater)))
(append (quick-sort lesser) (list pivot) (quick-sort greater))
)))))


http://en.wikipedia.org/wiki/Quicksort
Yeah - I chose Bubble Sort because from the basic programming challenges that were requested it's one of the simplest algorithms to use. By far not the fastest, but simple and easy to understand.
LemonyBrainAid is offline   Reply With Quote