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 30  

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 #291 of 306
Quote:
Originally Posted by MakubeX View Post
As long as it's ok with your employer.
Haha, apparently they didn't mind since I have a job .
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
Core i7 970 B1 EVGA X58 SLI (E758) Gigabyte GTX 970 Gaming Crucial Ballistix Tactical 12GB 
Hard DriveOSMonitorKeyboard
Intel X25-M 80GB, WD Caviar Black 1TB, WD CG 2TB Windows 7 x64 Ultimate Asus 24", ViewSonic 22" Saitek Cyborg 
PowerCaseMouseMouse Pad
CORSAIR TX850 HAF 932 Logitech G500 OCZ Behemoth 
  hide details  
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
Core i7 970 B1 EVGA X58 SLI (E758) Gigabyte GTX 970 Gaming Crucial Ballistix Tactical 12GB 
Hard DriveOSMonitorKeyboard
Intel X25-M 80GB, WD Caviar Black 1TB, WD CG 2TB Windows 7 x64 Ultimate Asus 24", ViewSonic 22" Saitek Cyborg 
PowerCaseMouseMouse Pad
CORSAIR TX850 HAF 932 Logitech G500 OCZ Behemoth 
  hide details  
post #292 of 306
finally got around to doing the exclusion sort challenge. here's my solution in java. i only coded it to work for 1 case at a time though.
Code:
import java.util.*;

public class exclusionSort {

public static int sort(ArrayList<Integer> array){
int total_deletes = 0;
int num_deletes = -1;
while(num_deletes != 0){
num_deletes = 0;
for(int i=0; i<array.size()-1; i++){
if(array.get(i)>array.get(i+1)){
num_deletes++;
total_deletes++;
array.remove(i);
}
}
}
return total_deletes;
}

public static void main( String args[] ) {
int length = 0;
ArrayList<Integer> array = new ArrayList<Integer>();
try{
length = Integer.parseInt(args[0]);
}
catch(Exception e){
System.err.println("First argument must be an integer!");
}
for(int i=1; i<=length; i++){
array.add(Character.getNumericValue(args[i].charAt(0)));
}
int num_deletes = sort(array);
System.out.println("You only need to remove " + num_deletes + " word(s)!");
}
}
@austinb324, i will be attempting your challenge tomorrow. pretty sure i did a ascii/hex converter in assembly language last fall. now i just have to find that code lol.
Fractal Design
(15 items)
 
775 4 life
(15 items)
 
 
CPUMotherboardGraphicsRAM
Intel i7 2600K Biostar TP67XE NVidia GTX 570 Crucial Ballistix 
Hard DriveHard DriveCoolingOS
Crucial C300 RealSSD SDD Samsung F4 2TB Noctua NH-D14 Windows 7 Professional x64 
MonitorMonitorKeyboardPower
Asus VH202T 20'' 1600x900 Acer P244W 24" 1920 x 1080 Apple Keyboard with Numeric Keypad SeaSonic M12II 620W 
CaseMouseAudio
Fractal Design Define XL Titanium Grey Razor Abyssus Creative Sound Blaster X-FI Xtreme Gamer 
CPUMotherboardGraphicsRAM
Intel X3350 3.2Ghz @ 1.25v Gigabyte-GA-P35-DS3L (rev 2) XFX 4870 1GB 4GB OCZ Reaper PC2-6400 
RAMHard DriveHard DriveOptical Drive
2GB Corsair XMS2 PC2-6400 Crucial C300 64GB SSD 2TB Samsung Spinpoint F4 Sony Super Multi 
OSMonitorPowerCase
Windows 7 Professional x64 SP1 Asus VH202T 20'' 1600x900 SeaSonic M12II 620W Cooler Master Centurion 5 
Mouse
Razor Abyssus 
CPUMotherboardGraphicsRAM
Core i5-520M Lenovo 2522BF3 NVIDIA® Quadro® NVS3100M  Ramaxel Technology 4Gb DDR3 
Hard DriveOptical DriveOSMonitor
Samsung SSD 128GB 1.8" Micro SATA  hl-dt-st dvdram gu10n Windows 7 Enterprise (64-bit) 14.1" WXGA (1280x800) display, anti-glare, LED ... 
Power
9-cell plus Slice battery 
  hide details  
