Ctrl+P again to print, arrows/tab to navigate results, enter to confirm

    Parsing

    Converting strings to integers

    x.toInteger()
    x as Integer
    x as int
    

    Looping through list/string

    for(a:args){a} // Java-style syntax; braces may be omitted if the body is only one statement
    args.any{it} // Must return falsy value to keep iterating
    args.min{it} // Sometimes useful for non-falsy values
    args.each{it} // Most general iteration method, but rarely optimal
    

    Looping through integers

    10.times{}
    for(n:0..9){} // better than .times when the variable is used at least twice and braces aren't needed
    0.upto(10){}
    (0..9).any{} // or any other list methods
    0.step(10,2){} // loop with a step
    

    Type Annotations

    Type annotations are optional in Groovy and should usually be avoided. However they can sometimes actually make code shorter.

    If you're storing an object in a variable anyway, the shortest way to invoke a class's constructor is:

    ClassName v=[arg]
    // vs
    v=new ClassName(arg)
    

    Typed variables can coerce values on assignment:

    // Loop over the char values of the string
    // Prints: 97 98 99 100
    for(int c:'abcd')print"$c "
    
    int i
    // Typed variables are zero-initialized
    // Prints: 0
    println i
    
    // We can do integer division without intdiv!
    i=3/2
    // Prints: 1
    println i
    i=5/2
    // Prints: 2
    println i
    // However this still prints 2.5:
    println(i=5/2)
    

    Finally, if your solution is timing out, applying annotations to some of the variables can help Groovy optimize your code so it runs faster.

    Misc

    Packers

    2:1

    Spoiler

    Decompressor

    evaluate new String('...'.getBytes('UTF-16LE'))
    

    If the hole has no arguments, Eval.me may be used instead of evaluate to save 1 byte.

    Compressor

    # python
    print('CODE'.encode().decode('utf-16le'))