Skip to content

Instantly share code, notes, and snippets.

@MLLeKander
MLLeKander / gist:3825219
Created October 3, 2012 05:35
305 BoardTest Shell
#!/usr/bin/python
from sys import argv, stdin, stdout
import re
translate = {
'em': 'enterMove',
'sm': 'showMove',
'show': 'showBoard',
'am': 'applyMove',
'dm': 'doMove',
@MLLeKander
MLLeKander / gist:3825222
Created October 3, 2012 05:36
305 BoardTest Shell
#!/usr/bin/python
from sys import argv, stdin, stdout
import re
translate = {
'em': 'enterMove',
'sm': 'showMove',
'show': 'showBoard',
'am': 'applyMove',
'dm': 'doMove',
import java.util.*;
class BeautifulStrings {
public static String solve(Scanner scan) {
HashMap<Character, Integer> map = new HashMap<Character, Integer>();
for (char c : scan.nextLine().toLowerCase().toCharArray())
if (Character.isLowerCase(c))
map.put(c, (map.containsKey(c) ? map.get(c) : 0)+1);
List<Integer> values = new ArrayList<Integer>(map.values());
235x02:409 b235x02bw1box
235x07:409 b235x07bVV4RS
235x07:currChars: l3vZmU bestScore: 410
235x08:407 b235x08cQcpgW
235x09:currChars: dda9QK bestScore: 409
235x10:currChars: nv0kyV bestScore: 410
235x11:currChars: nIFyRZ bestScore: 410
235x12:405 gybe235x12aLUKDA
235x13:currChars: hCs4fV bestScore: 406
235x13:currChars: mOy2WW bestScore: 405
@MLLeKander
MLLeKander / gist:7021349
Last active December 25, 2015 18:29
findHead
Node findHead(Node start) {
int tortoiseSpeed = 0, hareSpeed = 0;
Node tortoise, hare;
if (start == null)
return start;
for (tortoiseSpeed = 0; true; tortoiseSpeed = hareSpeed + 1) {
if (start.jump(tortoiseSpeed+1) == null)
return null;
@MLLeKander
MLLeKander / gist:7166279
Created October 26, 2013 07:15
CPC outfile tree
├── S13
│   ├── MagicCheck
│   │   ├── problem.txt
│   │   ├── submissions
│   │   │   ├── graded
│   │   │   │   ├── cfarwell.1
│   │   │   │   │   ├── 1.out
│   │   │   │   │   ├── 2.out
│   │   │   │   │   ├── 3.out
│   │   │   │   │   ├── 4.out
@MLLeKander
MLLeKander / gist:7308840
Last active December 27, 2015 10:09
C args
#include <stdio.h>
int main(int argc, char *argv[]) {
int i;
for (i = 0; i < argc; i++)
printf("argv[%d] = '%s'\n", i, argv[i]);
}
import java.util.*;
class Main {
public static void swap(int[] arr, int i, int j) {
int tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
}
public static void permuteRecur(int[] arr, int ndx) {
In [1]: import sys
In [2]: for line in sys.stdin:
...: print line
...:
asdf
hello
world
asdf
┌─[ michael@michael-desktop: ~ ]
└─> cat test.java
class test {
public static int f(int a, int b) {
return a + b;
}
public static int g(int f) {
return f(f, 3);
}
public static void main(String[] args) {