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 25

post #241 of 244
Just found out the challanges are up again, it will be nice to put myself in trouble hehe!
I'll go with PHP preferably since I almost forgot what I learned in C++ thumbsdownsmileyanim.gif
post #242 of 244
Quote:
Originally Posted by Icekilla View Post

R = (A+B) + (A-B) + (B+A) + (B-A)
It's harder than you think].

No it's not.

In Python
Code:
def easy(A, B):
    return (A+B) + (A-B) + (B+A) + (B-A)

Easy.
Back in Black
(13 items)
 
  
CPUMotherboardGraphicsRAM
AMD Phenom II X4 965 BE (C3) Biostar TA790GX A3+ Sapphire HD 5770 (v2) CORSAIR XMS3 4GB DDR3 
Hard DriveOptical DriveOSMonitor
WD Caviar Black 640GB Sony Optiarc CD/DVD RW Windows 7 Ultimate x64 NEC MultiSync LCD 1960NXi 
KeyboardPowerCaseMouse
Microsoft Comfort Curve Keyboard 2000 Corsair 650TX Cooler Master Storm Scout Logitech MX 400 Laser 
  hide details  
Reply
Back in Black
(13 items)
 
  
CPUMotherboardGraphicsRAM
AMD Phenom II X4 965 BE (C3) Biostar TA790GX A3+ Sapphire HD 5770 (v2) CORSAIR XMS3 4GB DDR3 
Hard DriveOptical DriveOSMonitor
WD Caviar Black 640GB Sony Optiarc CD/DVD RW Windows 7 Ultimate x64 NEC MultiSync LCD 1960NXi 
KeyboardPowerCaseMouse
Microsoft Comfort Curve Keyboard 2000 Corsair 650TX Cooler Master Storm Scout Logitech MX 400 Laser 
  hide details  
Reply
post #243 of 244
Quote:
Originally Posted by Chris++ View Post

No it's not.
In Python
Code:
def easy(A, B):
    return (A+B) + (A-B) + (B+A) + (B-A)
Easy.

Also trying to understand what could possibly be difficult about that challenge and what the relevance is of the input rules. Perhaps it's meant to restrict input, although if that's the case then resulting behavior should be defined.

But you forgot to include the "hard" part for getting input, parsing it, and printing. tongue.gif

Perl
Code:
my $input = <>;
$input =~ /^(\d+)\s(\d+)$/;
print (($1+$2) + ($1-$2) + ($2+$1) + ($2-$1));
Main Rig
(20 items)
 
   
CPUMotherboardGraphicsRAM
Phenom II 1090T @3.8GHz, CPU-NB @3.0GHz Asus M5A99X EVO Sapphire HD 7950 Corsair Vengeance 16GB 
Hard DriveHard DriveHard DriveOptical Drive
Crucial M4 128GB 2 x Samsung F3 1TB (RAID 0) Seagate Barracuda 3TB Asus DVD-RW 
CoolingCoolingOSMonitor
CPU: Noctua NH-D14 GPU: Corsair H60 Windows 8 Pro Viewsonic VX2770SMH-LED 
MonitorKeyboardPowerCase
Samsung 943BWX Ducky YOTD (MX Brown) Lepa G700-MA Fractal Design Define R3 
MouseMouse PadAudioAudio
Roccat Savu Steelseries 9HD Beyerdynamic DT 880 Asus Xonar DG 
CPUMotherboardGraphicsRAM
AMD A6-3500 Asrock A75M HD 6530D Samsung 4GB DDR3 1600  
Hard DriveHard DriveHard DriveOptical Drive
Intel 320 80GB Samsung Spinpoint F4 2TB WD Caviar Green 3TB Sony BD-Rom 
CoolingOSMonitorKeyboard
Noctua NH-C12P SE14 Win 7 Professional 64-bit Samsung LN46C600 Lenovo N5902 
PowerCaseOther
Corsair CX430 Antec Veris Fusion Hauppage WinTV DCR-2650 
CPUMotherboardGraphicsRAM
AMD Phenom II X3 B55 Gigabyte GA-MA785GM-US2H MSI HD 5750 G.Skill 4GB DDR2 
Hard DriveOptical DriveCoolingMonitor
Samsung F3 1TB LG DVD-RW CM Hyper 212 Plus Dell U2312HM 
KeyboardPowerCaseMouse
Pink KBT Race (MX Blue) Corsair CX400 Corsair 500R Razer Abyssus 
Mouse Pad
Modware Radiance 
  hide details  