Fractal Design
(15 items)
 
775 4 life
(15 items)
 
 
CPUMotherboardGraphicsRAM
Intel i7 2600K Biostar TP67XE NVidia GTX 570 Crucial Ballistix 
Hard DriveHard DriveCoolingOS
Crucial C300 RealSSD SDD Samsung F4 2TB Noctua NH-D14 Windows 7 Professional x64 
MonitorMonitorKeyboardPower
Asus VH202T 20'' 1600x900 Acer P244W 24" 1920 x 1080 Apple Keyboard with Numeric Keypad SeaSonic M12II 620W 
CaseMouseAudio
Fractal Design Define XL Titanium Grey Razor Abyssus Creative Sound Blaster X-FI Xtreme Gamer 
CPUMotherboardGraphicsRAM
Intel X3350 3.2Ghz @ 1.25v Gigabyte-GA-P35-DS3L (rev 2) XFX 4870 1GB 4GB OCZ Reaper PC2-6400 
RAMHard DriveHard DriveOptical Drive
2GB Corsair XMS2 PC2-6400 Crucial C300 64GB SSD 2TB Samsung Spinpoint F4 Sony Super Multi 
OSMonitorPowerCase
Windows 7 Professional x64 SP1 Asus VH202T 20'' 1600x900 SeaSonic M12II 620W Cooler Master Centurion 5 
Mouse
Razor Abyssus 
CPUMotherboardGraphicsRAM
Core i5-520M Lenovo 2522BF3 NVIDIA® Quadro® NVS3100M  Ramaxel Technology 4Gb DDR3 
Hard DriveOptical DriveOSMonitor
Samsung SSD 128GB 1.8" Micro SATA  hl-dt-st dvdram gu10n Windows 7 Enterprise (64-bit) 14.1" WXGA (1280x800) display, anti-glare, LED ... 
Power
9-cell plus Slice battery 
  hide details  
post #293 of 306
C++(without comments) I have one without comments b/c it is much easier to read the code this way(for me anyways).
Code:

#include <iostream>
#include <fstream>
#include <string>
#include <conio.h>     
#include <vector>
#include <sstream>
#define ENTER 13

using namespace std;

void readFile(vector<string> &charV);    
void displayTable(const vector<char> input, const vector<string> charSet, 
                  const int numChars, const bool isASCII);     

int main()
{
    vector<string> charSet;  
    vector<char> input;      
    char tempInput;          
    int numChars = 0;       
    int x, i;              
    
    readFile(charSet);      
    
    cout << "Begin your input: " << endl;
    do      
    {
         tempInput = getch();        
         if((tempInput >= 48 && tempInput <= 57)||(tempInput >= 65 && 
             tempInput <= 90)||(tempInput >= 97 && tempInput <= 122)||
             tempInput == 32||tempInput == 33||tempInput == 44||
             tempInput == 46||tempInput == 63||tempInput == 59)    
         {                                                                                                             
              input.push_back(tempInput);  
              cout << input.at(numChars);  
              numChars++;                 
         }
         else if(tempInput == 8 && numChars > 0)    
         {
              numChars--;     
              input.pop_back();   
              system("cls");      
              
              cout << "Begin your input: " << endl;      
              for(x=0; x<numChars; x++)    
              {
                   cout << input.at(x);
              }    
         }
    }
    while(tempInput != ENTER);
    
    displayTable(input, charSet, numChars, true);    
    displayTable(input, charSet, numChars, false); 
    
    cout << endl << endl;
    system("PAUSE");
    return 0;
}

