Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Temporary Programming Challanges!
New Posts  All Forums:Forum Nav:

Temporary Programming Challanges! - Page 2

post #11 of 23
Hehe

It's about time!
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 G0 @3.3Ghz Gigabyte EP45-UD3P Sapphire 2900Pro Flashed to XT 4Gb Gskill 1066Mhz PK's 
Hard DriveOptical DriveOSMonitor
Seagate Barracuda 320Gb & WD Black 640Gb Lite On Vista Business and VMWare Ubuntu Acer AL2223W 22" 
KeyboardPowerCaseMouse
Ergonomic 4000 Corsair HX 620W CM 690 G5 
  hide details  
Reply
It's about time!
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 G0 @3.3Ghz Gigabyte EP45-UD3P Sapphire 2900Pro Flashed to XT 4Gb Gskill 1066Mhz PK's 
Hard DriveOptical DriveOSMonitor
Seagate Barracuda 320Gb & WD Black 640Gb Lite On Vista Business and VMWare Ubuntu Acer AL2223W 22" 
KeyboardPowerCaseMouse
Ergonomic 4000 Corsair HX 620W CM 690 G5 
  hide details  
Reply
post #12 of 23
I was working on a different math based approach (using the sum of the x,y coords). It worked great for the top half, but I had to use a different alg for the bottom half. I ran out of time this morning before I could re-work it. Nice job.

All of the solutions are nice. However from a professional standpoint there has to be a cross between elegance, functionality and readability. The number of lines in a compilied language doesn't matter. Certainly minimizing loops and extra processing is important, but raw size doesn't really matter. Some of the solutions appear to be obfuscated in order to minimize the "size" of the application. In the professional setting you need to focus on readability a little more. Self documenting code via explanatory variable names is often very helpful. Try not to get caught up solely in the length of size of the code. Remember what you write isn't what is processed, it all goes through an interpreter and is compiled down. Same theory for variable names goes with consistant line control and tabbing. Just makes it easier for the rest of your team if you write code that doesn't need to be reformatted to read easier.

Otherwise, kudos for the work.
Main Rig
(15 items)
 
  
Reply
Main Rig
(15 items)
 
  
Reply
post #13 of 23
I had to revise mine a bit.
8 lines
Code:
#!/usr/bin/env perl
($num, $char, $count); # variables
print "Enter an odd number follow by a character => ";
($num, $char) = split(" ", <STDIN>); # Getting input
for ($i = 1; $i <= $num; $i += 2){ # Top half of triangle
    print (" " x (int($num + 1 / 2) - $i), "$char " x $i,"\
"); }
for ($count = $num - 2; $count >= 0; $count -= 2){ # Bottom half of triangle
    print (" " x (int($num + 1 / 2) - $count), "$char " x $count,"\
"); }

