![]() |
Programming Challenges?
Afternoon All,
I could do with getting some programming practice, and (whilst I'm at it) gaining at least a passing familiarity with a few different programming languages. I know that there are a few sites out there that have daily/weekly/monthly programming challenges, but are there any that you would recommend? Also, anybody got any thoughts on some little programming type tasks that might give me a little practice? |
Re: Programming Challenges?
What language?
I'll start with an easy one. (Don't look it up online ;)) Program something that will print to console/throw an alert for every multiple of 5 and 3 between 1 and 100. For numbers that are both multiples of 3 and 5 do something special. It's a common test. |
Re: Programming Challenges?
Any language really, doesn't matter.
Will have a go at your challenge tomorrow at work, thanks for that :tu: |
Re: Programming Challenges?
I gonna try to do it in C# later in the shortest/most elegant way I can. I'll wack it here in spoiler tags.
|
Re: Programming Challenges?
Cool, thanks.
I'll probably start with Python or something like that. |
Re: Programming Challenges?
Spoiler:
|
Re: Programming Challenges?
You could try PERL, C-sharp (just noticed my Mac doesn't have a hash key :() or JAVA as they seem to be popular languages lately.
|
Re: Programming Challenges?
I did more or less the same. Just one suggestion i'd make regarding your code Damien:
Spoiler:
|
Re: Programming Challenges?
Quote:
|
Re: Programming Challenges?
BTW the absolute classic programming challenge is to generate an array of random numbers and then sort it manually. Once you do it, then you can refine it to make it as efficient as possible.
I guarantee every programming course has that exercise. |
Re: Programming Challenges?
Quote:
---------- Post added at 21:29 ---------- Previous post was at 21:28 ---------- Quote:
I'll try tomorrow. |
Re: Programming Challenges?
Quote:
|
Re: Programming Challenges?
Quote:
Int32 is actually the structure that contains "int" - so you can just as easily use 'int' or actually use an implicitly typed local variable - 'var' as it will actually pick up that your variable type is an integer. Int32 is generally used to parse or switch another variable type into the integer type (Int32.Parse) or set the maximum or minimum value of a specified integer. Good job with the if statements though - I like how you ignored the curly braces as they're not necessary when you only have the one line of code being executed. However - your code will simply run through and then close when it's finished calculating all of the multiples, what you may want to do is stick Code:
Console.ReadKey(true); ---------- Post added at 10:06 ---------- Previous post was at 09:54 ---------- Quote:
For this, you can just use, in C#: Code:
Array.Sort(yourArray); Seeing as you're only using 10 random numbers, I suggest you actually create your own code for a bubble sort algorithm - http://en.wikipedia.org/wiki/Bubble_sort |
Re: Programming Challenges?
Quote:
Quote:
|
Re: Programming Challenges?
Quote:
Spoiler:
http://en.wikipedia.org/wiki/Quicksort |
All times are GMT +1. The time now is 05:32. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
All Posts and Content are © Cable Forum