Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Programming Challenge (Out-of-Date)
New Posts  All Forums:Forum Nav:

Programming Challenge (Out-of-Date) - Page 17  

Poll Results: Are you interested in participating in and/or helping organise and post these programming challenges?

 
  • 100% (2)
    I want to participate.
  • 0% (0)
    I want to contribute by helping posting and organise these challenges.
  • 0% (0)
    I'll only take part if other people are willing to participate.
  • 0% (0)
    I can help and participate - I love programming!
  • 0% (0)
    I do not wish to participate or help.
2 Total Votes  
post #161 of 306
Quote:
Originally Posted by Midpipps View Post
I think I will leave this up for another week I have not had time to make my entry yet and not sure if no one else is interested or not but maybe someone else will jump in and have some fun with it too.
Yea I'm still trying to find what some people refer to as "free time." I still wonder if it is real or a myth.
post #162 of 306
I vote for myth
    
CPUMotherboardGraphicsRAM
Q6600 DG33TL XFX 6950 2GB 4gigs Corsair XMS2 DDR2 
Hard DriveOptical DriveOSMonitor
1.5TB seagate 2X640GB Samsung DVDRW Windows Vista & Debian Linux Samsung 19" + Acer 24" Wide 
KeyboardPowerCaseMouse
Microsoft SideWinder X6 Antec 750 TruePower Raidmax Smilodon COOLER MASTER Sentinel 
Mouse Pad
RocketFish 
  hide details  
    
CPUMotherboardGraphicsRAM
Q6600 DG33TL XFX 6950 2GB 4gigs Corsair XMS2 DDR2 
Hard DriveOptical DriveOSMonitor
1.5TB seagate 2X640GB Samsung DVDRW Windows Vista & Debian Linux Samsung 19" + Acer 24" Wide 
KeyboardPowerCaseMouse
Microsoft SideWinder X6 Antec 750 TruePower Raidmax Smilodon COOLER MASTER Sentinel 
Mouse Pad
RocketFish 
  hide details  
post #163 of 306
Yeah got some free time thank you insomnia

Code:
import java.util.Scanner;
import java.lang.Math;

public class Tertiarian {
private static int leftWeight = 0;
private static int rightWeight = 0;
private static String leftTray = "";
private static String rightTray = "";
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int initialWeight = 0;

System.out.println("Please enter the weight of the object in the left tray");
initialWeight = in.nextInt();

if ( initialWeight > 0 ){
leftWeight = initialWeight;
findWeights();
}

System.out.println("left pan:" + leftTray + " right pan:" + rightTray);

}

private static void findWeights(){
double logResult;
while(leftWeight != rightWeight){
logResult = 0;
if (leftWeight > rightWeight){
logResult = Math.log((double)(leftWeight-rightWeight))/Math.log((double)(3));
logResult = Math.floor(logResult + 0.5);
rightWeight += Math.pow(3.0, logResult);
rightTray += " " + (int)Math.pow(3.0, logResult);
}else if (rightWeight > leftWeight){
logResult = Math.log((double)(rightWeight-leftWeight))/Math.log((double)(3));
logResult = Math.floor(logResult + 0.5);
leftWeight += (int)Math.pow(3.0, logResult);
leftTray += " " + (int)Math.pow(3.0, logResult);
}
}
}

}
    
CPUMotherboardGraphicsRAM
Q6600 DG33TL XFX 6950 2GB 4gigs Corsair XMS2 DDR2 
Hard DriveOptical DriveOSMonitor
1.5TB seagate 2X640GB Samsung DVDRW Windows Vista & Debian Linux Samsung 19" + Acer 24" Wide 
KeyboardPowerCaseMouse
Microsoft SideWinder X6 Antec 750 TruePower Raidmax Smilodon COOLER MASTER Sentinel 
Mouse Pad
RocketFish 
  hide details  
    
