Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › The Programming Challenge Master Thread
New Posts  All Forums:Forum Nav:

The Programming Challenge Master Thread - Page 15

post #141 of 263
Quote:
Originally Posted by tehwalris View Post

Yeah, for this job, the ammount of time taken writing the code could be considered as being the efficiency.

But that would be your time spent that was efficient, not the code itself (ie you used your time more efficiently in using a language that took less time to develop). The code itself would be inefficient but it enabled yourself to use your development time more efficiently.

I know I'm arguing semantics here (and please bare with me as I launch into a rant hehehe) but I think many people are wrongly taught in college / uni that code efficiency doesn't matter given the power of modern hardware. While this is true for desktop applications, it makes a significant difference the moment you start looking at server appliances and/or real time applications. Given that code efficiency is easier to teach when you're learning to develop than it is to unteach lazy habits, I do see the benefit in being specific about efficiency.

I know these challenges are just for fun and I know I probably come across as a touch elitist (despite the that that the majority of my examples have been in a JIT byte-code compiled language), but I've seen so many examples of wonky code over the years that it's not even funny (though ironically the worst source code I've ever seen was Microsoft's own example of DDE calls to Windows applications (going back a few years now lol). The code was so bad it literally fork bombed itself!!!)

Any how, rant over now biggrin.gif
Edited by Plan9 - 12/29/11 at 7:36am
post #142 of 263
I agree on most parts with you but tbh code efficiency is one thing the other is to implement algorithms that are efficient. You can have very efficient code with minimal overhead etc if the algorithm and/or data structure you use is inefficient and vice-versa.

I don't know about other places but we have 2 semesters worth of courses about algorithms and data structures in BSc, during these we don't actually code just learn about the efficiency of certain algorithm and data types and when to use which etc. Then we have a lot of other courses where we learn about a given language and how use that properly.
Footrest
(17 items)
 
server
(17 items)
 
HTPC
(12 items)
 
CPUMotherboardGraphicsRAM
2 x Xeon L5520 Supermicro X8DTL-i HD4550 Samsung 6x4GB ECC 
Hard DriveHard DriveCoolingOS
3 x 2TB WD Green 160GB WD Blue Hyper 212+ and EVO ESXi 
OSOSOSPower
unRaid pfSense Ubuntu CX430v2 
CaseOtherOther
CM Elite 331 TP-Link TG-3269 Sil3512 Sata controller 
CPUMotherboardRAMHard Drive
i3-2100T Asus P8H61-I Geil Black Dragon 1333 2x2GB PXE Network boot 
Optical DriveCoolingOSMonitor
OEM Slim DVD Burner Scythe Big-Shuriken OpenElec Panasonic TX-P42G30E 42" HDTV 
KeyboardCase
Lenovo n5901a Silverstone SG-05 
  hide details  
Reply
Footrest
(17 items)
 
server
(17 items)
 
HTPC
(12 items)
 
CPUMotherboardGraphicsRAM
2 x Xeon L5520 Supermicro X8DTL-i HD4550 Samsung 6x4GB ECC 
Hard DriveHard DriveCoolingOS
3 x 2TB WD Green 160GB WD Blue Hyper 212+ and EVO ESXi 
OSOSOSPower
unRaid pfSense Ubuntu CX430v2 
CaseOtherOther
CM Elite 331 TP-Link TG-3269 Sil3512 Sata controller 
CPUMotherboardRAMHard Drive
i3-2100T Asus P8H61-I Geil Black Dragon 1333 2x2GB PXE Network boot 
Optical DriveCoolingOSMonitor
OEM Slim DVD Burner Scythe Big-Shuriken OpenElec Panasonic TX-P42G30E 42" HDTV 
KeyboardCase
Lenovo n5901a Silverstone SG-05 
  hide details  
Reply
post #143 of 263
Im considering thinking up some more challenges for you guys (harder ones biggrin.gif)
    
CPUMotherboardGraphicsGraphics
FX-8350 Asus Crosshair V MSI GTX460 Hawk 1gb MSI GTX460 Hawk 1gb 
RAMHard DriveHard DriveHard Drive
Kingston HyperX 8gb (2x4gb) Crucial M4 64GB Samsung F3 1TB Western Digital 320GB 
CoolingOSMonitorMonitor
Custom WC Windows 7 Ultimate X64 Dell E2311H Dell E2311H 
MonitorKeyboardPowerCase
LH 23EN43 Ducky Year of the Dragon 2012 SilverStone Strider 1000W-P Corsair 800D 
Audio
Asus Xonar Essence STX 
  hide details  
Reply
    
