Skip to content

Instantly share code, notes, and snippets.

@stphung
Created April 12, 2011 04:18
Show Gist options
  • Save stphung/914918 to your computer and use it in GitHub Desktop.
Save stphung/914918 to your computer and use it in GitHub Desktop.
My solution to "Your Ride Is Here" from USACO
/*
ID: stphung1
LANG: JAVA
TASK: ride
*/
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
class ride {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(new File("ride.in"));
PrintWriter pw = new PrintWriter(new File("ride.out"));
if (toNumber(sc.nextLine()) % 47 == toNumber(sc.nextLine()) % 47) {
pw.println("GO");
} else {
pw.println("STAY");
}
pw.close();
}
public static int toNumber(String name) {
int product = 1;
for (int i = 0; i < name.length(); i++) {
int charVal = (name.charAt(i) - 'A') + 1;
product *= charVal;
}
return product;
}
}
@osly888
Copy link

osly888 commented Feb 18, 2019

thanks so much for showing me the way to successfully turn in my java code. love ya man no homo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment