Skip to content

Instantly share code, notes, and snippets.

View palmerabollo's full-sized avatar

Guido García palmerabollo

View GitHub Profile
@palmerabollo
palmerabollo / CrazyCroupier.java
Created May 6, 2012 18:01
Crazy Croupier - 2nd Tuenti Challenge - 12
import java.math.BigInteger;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
/**
* Crazy Croupier - 2nd Tuenti Challenge - 12
*
@palmerabollo
palmerabollo / gist:5104187
Created March 6, 2013 23:24
Magical Java Puzzle: “Pat The Unicorns”
import java.io.PrintStream;
public class MagicalLand {
public static void main(String[] args) {
for (int i = 0; i < (Math.random() * 500) + 2; i++) {
if (Unicorn.pat()) {
System.out.println("UNICORN #1: PAT THIS UNICORN ONCE");
}
}
@palmerabollo
palmerabollo / Python #1
Last active December 19, 2015 00:49
Python #1
import unittest
def IsOdd(n):
return n % 2 == 1
class IsOddTests(unittest.TestCase):
def testOne(self):
self.failUnless(IsOdd(1))
def testTwo(self):
for n in range(2, 1000):
for x in range(2, n):
if n % x == 0:
print n, 'equals', x, '*', n/x
break
else:
print n, ' true'
public String apply(String input) {
char[] chars = input.toCharArray();
int index;
for (index = 0; index < input.length(); index++) {
if (chars[index] != '0') {
break;
}
}
return (index == 0) ? input : input.substring(index);
Map<String, String> map = new HashMap<String, String>();
map.put("1","abc");
map.put("2", "def");
for (Map.Entry<String, String> entry : map.entrySet()) {
System.out.println(entry.getValue() + ":" + entry.getKey());
}
CLIENTES
========
id: INT
nombre: VARCHAR(255)
dni: VARCHAR(12)
PEDIDOS
=======
id: INT
id_producto: INT
public class Stack {
private Object [ ] items ;
private int top ;
public Stack ( int size ) {
this items = new Object [ size ] ;
this top = - 1 ;
}
public class Coordinates {
private double longitude;
private double latitude;
public Coordinates(double longitude, double latitude) {
this.longitude = longitude;
this.latitude = latitude;
}
}
@palmerabollo
palmerabollo / gist:9210469
Last active August 29, 2015 13:56
Java inheritance
interface Animal {
void eat()
}
class Mammal implements Animal {
void eat() {
System.out.println("mammal eating");
}
}