CPUMotherboardGraphicsRAM
Q6600 DG33TL XFX 6950 2GB 4gigs Corsair XMS2 DDR2 
Hard DriveOptical DriveOSMonitor
1.5TB seagate 2X640GB Samsung DVDRW Windows Vista & Debian Linux Samsung 19" + Acer 24" Wide 
KeyboardPowerCaseMouse
Microsoft SideWinder X6 Antec 750 TruePower Raidmax Smilodon COOLER MASTER Sentinel 
Mouse Pad
RocketFish 
  hide details  
post #164 of 306
Quote:
Originally Posted by Midpipps View Post
Yeah got some free time thank you insomnia

Code:
import java.util.Scanner;
import java.lang.Math;

public class Tertiarian {
private static int leftWeight = 0;
private static int rightWeight = 0;
private static String leftTray = "";
private static String rightTray = "";
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int initialWeight = 0;

System.out.println("Please enter the weight of the object in the left tray");
initialWeight = in.nextInt();

if ( initialWeight > 0 ){
leftWeight = initialWeight;
findWeights();
}

System.out.println("left pan:" + leftTray + " right pan:" + rightTray);

}

private static void findWeights(){
double logResult;
while(leftWeight != rightWeight){
logResult = 0;
if (leftWeight > rightWeight){
logResult = Math.log((double)(leftWeight-rightWeight))/Math.log((double)(3));
logResult = Math.floor(logResult + 0.5);
rightWeight += Math.pow(3.0, logResult);
rightTray += " " + (int)Math.pow(3.0, logResult);
}else if (rightWeight > leftWeight){
logResult = Math.log((double)(rightWeight-leftWeight))/Math.log((double)(3));
logResult = Math.floor(logResult + 0.5);
leftWeight += (int)Math.pow(3.0, logResult);
leftTray += " " + (int)Math.pow(3.0, logResult);
}
}
}

}

Nice, I recently developed a neck problem affecting the nerves in the back of my neck. Long story short, any chance of free time just got filled with zoning out on muscle relaxers...
post #165 of 306
LOL yeah was hoping if I posted some code some others will too. It actually turned out to be a lot easier then it sounded at first. Algebra win.

Sucks to hear about your neck problem
    
CPUMotherboardGraphicsRAM
Q6600 DG33TL XFX 6950 2GB 4gigs Corsair XMS2 DDR2 
Hard DriveOptical DriveOSMonitor
1.5TB seagate 2X640GB Samsung DVDRW Windows Vista & Debian Linux Samsung 19" + Acer 24" Wide 
KeyboardPowerCaseMouse
Microsoft SideWinder X6 Antec 750 TruePower Raidmax Smilodon COOLER MASTER Sentinel 
Mouse Pad
RocketFish 
  hide details  
    
CPUMotherboardGraphicsRAM
Q6600 DG33TL XFX 6950 2GB 4gigs Corsair XMS2 DDR2 
Hard DriveOptical DriveOSMonitor
1.5TB seagate 2X640GB Samsung DVDRW Windows Vista & Debian Linux Samsung 19" + Acer 24" Wide 
KeyboardPowerCaseMouse
Microsoft SideWinder X6 Antec 750 TruePower Raidmax Smilodon COOLER MASTER Sentinel 
Mouse Pad
RocketFish 
  hide details  
post #166 of 306
Quote:
Originally Posted by Midpipps View Post
LOL yeah was hoping if I posted some code some others will too. It actually turned out to be a lot easier then it sounded at first. Algebra win.

Sucks to hear about your neck problem
Dude I just woke up with it one day. It's called Occipital Neuralgia. I did get to work from home today though
post #167 of 306
Another Wednesday Another program. Really hope more people start this up again. This is another one from the MICS competition last year.

Quote:
Perrin Numbers

Description:
The Perrin sequence {A(0), A(1), A(2), …} is defined as follows:

A(0) = 3
A(1) = 0
A(2) = 2
For i >= 3, A(i) = A(i-2) + A(i-3)