void displayTable(const vector<char> input, const vector<string> charSet, 
                  const int numChars, const bool isASCII) 
{
     int i, x;   
     string tempString;  
     if(isASCII)     
          cout << "\
\
ADDR  00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F   ASCII" << endl;
     else
          cout << "\
\
\
ADDR  00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F   EBCDIC" << endl;
    
    i = 0;
    while(i < numChars)        
    {
         cout << endl;
         cout.width(4);   
         cout.fill('0');  
         cout << hex << i << ": ";   
         
         for(x=0; x < 16; x++)  
         {
              if((x+i) < numChars)  
              {   
                   if(isASCII)      
                        cout << hex << (int)input[i+x] << " ";  
                   else
                   {
                        for(int j=0; j<charSet.size(); j++) 
                        {                                   
                                                            
                             
                             stringstream ss;   
                                                
                             ss << input[i+x];  
                             ss >> tempString;  
                             if((int)input[i+x] == 32)
                             {     
                                  cout << "40 ";   
                                  break;           
                             }
                             else if((charSet.at(j).compare(tempString)== 0)&&((int)input[i+x] != 32))
                                  cout << hex << j << " ";        
                        }    
                   }  
              }      
              else
                   cout << "   "; 
         }
           
         cout << "\"; 
         
         for(x=0; x < 16 && x < numChars; x++)
         {
              if((x+i) < numChars)
                   cout << input[i+x];
              else
                   cout << " ";       
         } 
         i+=x; 
    }        
}

void readFile(vector<string> &charV)
{
     ifstream infile;  
     string tempChar;  
     infile.open("EBCDIC.txt" , ifstream::in);
     while (infile.good())
     {
          getline(infile, tempChar);   
          charV.push_back(tempChar);   
     }
     
     infile.close();   
}


C++(with comments)
Code:
#include <iostream>
#include <fstream>
#include <string>
#include <conio.h>       //Library that allows for unbuffered input from the keyboard
#include <vector>
#include <sstream>
#define ENTER 13

using namespace std;

void readFile(vector<string> &charV);     //function for reading file with the EBCDIC characters in it 
void displayTable(const vector<char> input, const vector<string> charSet, const int numChars, const bool isASCII);     //prints the char table in either ASCII or EBCDIC

int main()
{
    vector<string> charSet;  //vector where the EBCDIC char set is stored
    
    vector<char> input;      //vector where the keyboard is stored
    char tempInput;          //variable used for input validation
    int numChars = 0;        //counter to keep track of the number of characters entered
    int x, i;                //loop counters
    
    readFile(charSet);       //function call to read in the EBCDIC file
    
    cout << "Begin your input: " << endl;
    do      //main loop for keyboard input
    {
         tempInput = getch();        //function call from conio.h that detects keyboard event and takes the character off of the input buffer
         if((tempInput >= 48 && tempInput <= 57)||(tempInput >= 65 && tempInput <= 90)||(tempInput >= 97 && tempInput <= 122)||
             tempInput == 32||tempInput == 33||tempInput == 44||tempInput == 46||tempInput == 63||tempInput == 59)    //input validation that restricts the 
                                                                                                                      // possible input characters to the challenge requirements
         {
              input.push_back(tempInput);  //if the char passes validation, it gets pushed onto the storage vector
              cout << input.at(numChars);  //if the char passes validation, it gets displayed on the screen
              numChars++;                  //number of entered chars gets incremented
         }
         else if(tempInput == 8 && numChars > 0)    //if the entered char fails first validation, it is then tested to see if it is the backspace char
         {
              numChars--;     //number of chars is devcremented
              input.pop_back();   //the last entered char is popped out of the storage vector
              system("cls");      //the screen is cleared
              
              //The next 5 lines recreate the screen as if it had never been cleared except the last char is removed
              cout << "Begin your input: " << endl;      
              for(x=0; x<numChars; x++)    //loop to reprint all characters
              {
                   cout << input.at(x);
              }    
         }
    }
    while(tempInput != ENTER);
    
    displayTable(input, charSet, numChars, true);    //funciton call to create the Hex/ASCII table
    displayTable(input, charSet, numChars, false);   //funciton call to create the Hex/EBCDIC table
    
    cout << endl << endl;
    system("PAUSE");
    return 0;
}

