UVA – 458 – The Decoder

  • ID : UVA – 458 – The Decoder
  • Submissions :
    • Java – Accepted
  • Difficulty : Shame to Solve
  • Type : String Manipulation
  • Time for Submission : 2 Hours
  • Solution Description :
    • The constant cipher is -7, for each character output it’s 7th precedent & avoid ‘\n’ & ‘\r’.
  • Problems :
    • Wierd 1 Line problem :S 25 Submission to Accept :S I was using scanner.nextLine() then the STd in  nothing worked :S
    • When I used DataInputStream & outPut it worked. i believe it has something to do with the ASCII & Unicode conversions but I can;t figure it out now.

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

public class Main {
	public static void main(String[] args) throws IOException {
		DataInputStream in = new DataInputStream(System.in);
		DataOutputStream output = new DataOutputStream(System.out) ;
		int C;
		while ((C =in.read()) !=-1)
			output.write((Character.isSpace((char)C) ? C : (C-7)));
	}
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: