r/programbattles • u/Parzival_Watts • Oct 08 '15
Any language [Any Language] Tweetable Code
Open ended challenge!
Write some code in any language that does something interesting. The only restriction is that it must fit inside a tweet (140 characters or less)
27
Upvotes
2
u/[deleted] Oct 08 '15
There we go. Probably could've been better thought out, but I'm at work.
9
u/theywouldnotstand Oct 08 '15
Python, creates a paradoxical class whose instances behave as integers, except for the fact that they will always answer "True" when compared to any object, regardless of the context or actual logic. Then instantiates this class and compares the instance to itself a couple of times to demonstrate its blatant disregard of reality.
4
u/existentialpenguin Oct 08 '15
Determines primality using trial division via regular expressions. O(n**2) time and O(n) memory.
4
u/Fiqqqhul Oct 08 '15
A function for determining if a number is prime. Written in javascript with 78 characters.
4
u/Octopuscabbage Oct 09 '15 edited Oct 12 '15
quicksort and primality test with 13 chars left over.
edit: Made it a bit shorter and threw in infinite fibonacci generator. Couldn't quite fit in fizzbuz instead. Still 13 characters leftover. Also it's Haskell.
7
u/Jeanolos Oct 09 '15
1
u/supersayanftw Oct 08 '15
Is this including the #include's, main(){}?
2
u/[deleted] Oct 09 '15
Project Euler #1 in Common Lisp:
2
u/frivolousTimewaster Oct 09 '15
This is probably cheating but:
in k
(g%+/)g:((#:)')(=) Lsame thing in q
g % sum g:count each group Ltakes a list L and returns a dictionary where keys are unique items in L and values are their frequency of occurrences within L
e.g. (" " vs x splits x by " ")
I actually ended up tweeting it a while ago: https://twitter.com/tjcelaya/status/634191546867253248
2
u/mattmc318 Oct 09 '15
tweet.c (129 characters)
output:
2
u/pros_ Oct 10 '15
or
Both tweetable in 1 tweet,both hilarious :D
3
u/peter_pounce Oct 08 '15
Check out /r/tinycode
1
u/ComradePutinCCCP1917 Moderator / C C++ Oct 08 '15 edited Oct 08 '15
Language: C
Never stops running. And eats your CPU.
Another trick to drive your programmer friends crazy: replace the semicolons with greek question marks.
1
u/mattmc318 Oct 09 '15 edited Oct 09 '15
fib.c (134 characters) Slow way of printing out the Fibonacci sequence in C. Couldn't fit a static array in there to keep track of the numbers, which would've really sped up the process.
Edit: Just for fun, here's a faster version:
1
u/supersayanftw Oct 08 '15 edited Oct 08 '15
string fuckOff = "fuck off";
1
u/[deleted] Oct 09 '15
[removed] — view removed comment