This sequence has the following interesting property – if P is a prime number, then P evenly divides A(P).

Problem:
Write a program that verifies the above property of the Perrin numbers for the first 30 primes and their related Perrin numbers. The output should be a list of the first k primes, P(1), …, P(k), their associated Perrin numbers (A(P(1)), …, A(P(k))), and confirmation that P(k) divides A(P(k)) by generating the output of A(P(k)) modulus P(k).

Technical Data:
This is a timed problem. Any program that takes longer than two real-time minutes to complete will be rejected on time.

Sample Input:
None – k value is hardcoded.

Sample Output: (assuming k=5; again, your program should use k = 30)
P(1) = 2; A(P(1)) = 2; 2 modulus 2 => 0
P(2) = 3; A(P(2)) = 3; 3 modulus 3 => 0
P(3) = 5; A(P(3)) = 5; 5 modulus 5 => 0
P(4) = 7; A(P(4)) = 7; 7 modulus 7 => 0
P(5) = 11; A(P(5)) = 22; 22 modulus 11 => 0
    
CPUMotherboardGraphicsRAM
Q6600 DG33TL XFX 6950 2GB 4gigs Corsair XMS2 DDR2 
Hard DriveOptical DriveOSMonitor
1.5TB seagate 2X640GB Samsung DVDRW Windows Vista & Debian Linux Samsung 19" + Acer 24" Wide 
KeyboardPowerCaseMouse
Microsoft SideWinder X6 Antec 750 TruePower Raidmax Smilodon COOLER MASTER Sentinel 
Mouse Pad
RocketFish 
  hide details  
    
CPUMotherboardGraphicsRAM
Q6600 DG33TL XFX 6950 2GB 4gigs Corsair XMS2 DDR2 
Hard DriveOptical DriveOSMonitor
1.5TB seagate 2X640GB Samsung DVDRW Windows Vista & Debian Linux Samsung 19" + Acer 24" Wide 
KeyboardPowerCaseMouse
Microsoft SideWinder X6 Antec 750 TruePower Raidmax Smilodon COOLER MASTER Sentinel 
Mouse Pad
RocketFish 
  hide details  
post #168 of 306
Quote:
Originally Posted by Midpipps View Post
Another Wednesday Another program. Really hope more people start this up again. This is another one from the MICS competition last year.
This one is interesting enough that I think I'll set aside some time tonight to give it a go. The question is, what language to use?
post #169 of 306
LISP or how about AJAX I know your company loves or used to love that
    
CPUMotherboardGraphicsRAM
Q6600 DG33TL XFX 6950 2GB 4gigs Corsair XMS2 DDR2 
Hard DriveOptical DriveOSMonitor
1.5TB seagate 2X640GB Samsung DVDRW Windows Vista & Debian Linux Samsung 19" + Acer 24" Wide 
KeyboardPowerCaseMouse
Microsoft SideWinder X6 Antec 750 TruePower Raidmax Smilodon COOLER MASTER Sentinel 
Mouse Pad
RocketFish 
  hide details  
    
CPUMotherboardGraphicsRAM
Q6600 DG33TL XFX 6950 2GB 4gigs Corsair XMS2 DDR2 
Hard DriveOptical DriveOSMonitor
1.5TB seagate 2X640GB Samsung DVDRW Windows Vista & Debian Linux Samsung 19" + Acer 24" Wide 
KeyboardPowerCaseMouse
Microsoft SideWinder X6 Antec 750 TruePower Raidmax Smilodon COOLER MASTER Sentinel 
Mouse Pad
RocketFish 
  hide details  
post #170 of 306
Quote:
Originally Posted by Midpipps View Post
LISP or how about AJAX I know your company loves or used to love that
Old job used AJAX in the most annoying places. New job we use it but I don't deal with the web stuff anymore. I write the core code and API that our web interface relies on.

LISP eh? I could give it a go...
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
This thread is locked  
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Programming Challenge (Out-of-Date)