void displayTable(const vector<char> input, const vector<string> charSet, const int numChars, const bool isASCII) //note - const used to be sure none of the variables values 
                                                                                                                  // are changed as this could cause problems
{
     int i, x;    //loop counters
     string tempString;  //temp variable used when converting input vector values from char to string for comparison
     if(isASCII)     //determines which char table heading will be printed
          cout << "\
\
ADDR  00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F   ASCII" << endl;
     else
          cout << "\
\
\
ADDR  00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F   EBCDIC" << endl;
    
    i = 0;
    while(i < numChars)        //main print loop. Programmaticaly prints each line of the table
    {
         cout << endl;
         cout.width(4);   //sets width of left hand side line number to 4 as to emulate the challenge specification
         cout.fill('0');  //sets the empty space to be filled with the char 0. ie: 20 would be printed as 0020
         cout << hex << i << ": ";   //prints the position in the table of the first element in the current line. Each line has 16 elements.
         
         for(x=0; x < 16; x++)  //loop that will print one line of the left side of the table
         {
              if((x+i) < numChars)  //conditional statement that checks to see if you have reached the last item to be printed in the table. If so, 
                                    // line 106 prints blank spaces for each time this happens (up to 15 times)
              {   
                   if(isASCII)      //conditional statement to check to see which version of the table is supposed to be printed
                        cout << hex << (int)input[i+x] << " ";  //prints the integer value that is associated with each char(ASCII) in hexidecimal notation
                   else
                   {
                        for(int j=0; j<charSet.size(); j++) //loop that for each char, it will search for it in the vector where the EBCDIC values are stored.
                        {                                   // Upon finding it in the vector, the hexidecimal notaion of the position where it was found in the vector 
                                                            // is printed out. 
                             
                             stringstream ss;   //creation of string stream variable to handle conversion from char to string. This must be done since the 
                                                // input vector is in char form where the EBCDIC vector is in string form           
                                                
                             ss << input[i+x];  //insertion of the current position of the input vector into the string stream variable
                             ss >> tempString;  //extraction of the value in string format
                             if((int)input[i+x] == 32) //test to see if the current char is a space. This was a cheap fix to handle an error the next statement 
                                                       // was having of not being able to match the space char
                             {     
                                  cout << "40 ";   //Prints the EBCDIC hex value for space
                                  break;           //stops loop from continueing. Breaks to the nearest outer loop.
                             }
                             else if((charSet.at(j).compare(tempString)== 0)&&((int)input[i+x] != 32)) //if the tempString value matches the current EBCDIC value then 
                                                                                                       // the loop counter will be equivalent to the char's EBCDIC value.
                                  cout << hex << j << " ";        
                        }    
                   }  
              }      
              else
                   cout << "   "; //comments on line 84
         }
           
         cout << "\"; //Puts some space between the Hex side of the table and the char side of the table
         
         for(x=0; x < 16 && x < numChars; x++) //Prints all of the input characters in lines of 16 until the last char is reached, then it prints blank space
         {
              if((x+i) < numChars)
                   cout << input[i+x];
              else
                   cout << " ";       
         } 
         i+=x;  //outer while loop is incremented this way so that it only runs as many times as there is line to print     
    }        
}

void readFile(vector<string> &charV)  //note - vector variable passed by reference
{
     ifstream infile;  //create input file stream variable
     string tempChar;  //temp variable to store fileinput before it is pushed onto the vector
     infile.open("EBCDIC.txt" , ifstream::in);  //open the file in readonly mode
     while (infile.good())   //loop that runs until the end of file is reached or there is an error
     {
          getline(infile, tempChar);     //reads one line from file and stores it in the temp variable
          charV.push_back(tempChar);     //pushes value in the temp variable onto the vector
     }
     
     infile.close();     //closes input file
}
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
Core i7 970 B1 EVGA X58 SLI (E758) Gigabyte GTX 970 Gaming Crucial Ballistix Tactical 12GB 
Hard DriveOSMonitorKeyboard
Intel X25-M 80GB, WD Caviar Black 1TB, WD CG 2TB Windows 7 x64 Ultimate Asus 24", ViewSonic 22" Saitek Cyborg 
PowerCaseMouseMouse Pad
CORSAIR TX850 HAF 932 Logitech G500 OCZ Behemoth 
  hide details  
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
Core i7 970 B1 EVGA X58 SLI (E758) Gigabyte GTX 970 Gaming Crucial Ballistix Tactical 12GB 
Hard DriveOSMonitorKeyboard
Intel X25-M 80GB, WD Caviar Black 1TB, WD CG 2TB Windows 7 x64 Ultimate Asus 24", ViewSonic 22" Saitek Cyborg 
PowerCaseMouseMouse Pad
CORSAIR TX850 HAF 932 Logitech G500 OCZ Behemoth 
  hide details  