CPUMotherboardGraphicsGraphics
FX-8350 Asus Crosshair V MSI GTX460 Hawk 1gb MSI GTX460 Hawk 1gb 
RAMHard DriveHard DriveHard Drive
Kingston HyperX 8gb (2x4gb) Crucial M4 64GB Samsung F3 1TB Western Digital 320GB 
CoolingOSMonitorMonitor
Custom WC Windows 7 Ultimate X64 Dell E2311H Dell E2311H 
MonitorKeyboardPowerCase
LH 23EN43 Ducky Year of the Dragon 2012 SilverStone Strider 1000W-P Corsair 800D 
Audio
Asus Xonar Essence STX 
  hide details  
Reply
post #144 of 263
First challenge done

304
Code:
#include <iostream>

using namespace std;

int main()
{
        int n;

        cout << "Enter number of stars: ";
        cin >> n;

        if(n < 1)
        {
                return 0;
        }

        for(int i = 0; i < n; i++)
        {
                for (int j = 0; j < i; j++)
                {       
                        cout << "*";
                }
                cout << endl;
        }

        for(int i = n; i > 0; i--)
        {
                for (int j = i; j > 0; j--)
                {       
                        cout << "*";
                }
                cout << endl;
        }

        cout << "\nChallenge Completed. Press any key to terminate...";
        cin.ignore();
        cin.get();

}

Edited by keeganzero - 12/31/11 at 4:13pm
post #145 of 263
Quote:
Originally Posted by FiX View Post

Im considering thinking up some more challenges for you guys (harder ones biggrin.gif)
{Unregestered} wants to slowly escalate thei difficulty.
Teh neon walris
(17 items)
 
  
CPUMotherboardGraphicsRAM
AMD 1090T Asus M5A99X EVO Asus 7950 2x Kingston ValueRAM DDR3 PC10600/1333MHz CL9 2GB 
Hard DriveHard DriveOptical DriveOS
WD Caviar Blue 1tb 7200rpm Corsair force 3 LiteOn iHAS424 Arch Linux 
OSMonitorMonitorKeyboard
Windows 7 23" LG (Not sure what model) Asus vs247h razer blackwidow 
CaseMouseAudio
Cooler Master Storm Scout Razer naga Beyerdynamic DT-770 
  hide details  
Reply
Teh neon walris
(17 items)
 
  
CPUMotherboardGraphicsRAM
AMD 1090T Asus M5A99X EVO Asus 7950 2x Kingston ValueRAM DDR3 PC10600/1333MHz CL9 2GB 
Hard DriveHard DriveOptical DriveOS
WD Caviar Blue 1tb 7200rpm Corsair force 3 LiteOn iHAS424 Arch Linux 
OSMonitorMonitorKeyboard
Windows 7 23" LG (Not sure what model) Asus vs247h razer blackwidow 
CaseMouseAudio
Cooler Master Storm Scout Razer naga Beyerdynamic DT-770 
  hide details  
Reply
post #146 of 263
keeganzero, what language is that? Headers look like C++ but you used a scanf. I assume it's some form of C?
My rig
(18 items)
 
  
CPUMotherboardGraphicsRAM
4770k M power EVGA GTX 980 SC G.SKILL Sniper (2 x 4GB) DDR3 1600 9-9-9-24 
Hard DriveCoolingOSMonitor
512GB Samsung 940 Pro h100 Windows 8 Home premium Asus VG248QE 
MonitorKeyboardPowerCase
Asus VG248QE Corsair K90 Kingwin Lazer Gold 850w Fractal Design Arc Midi R2 
MouseMouse PadAudioAudio
Logitech G700s Corsair Asus Xonar M-Audio BX5 d2 
Audio
krk 10s 
  hide details  
Reply
My rig
(18 items)
 
  
CPUMotherboardGraphicsRAM
4770k M power EVGA GTX 980 SC G.SKILL Sniper (2 x 4GB) DDR3 1600 9-9-9-24 
Hard DriveCoolingOSMonitor
512GB Samsung 940 Pro h100 Windows 8 Home premium Asus VG248QE 
MonitorKeyboardPowerCase
Asus VG248QE Corsair K90 Kingwin Lazer Gold 850w Fractal Design Arc Midi R2 
MouseMouse PadAudioAudio
Logitech G700s Corsair Asus Xonar M-Audio BX5 d2 
Audio
krk 10s 
  hide details  
Reply
post #147 of 263
Quote:
Originally Posted by Kyleinator View Post

keeganzero, what language is that? Headers look like C++ but you used a scanf. I assume it's some form of C?

Ah, my mistake. I am C++ noob and I used a C scanf. Fixed and changed to a cin.
post #148 of 263
Ah no worries. I am fairly new to programming myself so I was just curious.
My rig
(18 items)
 
  
CPUMotherboardGraphicsRAM
4770k M power EVGA GTX 980 SC G.SKILL Sniper (2 x 4GB) DDR3 1600 9-9-9-24 
Hard DriveCoolingOSMonitor
512GB Samsung 940 Pro h100 Windows 8 Home premium Asus VG248QE 
MonitorKeyboardPowerCase
Asus VG248QE Corsair K90 Kingwin Lazer Gold 850w Fractal Design Arc Midi R2 
MouseMouse PadAudioAudio
Logitech G700s Corsair Asus Xonar M-Audio BX5 d2 
Audio
krk 10s 
  hide details  
