Skip to content

Instantly share code, notes, and snippets.

@Chase-san
Created November 17, 2010 09:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Chase-san/703178 to your computer and use it in GitHub Desktop.
Save Chase-san/703178 to your computer and use it in GitHub Desktop.
Look Ma! No hands!
/**
* Recursive with no class level or local variables,
* a single int (the one passed in),
* a single call to print
* a single call to itself
* a single assignment
* a single if() statement (not counting ternaries)
* @param a
*/
public static void rc(int a) {
System.out.print(
((a & 0x4000) == 0x4000) ?
(((a & 0x3F00) >>> 8) == 0 ? "\n" :
((a & 0x3F00) >>> 8) == 1 ? " " : " *") : ""
);
a = (a & 0x4000) == 0x4000 ? a & ~0x4000 :
(a&0x3FFF) < 0x100 ? a|0x100 : (((a&0x3F00)>>>8)==1)?(((a>>>24)<(a&0xFF)-((a>>>16)&0xFF))?(a&0xFFFFFF)
|(((a>>>24)+1)<<24)|0x4000:(a&(0xFFFFFF&~0x3F00))|((((a&0x3F00)>>>8)+1)<<8)):(((a&0x3F00)>>>8)==2)
?(((a>>>24)<((a>>>16)&0xFF)+1)?(a&0xFFFFFF)|(((a>>>24)+1)<<24)|0x4000:(a&(0xFFFFFF
&~0x3F00))|((((a&0x3F00)>>>8)+1)<<8)):(a&(~0xFF0000&~0x3F00))|((((a>>>16)&0xFF)+1)<<16)|0x4000;
if(((a >>> 16) & 0xFF) < (a&0xFF))
rc(a);
}
/**
* @param args
*/
public static void main(String[] args) {
rc(10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment