Skip to content

Instantly share code, notes, and snippets.

View Staticity's full-sized avatar

Jaime Rivera Staticity

View GitHub Profile
public static boolean isPalindrome(String str) {
if (str == null || str.charAt(0) != str.charAt(str.length() - 1)) {
return false;
} else if (str.length() <= 1) {
return true;
} else {
return isPalindrome(str.substring(1, str.length() - 1));
}
}
@Staticity
Staticity / main.java
Last active December 20, 2015 05:19
"My First Program", by Jaime Rivera
import java.util.Scanner;
public class main {
public static void main(String args[]){
boolean running = true;
while(running){
try{
@Staticity
Staticity / potd1.java
Last active December 20, 2015 12:09
3n + 1
import java.io.*;
import java.util.*;
import java.lang.Math;
class Main {
private static int[] count_cache = new int[100000];
public static void main(String args[]) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
@Staticity
Staticity / potd2.java
Created August 2, 2013 08:00
Digit Counting
import java.io.*;
class Main {
public static void main(String args[]) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = null;
while ((line = br.readLine()) != null) {
int n = Integer.parseInt(line);
int[] counts = count(1, n);
public static boolean isPangram(String s) {
if (s == null || s.length() < 26) {
return false;
}
int[] counts = new int[26];
for (char c : s) {
if (Character.isletter(c) {
counts[c - 'a']++;
}
@Staticity
Staticity / potd3.java
Last active December 20, 2015 14:19
Problem G
import java.io.*;
import java.util.*;
import java.lang.Math;
class Main {
public static void main(String args[]) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int cases = Integer.parseInt(br.readLine());
while (cases-- > 0) {
@Staticity
Staticity / CatchEmAll.java
Last active January 4, 2021 01:14
"Gotta Catch 'Em All!" Exception in thread "main" Pokemon: Gotta Catch 'Em All! at Main.main(11069.java:10)
class Pokemon extends Exception {
public Pokemon(String message) {
super(message);
}
}
class Main {
public static void main(String args[]) throws Exception {
throw new Pokemon("Gotta Catch 'Em All!");
}
@Staticity
Staticity / Expression Calculator
Last active December 20, 2015 15:09
potd4.txt
Problem:
You are given a list of tokens which represent a mathematical expression.
Write an algorithm that will determine the value of a given mathematical expression.
Input:
You are given an integer n (1 <= n <= 100000), which represents the number of expressions
following. Each expression will be on a line of tokens separated by spaces.
@Staticity
Staticity / potd4.java
Created August 4, 2013 23:57
Expression Calculator
import java.io.*;
import java.util.*;
class Main {
public static void main(String args[]) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = br.readLine();
int n = Integer.parseInt(line);
while (n-- > 0) {
@Staticity
Staticity / Bag.java
Last active December 20, 2015 15:18
Bag
import java.util.ArrayList;
class Bag {
private ArrayList<Integer> bag;
private int size;
public Bag() {
this.bag = new ArrayList<Integer>();
this.size = 0;