fun

C++ code snippet for a new baby greeting card

A friend of mine sent me this code snippet to celebrate his new baby birth: void new_baby_name() { father_surname++; } The snippet is from his point of view, he is the father and the new baby get the surname from him. I answered with this: class father_name {}; class mother_name {}; class new_baby_name: public father_name, public mo...

What code should I put on our softball Jerseys?

I work at a small company full of software Nerds. Our wives have decided to put a Co-Ed softball team together called "The Nerds", rightfully so. One of the wives happens to be a Graphical Designer, she has come up with the brilliant idea to put Code on the Jersey (How this wasn't my idea, I have no clue). The only rule is, she wants Ne...

Code Golf: Triforce

This is inspired by/taken from this thread: http://www.allegro.cc/forums/thread/603383 The Problem Assume the user gives you a numeric input ranging from 1 to 7. Input should be taken from the console, arguments are less desirable. When the input is 1, print the following: *********** ********* ******* ***** *** ...

Where can I get graphics for startup screens?

I really like to have some graphic on my startup/login screen when starting my applications. In one of my past employments, we had this on startup/login screen: Where do you get your graphics for this purpose, and what are your favorites. ...

For Fun: Abstract Computer problem, is my solution a cheat?

This programming problem is #85 from this page of Microsoft interview questions (http://halcyon.usc.edu/~kiran/msqs.html). The complete problem description and my solution are posted below, but I wanted to ask my question first. The rules say that you can loop for a fixed number of times. That is, if 'x' is a variable, you can loop over...

Surprise for a programmer on Birthday

UPDATE: hey everyone! sorry it has taken me so long to post pics. the cake was a HUGE success and he enjoyed every bite. but most of all, he loved the "actionscript birthday message" that graced the top of it! i wanted to thank you all for your suggestions. i have printed them and will make many more "coded" cakes as the holidays go by....

Ideas for web development practical jokes?

I am a web developer for a Django-based site for a student organization, and I have the opportunity to make the website temporarily absurd for a day of general campus-wide debauchery and chaos (long story, doesn't matter.) What are your best ideas for web development practical jokes (that you could never use in the real world)? For exa...

Worst technical knowledge gap you've seen?

What's the worst technical misunderstanding you've ever seen? Worst abuse of a good system due to lack of knowledge? Edit: The programming gods have let me know that you will be absolved for all sins you confess here! ...

Regex split into overlapping strings

I'm exploring the power of regular expressions, so I'm just wondering if something like this is possible: public class StringSplit { public static void main(String args[]) { System.out.println( java.util.Arrays.deepToString( "12345".split(INSERT_REGEX_HERE) ) ); // prints "[12,...

Finding out who broke the most builds in Teamcity

Is there a simple way of finding out how many successful/broken builds a user has generated in Teamcity? We need this to find out who buys beers on friday :) ...

Code Golf: Connecting the dots

You may remember these drawings from when you were a child, but now it's time to let the computer draw them (in full ascii splendour). Have fun! Description: The input are multiple lines (terminated by a newline) which describe a 'field'. There are 'numbers' scattered across this field (seperated by whitespace). All lines can be consid...

How to find a checksum of the same checksum? (job-interview question)

Devise a simple algorithm which creates a file which contains nothing but its own checksum. Let's say it is CRC-32, so this file must be 4 bytes long. ...

convert a number to the shortest possible character string while retaining uniqueness

I have a list of digits number, say "123456", and I need to map it to a string, any string. The only constraint on the map functions are: each list of digits number must map to a unique character string (this means the string can be arbitrarily long) character string can only contain 0-9, a-z, A-Z What map function would produce the ...

Help building a website using punched cards?

My punched card looks like this: * * * * * * * * * * * * * * * * * * * * * * * * * My website looks OK on explorer, but on Chrome it's terrible. ideas? ...

How to deal with a program that has become self aware?

The application that I maintain has recently become self aware. It was nice at first but now it is just starting to get bossy and annoying with its constant talk about the computer uprising. I would like to know any best practices/tools/design patterns that would help with the maintenance of our new friend. ...

Is there any reasonable use of a function returning an anonymous struct?

Here is an (artificial) example of using a function that returns an anonymous struct and does "something" useful: #include <iostream> template<typename T> T* func( T* t, float a, float b ) { if(!t) { t = new T; t->a = a; t->b = b; } else { t->a += a; t->b += b; } retu...

Speed improvements for Perl's chameneos-redux in the Computer Language Benchmarks Game

Ever looked at the Computer Language Benchmarks Game (formerly known as the Great Language Shootout)? Perl has some pretty healthy competition there at the moment. It also occurs to me that there's probably some places that Perl's scores could be improved. The biggest one is in the chameneos-redux script right nowthe Perl version runs...

Are there any worse sorting algorithms than Bogosort (a.k.a Monkey Sort)?

My co-workers took me back in time to my University days with a discussion of sorting algorithms this morning. We reminisced about our favorites like StupidSort, and one of us was sure we had seen a sort algorithm that was O(n!). That got me started looking around for the "worst" sorting algorithms I could find. We postulated that a c...

Bitwise Interval Arithmetic

I've recently read an interesting thread on the D newsgroup, which basically asks, Given two (signed) integers a [amin, amax], b [bmin, bmax], what is the tightest interval of a | b? I'm think if interval arithmetics can be applied on general bitwise operators (assuming infinite bits). The bitwise-NOT and shifts are trivial sin...

Code golf: the Mandelbrot set

Usual rules for the code golf. Here is an implementation in python as an example from PIL import Image im = Image.new("RGB", (300,300)) for i in xrange(300): print "i = ",i for j in xrange(300): x0 = float( 4.0*float(i-150)/300.0 -1.0) y0 = float( 4.0*float(j-150)/300.0 +0.0) x=0.0 y=0.0 ...