Reply
My rig
(18 items)
 
  
CPUMotherboardGraphicsRAM
4770k M power EVGA GTX 980 SC G.SKILL Sniper (2 x 4GB) DDR3 1600 9-9-9-24 
Hard DriveCoolingOSMonitor
512GB Samsung 940 Pro h100 Windows 8 Home premium Asus VG248QE 
MonitorKeyboardPowerCase
Asus VG248QE Corsair K90 Kingwin Lazer Gold 850w Fractal Design Arc Midi R2 
MouseMouse PadAudioAudio
Logitech G700s Corsair Asus Xonar M-Audio BX5 d2 
Audio
krk 10s 
  hide details  
Reply
post #149 of 263
I know it is late but I'm going to catch up and try to stay current with this.
Here is my code:
Code:
#include <iostream>
using namespace std;
int main(){
        int number;
        cout << "How many '*' would you like? ";
        cin >> number;
        for(int a = 0; a <= number; a++){
                for(int b = 0; b < a; b++)
                        cout << "*";
                cout << endl;
        }
        for(int a = number; a > 0; a--){
                for(int b = a; b > 1; b--)
                        cout << "*";
                cout << endl;
        }
        return 0;
}

Here is what it does:

OCN1.png
Edited by Kyleinator - 12/31/11 at 4:55pm
My rig
(18 items)
 
  
CPUMotherboardGraphicsRAM
4770k M power EVGA GTX 980 SC G.SKILL Sniper (2 x 4GB) DDR3 1600 9-9-9-24 
Hard DriveCoolingOSMonitor
512GB Samsung 940 Pro h100 Windows 8 Home premium Asus VG248QE 
MonitorKeyboardPowerCase
Asus VG248QE Corsair K90 Kingwin Lazer Gold 850w Fractal Design Arc Midi R2 
MouseMouse PadAudioAudio
Logitech G700s Corsair Asus Xonar M-Audio BX5 d2 
Audio
krk 10s 
  hide details  
Reply
My rig
(18 items)
 
  
CPUMotherboardGraphicsRAM
4770k M power EVGA GTX 980 SC G.SKILL Sniper (2 x 4GB) DDR3 1600 9-9-9-24 
Hard DriveCoolingOSMonitor
512GB Samsung 940 Pro h100 Windows 8 Home premium Asus VG248QE 
MonitorKeyboardPowerCase
Asus VG248QE Corsair K90 Kingwin Lazer Gold 850w Fractal Design Arc Midi R2 
MouseMouse PadAudioAudio
Logitech G700s Corsair Asus Xonar M-Audio BX5 d2 
Audio
krk 10s 
  hide details  
Reply
post #150 of 263
Quote:
Originally Posted by Kyleinator View Post

Code:
#include <iostream>
using namespace std;
int main(){
        int number;
        cout << "How many '*' would you like? ";
        cin >> number;
        for(int a = 0; a <= number; a++){
                for(int b = 0; b < a; b++)
                        cout << "*";
                cout << endl;
        }
        for(int a = number; a > 0; a--){
                for(int b = a; b > 1; b--)
                        cout << "*";
                cout << endl;
        }
        return 0;
}

That is almost exactly like my code o.O
http://www.overclock.net/t/1170144/the-programming-challenge-master-thread/110#post_16039673
    
CPUMotherboardGraphicsGraphics
FX-8350 Asus Crosshair V MSI GTX460 Hawk 1gb MSI GTX460 Hawk 1gb 
RAMHard DriveHard DriveHard Drive
Kingston HyperX 8gb (2x4gb) Crucial M4 64GB Samsung F3 1TB Western Digital 320GB 
CoolingOSMonitorMonitor
Custom WC Windows 7 Ultimate X64 Dell E2311H Dell E2311H 
MonitorKeyboardPowerCase
LH 23EN43 Ducky Year of the Dragon 2012 SilverStone Strider 1000W-P Corsair 800D 
Audio
Asus Xonar Essence STX 
  hide details  
Reply
    
CPUMotherboardGraphicsGraphics
FX-8350 Asus Crosshair V MSI GTX460 Hawk 1gb MSI GTX460 Hawk 1gb 
RAMHard DriveHard DriveHard Drive
Kingston HyperX 8gb (2x4gb) Crucial M4 64GB Samsung F3 1TB Western Digital 320GB 
CoolingOSMonitorMonitor
Custom WC Windows 7 Ultimate X64 Dell E2311H Dell E2311H 
MonitorKeyboardPowerCase
LH 23EN43 Ducky Year of the Dragon 2012 SilverStone Strider 1000W-P Corsair 800D 
Audio
Asus Xonar Essence STX 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › The Programming Challenge Master Thread