BlackMesa
(14 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II x6 Gigabyte XFX RF460 16gb G.Skill 
Hard DriveHard DriveOSMonitor
OCZ Vertex2 Sata II Coorsair Force GS Sata III Debian (testing) Shimian 27" 
KeyboardMouse
Filco w/ blue cherries Who needs a mouse? 
  hide details  
Reply
BlackMesa
(14 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II x6 Gigabyte XFX RF460 16gb G.Skill 
Hard DriveHard DriveOSMonitor
OCZ Vertex2 Sata II Coorsair Force GS Sata III Debian (testing) Shimian 27" 
KeyboardMouse
Filco w/ blue cherries Who needs a mouse? 
  hide details  
Reply
post #14 of 23
Thread Starter 
I completely agree BFRD! It was posed to me this way so that students would have a goal to post the shortest code possible. Definitely a good point for those who are not classically instructed in computer science.
GAMR
(15 items)
 
  
CPUMotherboardGraphicsGraphics
6600K ASUS Z170-A ASUS 970 Strix ASUS 970 Strix 
RAMHard DriveHard DriveHard Drive
Crucial Ballistix Elite Samsung 850 EVO Intel 320 6400AAKS 
Hard DriveCoolingMonitorPower
6400AAKS Cooler Master Hyper 212 EVO ASUS VG24QE EVGA SuperNova 650 G2 
CaseMouseMouse Pad
Antec 1200 Razer Abyssus 3.5G QCK+ 
  hide details  
Reply
GAMR
(15 items)
 
  
CPUMotherboardGraphicsGraphics
6600K ASUS Z170-A ASUS 970 Strix ASUS 970 Strix 
RAMHard DriveHard DriveHard Drive
Crucial Ballistix Elite Samsung 850 EVO Intel 320 6400AAKS 
Hard DriveCoolingMonitorPower
6400AAKS Cooler Master Hyper 212 EVO ASUS VG24QE EVGA SuperNova 650 G2 
CaseMouseMouse Pad
Antec 1200 Razer Abyssus 3.5G QCK+ 
  hide details  
Reply
post #15 of 23
Quote:
Originally Posted by BFRD View Post
I was working on a different math based approach (using the sum of the x,y coords). It worked great for the top half, but I had to use a different alg for the bottom half. I ran out of time this morning before I could re-work it. Nice job.

All of the solutions are nice. However from a professional standpoint there has to be a cross between elegance, functionality and readability. The number of lines in a compilied language doesn't matter. Certainly minimizing loops and extra processing is important, but raw size doesn't really matter. Some of the solutions appear to be obfuscated in order to minimize the "size" of the application. In the professional setting you need to focus on readability a little more. Self documenting code via explanatory variable names is often very helpful. Try not to get caught up solely in the length of size of the code. Remember what you write isn't what is processed, it all goes through an interpreter and is compiled down. Same theory for variable names goes with consistant line control and tabbing. Just makes it easier for the rest of your team if you write code that doesn't need to be reformatted to read easier.

Otherwise, kudos for the work.
Heh, I know what you mean. I only squished things a bit to get down to functioning on 14 lines. I'd like to think my actual code is stylistically decent, this was just a poor example because our #1 focus was lines used. I'm actually fairly notorious for spacing everything out nicely, often having longer than normal files. I guess there's a difference between onlince competition for fun and professional level code.

And its interesting to think of it in a coordinate system. I was almost going to break it down into binary to see if I could find a simple solution, until I figured out the math behind it. I'll look forward to seeing what you have if you do get it done!
It's about time!
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 G0 @3.3Ghz Gigabyte EP45-UD3P Sapphire 2900Pro Flashed to XT 4Gb Gskill 1066Mhz PK's 
Hard DriveOptical DriveOSMonitor
Seagate Barracuda 320Gb & WD Black 640Gb Lite On Vista Business and VMWare Ubuntu Acer AL2223W 22" 
KeyboardPowerCaseMouse
Ergonomic 4000 Corsair HX 620W CM 690 G5 
  hide details  
Reply
It's about time!
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 G0 @3.3Ghz Gigabyte EP45-UD3P Sapphire 2900Pro Flashed to XT 4Gb Gskill 1066Mhz PK's 
Hard DriveOptical DriveOSMonitor
Seagate Barracuda 320Gb & WD Black 640Gb Lite On Vista Business and VMWare Ubuntu Acer AL2223W 22" 
KeyboardPowerCaseMouse
Ergonomic 4000 Corsair HX 620W CM 690 G5 
  hide details  
Reply
post #16 of 23
Quote:
Originally Posted by BFRD View Post
I was working on a different math based approach (using the sum of the x,y coords). It worked great for the top half, but I had to use a different alg for the bottom half. I ran out of time this morning before I could re-work it. Nice job.

All of the solutions are nice. However from a professional standpoint there has to be a cross between elegance, functionality and readability. The number of lines in a compilied language doesn't matter. Certainly minimizing loops and extra processing is important, but raw size doesn't really matter. Some of the solutions appear to be obfuscated in order to minimize the "size" of the application. In the professional setting you need to focus on readability a little more. Self documenting code via explanatory variable names is often very helpful. Try not to get caught up solely in the length of size of the code. Remember what you write isn't what is processed, it all goes through an interpreter and is compiled down. Same theory for variable names goes with consistant line control and tabbing. Just makes it easier for the rest of your team if you write code that doesn't need to be reformatted to read easier.

Otherwise, kudos for the work.
I'd have to agree. I think readability is more important than size.
When I write something for a course, I use a lot of space and comments in my code. In the end I'm happy with the time I put into it to add comments and try to work out good logic. They look nothing the packed mess of code, like the two examples I posted.
BlackMesa
(14 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II x6 Gigabyte XFX RF460 16gb G.Skill 
Hard DriveHard DriveOSMonitor
OCZ Vertex2 Sata II Coorsair Force GS Sata III Debian (testing) Shimian 27" 
KeyboardMouse
Filco w/ blue cherries Who needs a mouse? 
  hide details  
Reply
BlackMesa
(14 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II x6 Gigabyte XFX RF460 16gb G.Skill 
Hard DriveHard DriveOSMonitor
OCZ Vertex2 Sata II Coorsair Force GS Sata III Debian (testing) Shimian 27" 
KeyboardMouse
Filco w/ blue cherries Who needs a mouse? 
  hide details  
Reply
post #17 of 23
Quote:
Originally Posted by dangerousHobo View Post
I had to revise mine a bit.
8 lines
Code:
#!/usr/bin/env perl
($num, $char, $count); # variables
print "Enter an odd number follow by a character => ";
($num, $char) = split(" ", <STDIN>); # Getting input
for ($i = 1; $i <= $num; $i += 2){ # Top half of triangle
    print (" " x (int($num + 1 / 2) - $i), "$char " x $i,"\
"); }
for ($count = $num - 2; $count >= 0; $count -= 2){ # Bottom half of triangle
    print (" " x (int($num + 1 / 2) - $count), "$char " x $count,"\
"); }

Ugh, nice job. Can't compete with that in a C based language


Edit: yipee 400 posts!
It's about time!
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 G0 @3.3Ghz Gigabyte EP45-UD3P Sapphire 2900Pro Flashed to XT 4Gb Gskill 1066Mhz PK's 
Hard DriveOptical DriveOSMonitor
Seagate Barracuda 320Gb & WD Black 640Gb Lite On Vista Business and VMWare Ubuntu Acer AL2223W 22" 
KeyboardPowerCaseMouse
Ergonomic 4000 Corsair HX 620W CM 690 G5 
  hide details  
Reply
It's about time!
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 G0 @3.3Ghz Gigabyte EP45-UD3P Sapphire 2900Pro Flashed to XT 4Gb Gskill 1066Mhz PK's 
Hard DriveOptical DriveOSMonitor
Seagate Barracuda 320Gb & WD Black 640Gb Lite On Vista Business and VMWare Ubuntu Acer AL2223W 22" 
KeyboardPowerCaseMouse
Ergonomic 4000 Corsair HX 620W CM 690 G5 
  hide details  
Reply
post #18 of 23
OMG, I can write it all on the same line in C by never hitting return!

    
CPUMotherboardGraphicsRAM
Q6600 G0 @ 3.24GHz w/ 1.36v (L724A760) Gigabyte P35-DS3R rev 1.0 EVGA GTX 285 1GB + ? BIOS (720c/1512s/1377m) 8GB G.Skill PQ @ 1000MHz 5-5-5-15 
Hard DriveOptical DriveOSMonitor
2x320GB 7200.11 Raid0 + 750GB 7200.11 for Storage Samsung SH-S203B Windows 7 Pro x64 Samsung T260HD 1920x1200 + Samsung 226BW 1680x1050 
KeyboardPowerCaseMouse
Saitek Eclipse II PC Power & Cooling Silencer 750W Antec Nine Hundred Razer DeathAdder 
Mouse Pad
Razer Destructor 
  hide details  
Reply
    
CPUMotherboardGraphicsRAM
Q6600 G0 @ 3.24GHz w/ 1.36v (L724A760) Gigabyte P35-DS3R rev 1.0 EVGA GTX 285 1GB + ? BIOS (720c/1512s/1377m) 8GB G.Skill PQ @ 1000MHz 5-5-5-15 
Hard DriveOptical DriveOSMonitor
2x320GB 7200.11 Raid0 + 750GB 7200.11 for Storage Samsung SH-S203B Windows 7 Pro x64 Samsung T260HD 1920x1200 + Samsung 226BW 1680x1050 
KeyboardPowerCaseMouse
Saitek Eclipse II PC Power & Cooling Silencer 750W Antec Nine Hundred Razer DeathAdder 
Mouse Pad
Razer Destructor 
  hide details  
Reply
post #19 of 23
Quote:
Originally Posted by Muhahahaha View Post
OMG, I can write it all on the same line in C by never hitting return!



And I came in here hoping another challenge was posted...
It's about time!
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 G0 @3.3Ghz Gigabyte EP45-UD3P Sapphire 2900Pro Flashed to XT 4Gb Gskill 1066Mhz PK's 
Hard DriveOptical DriveOSMonitor
Seagate Barracuda 320Gb & WD Black 640Gb Lite On Vista Business and VMWare Ubuntu Acer AL2223W 22" 
KeyboardPowerCaseMouse
Ergonomic 4000 Corsair HX 620W CM 690 G5 
  hide details  
Reply
It's about time!
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 G0 @3.3Ghz Gigabyte EP45-UD3P Sapphire 2900Pro Flashed to XT 4Gb Gskill 1066Mhz PK's 
Hard DriveOptical DriveOSMonitor
Seagate Barracuda 320Gb & WD Black 640Gb Lite On Vista Business and VMWare Ubuntu Acer AL2223W 22" 
KeyboardPowerCaseMouse
Ergonomic 4000 Corsair HX 620W CM 690 G5 
  hide details  
Reply
post #20 of 23
Thread Starter 
See the new thread... Apparently nobody's attempted it yet =\\
GAMR
(15 items)
 
  
CPUMotherboardGraphicsGraphics
6600K ASUS Z170-A ASUS 970 Strix ASUS 970 Strix 
RAMHard DriveHard DriveHard Drive
Crucial Ballistix Elite Samsung 850 EVO Intel 320 6400AAKS 
Hard DriveCoolingMonitorPower
6400AAKS Cooler Master Hyper 212 EVO ASUS VG24QE EVGA SuperNova 650 G2 
CaseMouseMouse Pad
Antec 1200 Razer Abyssus 3.5G QCK+ 
  hide details  
Reply
GAMR
(15 items)
 
  
CPUMotherboardGraphicsGraphics
6600K ASUS Z170-A ASUS 970 Strix ASUS 970 Strix 
RAMHard DriveHard DriveHard Drive
Crucial Ballistix Elite Samsung 850 EVO Intel 320 6400AAKS 
Hard DriveCoolingMonitorPower
6400AAKS Cooler Master Hyper 212 EVO ASUS VG24QE EVGA SuperNova 650 G2 
CaseMouseMouse Pad
Antec 1200 Razer Abyssus 3.5G QCK+ 
  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 › Temporary Programming Challanges!