Reply
Main Rig
(20 items)
 
   
CPUMotherboardGraphicsRAM
Phenom II 1090T @3.8GHz, CPU-NB @3.0GHz Asus M5A99X EVO Sapphire HD 7950 Corsair Vengeance 16GB 
Hard DriveHard DriveHard DriveOptical Drive
Crucial M4 128GB 2 x Samsung F3 1TB (RAID 0) Seagate Barracuda 3TB Asus DVD-RW 
CoolingCoolingOSMonitor
CPU: Noctua NH-D14 GPU: Corsair H60 Windows 8 Pro Viewsonic VX2770SMH-LED 
MonitorKeyboardPowerCase
Samsung 943BWX Ducky YOTD (MX Brown) Lepa G700-MA Fractal Design Define R3 
MouseMouse PadAudioAudio
Roccat Savu Steelseries 9HD Beyerdynamic DT 880 Asus Xonar DG 
CPUMotherboardGraphicsRAM
AMD A6-3500 Asrock A75M HD 6530D Samsung 4GB DDR3 1600  
Hard DriveHard DriveHard DriveOptical Drive
Intel 320 80GB Samsung Spinpoint F4 2TB WD Caviar Green 3TB Sony BD-Rom 
CoolingOSMonitorKeyboard
Noctua NH-C12P SE14 Win 7 Professional 64-bit Samsung LN46C600 Lenovo N5902 
PowerCaseOther
Corsair CX430 Antec Veris Fusion Hauppage WinTV DCR-2650 
CPUMotherboardGraphicsRAM
AMD Phenom II X3 B55 Gigabyte GA-MA785GM-US2H MSI HD 5750 G.Skill 4GB DDR2 
Hard DriveOptical DriveCoolingMonitor
Samsung F3 1TB LG DVD-RW CM Hyper 212 Plus Dell U2312HM 
KeyboardPowerCaseMouse
Pink KBT Race (MX Blue) Corsair CX400 Corsair 500R Razer Abyssus 
Mouse Pad
Modware Radiance 
  hide details  
Reply
post #244 of 244
Quote:
Originally Posted by Icekilla View Post

I have a challenge for you

Given two numbers A and B, 1 <= A, B <= 10^9, you must find the following calculation:
R = (A+B) + (A-B) + (B+A) + (B-A)

Data input
The only line of the input is two space separated numbers, A and B.

Data output
The only line of the output is the result of the calculation, R.

Input samples
10 5

Output samples
30

It's harder than you think, took it from COJ.

I don't possibly see what is hard about that, especially if you simplify first to: 2*(A+B)
Regen v2
(18 items)
 
  
CPUMotherboardGraphicsRAM
Intel i7-3770K Asus p8z77-deluxe Asus Geforce GTX 590 samsung 4GB DDR3 
Hard DriveCoolingOSMonitor
Combined: 6.13 TB of space Silver Arrow SB-E Extreme Windows 8 Pro Asus VG278H 
KeyboardPowerCaseMouse
Overclock.net Ducky Keyboard Corsair AX1200 Corsair Obsidian 800D Logitech Performance MX 
AudioAudioAudioAudio
Onkyo TX-809NR KRK 10-3 Studio Mid-Field Monitors(Pair) HSU ULS-15 Subwoofer MOTO Microbook II 
AudioAudio
MXL v69 Mogami Edition Tube Microphone Rode PSA-1 Microphone Arm 
  hide details  
Reply
Regen v2
(18 items)
 
  
CPUMotherboardGraphicsRAM
Intel i7-3770K Asus p8z77-deluxe Asus Geforce GTX 590 samsung 4GB DDR3 
Hard DriveCoolingOSMonitor
Combined: 6.13 TB of space Silver Arrow SB-E Extreme Windows 8 Pro Asus VG278H 
KeyboardPowerCaseMouse
Overclock.net Ducky Keyboard Corsair AX1200 Corsair Obsidian 800D Logitech Performance MX 
AudioAudioAudioAudio
Onkyo TX-809NR KRK 10-3 Studio Mid-Field Monitors(Pair) HSU ULS-15 Subwoofer MOTO Microbook II 
AudioAudio
MXL v69 Mogami Edition Tube Microphone Rode PSA-1 Microphone Arm 
  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