post #294 of 306
Here it is in scala. I can't filter the input from java, unless I made a gui or used something like JLine(which is essentially a wrapper around a terminal), which I looked at, but it's got different code for windows and linux. It'd be easier to write it in another language.

Another option was doing something like this. It just seemed like a hack.


Code:
package ebcdic
import java.nio.charset.Charset


object PuzzleReadline {

  val valid = (('a' to 'z') ++ ('A' to 'Z') ++ ('0' to '9') ++ List(' ', '?', '.','!' , ':')).toSet
  val charSet = Charset.forName("cp500")
  
  def process()
  {
  val s = Console.readLine().filter(valid.contains(_))
  val hexValues = s.toList.map{c:Char =>Integer.toHexString(c.intValue) }
  
  val ebc = charSet.encode(s).array
  
  val ebcHex = ebc.map{ b:Byte => Integer.toHexString(b.toInt & 0xff)}
  
  println("Original:\ " + s.mkString("  |"))
  println("Hex:\\ " + hexValues.mkString(" |"))
  println("EBC Hex:\ " + ebcHex.mkString(" |"))
  }
    
  def main(args: Array[String])
  {
   process()
 
  }
}
post #295 of 306
Easy to do in Cocoa by creating a new subclass of NSTextField.
edit: wow easy, this guy's done most of the work already. http://blog.gruby.com/2008/03/29/nst...-capabilities/

just add a popup window for the info that needs to be displayed, hidden until an IBAction is triggered to show it.
Ground work done, just need to add fields for ascii/hex to display in the window when triggered, and also a subroutine to convert from ascii to whatever.

edit: woo that's awesome, can't attach zip file
http://www.mediafire.com/file/s3o7d7n9vvaf0iv/PC1.zip
Edited by S0ULphIRE - 7/5/11 at 10:18pm
Blitzkrieg
(14 items)
 
  
CPUMotherboardGraphicsRAM
i7 980X Asus P6X58D Premium GTX 680 G.Skill 6Gb 2000Mhz 
Hard DriveOptical DriveCoolingOS
OCZ Vertex 3 BD/DVD Combo EK Supreme HF Windows 7 
MonitorKeyboardPowerCase
SAMSUNG S27A850T 27" Microsoft basic 600 :p AeroCool V12 1000W HAF 932 
Mouse
Razer Deathadder V2 
  hide details  
Blitzkrieg
(14 items)
 
  
CPUMotherboardGraphicsRAM
i7 980X Asus P6X58D Premium GTX 680 G.Skill 6Gb 2000Mhz 
Hard DriveOptical DriveCoolingOS
OCZ Vertex 3 BD/DVD Combo EK Supreme HF Windows 7 
MonitorKeyboardPowerCase
SAMSUNG S27A850T 27" Microsoft basic 600 :p AeroCool V12 1000W HAF 932 
Mouse
Razer Deathadder V2 
  hide details  
post #296 of 306
i would like to see another challenge.
Pepe Silvia
(13 items)
 
  
CPUMotherboardGraphicsRAM
255 @ 4 Ghz MSI 870-C45 GT 520 @ 1Ghz Crucial Rendition 4GB DDR3 
Hard DriveOSMonitorPower
Hitachi 1TB Win 7 19" 420W 
  hide details  
Pepe Silvia
(13 items)
 
  
CPUMotherboardGraphicsRAM
255 @ 4 Ghz MSI 870-C45 GT 520 @ 1Ghz Crucial Rendition 4GB DDR3 
Hard DriveOSMonitorPower
Hitachi 1TB Win 7 19" 420W 
  hide details  
post #297 of 306
Well here you go then

Quote:
Problem 7 — Postage Stamps

Professor Smith loves to travel around the United States during her summer break. She often writes long letters to her children detailing her adventures. Since a post office is not always handy, she buys large quantities of various stamp denominations and prints a current postal chart before she starts her travels. She carries a digital postage scale to weigh the letters so she can use exact postage to the penny. Being a bit eccentric, she always uses the fewest number of stamps possible using the stamp denominations she has previously purchased. She always buys 1-cent stamps to ensure exact postage, and enough stamps of each denomination so she never runs out of any denomination of stamps.

INPUT SPECIFICATION: You will be given a set of stamp denominations followed by several postage amounts. The first line begins with a single unsigned decimal (representing the number of stamp denominations) followed by <EOLN>. The second line contains that many unsigned decimal integers (representing the stamp denominations) separated by one space and followed by <EOLN>. The stamp denominations are sorted in ascending order and always start with 1 to ensure exact postage. The remaining lines each contain a single unsigned decimal integer (representing a postage amount) and followed by<EOLN>. The last input case will be followed by “0<EOLN>â€.

OUTPUT SPECIFICATION: The output cases should appear in the same order as the input cases. Each output case will be of the form “Case c: The postage amount p can be made using s stamp(s).†(where c is the number of the input case, p is the postage amount, and s is the FEWEST number of stamps necessary to arrive at the postage amount) followed by <EOLN>.

SAMPLE INPUT:
6<EOLN>
1•5•10•12•25•50<EOLN>
18<EOLN>
120<EOLN>
79<EOLN>
0<EOLN>
<EOF>

SAMPLE OUTPUT:
Case•1:•The•postage•amount•18•can•be •made•using•3•stamp(s).<EOLN>
Case•2:•The•postage•amount•120•can•b e•made•using•4•stamp(s).<EOLN>
Case•3:•The•postage•amount•79•can•be •made•using•4•stamp(s).<EOLN>
<EOF>
and some inputs
Quote:
6
1 5 10 12 25 50
18
120
79
214
13
0
and their outputs
Quote:
Case 1: The postage amount 18 can be made using 3 stamp(s).
Case 2: The postage amount 120 can be made using 4 stamp(s).
Case 3: The postage amount 79 can be made using 4 stamp(s).
Case 4: The postage amount 214 can be made using 7 stamp(s).
Case 5: The postage amount 13 can be made using 2 stamp(s).
    
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 #298 of 306
Dynamic programming ftw
 
Mineral Oil PC
(7 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core i7 4790K Devil's Canyon 4.0GHz ASUS Sabertooth Z97 Mark S (White) Zotac GTX 760 Avexir Raiden 16GB DDR3 
Hard DriveCoolingCoolingCooling
OCZ Trion 240GB XSPC Raystorm Pro (white) XSPC EX 240 (white) XSPC EX 360 (white) 
CoolingCoolingCoolingCooling
Swiftech MCP655 Monsoon Dual Bay Reservoir Monsoon Modular Tube Reservoir Monsoon Stand Alone Pump Top/Cover 
CoolingPower
EK GTX 970 Water Block Corsair AX760i 
CPUMotherboardGraphicsGraphics
Intel Core i7 2600K Sandy Bridge 3.4 GHz Gigabyte GA-P67A-UD4-B3 GTX 285 GTX 285 
RAMHard DriveHard DriveCooling
Corsair Vengeance 16GB Western Digital 1TB Western Digital 250GB EK-Supremacy Clean CSQ - Nickel 
CoolingCoolingCoolingCooling
XSPC RX 360 XSPC EX 360 (cross flow) FrozenQ T-virus Reservoir EK Waterblock GTX 285 
Cooling
Swiftech MCP655 
  hide details  
 
Mineral Oil PC
(7 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core i7 4790K Devil's Canyon 4.0GHz ASUS Sabertooth Z97 Mark S (White) Zotac GTX 760 Avexir Raiden 16GB DDR3 
Hard DriveCoolingCoolingCooling
OCZ Trion 240GB XSPC Raystorm Pro (white) XSPC EX 240 (white) XSPC EX 360 (white) 
CoolingCoolingCoolingCooling
Swiftech MCP655 Monsoon Dual Bay Reservoir Monsoon Modular Tube Reservoir Monsoon Stand Alone Pump Top/Cover 
CoolingPower
EK GTX 970 Water Block Corsair AX760i 
CPUMotherboardGraphicsGraphics
Intel Core i7 2600K Sandy Bridge 3.4 GHz Gigabyte GA-P67A-UD4-B3 GTX 285 GTX 285 
RAMHard DriveHard DriveCooling
Corsair Vengeance 16GB Western Digital 1TB Western Digital 250GB EK-Supremacy Clean CSQ - Nickel 
CoolingCoolingCoolingCooling
XSPC RX 360 XSPC EX 360 (cross flow) FrozenQ T-virus Reservoir EK Waterblock GTX 285 
Cooling
Swiftech MCP655 
  hide details  
post #299 of 306
Damn it, more challenges keep coming but my free time keeps getting shorter.
post #300 of 306
Still learning Java how's this?
edit: hmmm logic errors in stamp calculation still...derp dynamic programming was even mentioned already. facepalm.jpg
Code:
public class StampCalc {

    public static void main(String[] args) {
        Scanner kb = new Scanner(in);Scanner intkb = new Scanner(in);
        int i=0, count=0, u=0;
        out.print("Input available number of stamp denominations: ");
        int start = kb.nextInt();
        kb.nextLine();
        u = start - 1;
        out.print("Input stamp values serparated by spaces: ");
        String temp = kb.nextLine();
        int[] stampArray = new int[start]; 
        int[] amountArray;
        StringTokenizer sA = new StringTokenizer(temp);
        while (sA.hasMoreTokens())
        {
            stampArray[i] = Integer.parseInt(sA.nextToken());
            i++;
        }
        Arrays.sort(stampArray);
        ArrayList stampAmount = new ArrayList();
        out.print("Input postage amount, or enter 0 to finish: ");
        for( ; ; )
        {
            int chk = intkb.nextInt();
            if (chk == 0){
                amountArray = new int[stampAmount.size()];
                for (int p=0; p<stampAmount.size(); p++) amountArray[p] = (int)stampAmount.get(p);
                break;
            }
            stampAmount.add(chk);
            out.print("Next?: ");
        } 
        for(int z = 0; z < amountArray.length; z++){
            int totalAmount = amountArray[z];
            while (amountArray[z] != 0){
                if (amountArray[z] >= stampArray[u]){
                    amountArray[z] = amountArray[z] - stampArray[u];
                    count++;
                }
                else u--;
            }
            out.print("Case ");out.print(z);out.print(": The postage amount ");out.print(totalAmount);out.print(" can be made using ");out.print(count);out.println(" stamps");
            u = start-1; count=0;
        }
    }
}

Edited by S0ULphIRE - 7/17/11 at 11:30pm
Blitzkrieg
(14 items)
 
  
CPUMotherboardGraphicsRAM
i7 980X Asus P6X58D Premium GTX 680 G.Skill 6Gb 2000Mhz 
Hard DriveOptical DriveCoolingOS
OCZ Vertex 3 BD/DVD Combo EK Supreme HF Windows 7 
MonitorKeyboardPowerCase
SAMSUNG S27A850T 27" Microsoft basic 600 :p AeroCool V12 1000W HAF 932 
Mouse
Razer Deathadder V2 
  hide details  
Blitzkrieg
(14 items)
 
  
CPUMotherboardGraphicsRAM
i7 980X Asus P6X58D Premium GTX 680 G.Skill 6Gb 2000Mhz 
Hard DriveOptical DriveCoolingOS
OCZ Vertex 3 BD/DVD Combo EK Supreme HF Windows 7 
MonitorKeyboardPowerCase
SAMSUNG S27A850T 27" Microsoft basic 600 :p AeroCool V12 1000W HAF 932 
Mouse
Razer Deathadder V2 
  hide details  
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)