fun

Regex to match partial words (JavaScript)

I would like to craft a case-insensitive regex (for JavaScript) that matches street names, even if each word has been abbreviated. For example: n univ av should match N University Ave king blv should match Martin Luther King Jr. Blvd ne 9th should match both NE 9th St and 9th St NE Bonus points (JK) for a "replace" regex that wraps t...

How can I improve my programming skills with out a computer (or reading material)?

Given the recent and continued chaos with grounded flights and folks stuck in airports, and what not, I'm wondering if anyone has any suggestions for activities that would help sharpen and develop a progammer's mind. The constraints are: Laptop is out of battery and there are no free sockets. You're bored of the book you're reading or...

One letter game problem?

Recently at a job interview I was given the following problem: Write a script capable of running on the command line as python It should take in two words on the command line (or optionally if you'd prefer it can query the user to supply the two words via the console). Given those two words: a. Ensure they are of equal length b. Ensur...

Easy code-golf challenges

I am interested in trying a few code-golf problems, but of a fairly easy level as I'm only a year old in terms of programming. Simple things, but that will make me think. I am comfortable in JavaScript and PHP at the moment. ...

What programming/techy name should I give my new pup?

I am getting a Border Collie puppy tomorrow. If I can get my wife to agree to do so I want to give it a techy/programming type of name. The vast majority of my development is in Microsoft .NET / C# on mobile devices (WinMo and tablets) as well as Silverlight and ASP.NET. I would like the name to be something in that area although I am op...

When will this condition evaluate to False?

Under what circumstances will the "False" part of the following code be executed? x = 20; y = -30; if (x > y) { // True part } else { // False part } NB: Language is C, compiler is gcc (although some other compilers may also do the same thing). ...

What was Tim Sweeney thinking? (How does this C++ parser work?)

Tim Sweeney of Epic MegaGames is the lead developer for Unreal and a programming language geek. Many years ago posted the following screen shot to VoodooExtreme: As a C++ programmer and Sweeney fan, I was captivated by this. It shows generic C++ code that implements some kind of scripting language where that language itself seems to b...

Algorithm: How to tell if an array is a permutation in O(n)?

Hello, Input: A read-only array of N elements containing integer values from 1 to N (some integer values can appear more than once!). And a memory zone of a fixed size (10, 100, 1000 etc - not depending on N). How to tell in O(n) if the array represents a permutation? --What I achieved so far (an answer proved that this was not good)...

How would you solve this graph theory handshake problem in python?

I graduated college last year with a degree in Psychology, but I also took a lot of math for fun. I recently got the book "Introductory Graph Theory" by Gary Chartrand to brush up on my math and have some fun. Here is an exercise from the book that I'm finding particularly befuddling: Suppose you and your husband attended a party w...

Implementing a scrabble solver.

Hello, before I ask anything, just letting everyone know that this is for fun and I have posted all of my code that I have so far; will post more as things are fixed/implemented), sorry for the lengthy post! I have two questions here and I will post all of my code below. - 1) I can't seem to figure out why when inputting 12+ letters wi...

Code Golf: 1x1 black pixel

Recently, I used my favorite image editor to make a 1x1 black pixel (which can come in handy when you want to draw solid boxes in HTML cheaply). Even though I made it a monochrome PNG, it came out to be 120 bytes! I mean, that's kind of steep. 120 bytes. For one pixel. I then converted it to a GIF, which dropped the size down to 43 ...

Problem understanding Inheritance

I've been racking my brains over inheritance for a while now, but am still not completely able to get around it. For example, the other day I was thinking about relating an Infallible Human and a Fallible Human. Let's first define the two: Infallible Human: A human that can never make a mistake. Its do_task() method will never throw an...

What is your favourite programming-related lolcat picture?

In the spirit of these questions... http://stackoverflow.com/questions/234075/what-is-your-best-programmer-joke http://stackoverflow.com/questions/354686/programming-related-songs http://stackoverflow.com/questions/517897/anyone-know-any-programming-related-poetry ... I wonder: What is your favourite programming-related lolcat pictu...

Code Golf: Phone Number to Words

Guidelines for code-golf on SO We've all seen phone numbers that are put into words: 1-800-BUY-MORE, etc. What is the shortest amount of code you can write that will produce all the possible combinations of words for a 7 digit US phone number. Input will be a seven-digit integer (or string, if that is simpler), and assume that ...

How does uʍop-ǝpısdn text work?

I have found upside down text in this website: http://www.cheesygames.com/upside-down-text how does it work? does unicode have upside down chars? Or what? How can I write my own text flipping function? ...

Looking for web comic: number of words made up in protocols

There is this xkcd comic: I recently saw a version with "probability protocol is good" and a quote from the HTTP RFC (I believe). But I can't seem to find it anymore. Can someone help? (I need this to convince some of my co-workers that they're doing the design for a network protocol we're building wrong, so this question is programm...

Are there any code libraries or languages with built-in support for Metric Time?

Metric time is documented here. I'm looking for any implementations of Metric time to Anglo-Babylonian Time (see article link) either as a library or built-into a programming language. With all the "joke" programming languages out there, it's possible that someone has done this. P.S. I realize that it is trivial. This question is for ...

Code Golf (sort of): a Functional Puzzle

Here's a puzzle: define some higher-order function f such that, using only f and parentheses, you can define the three higher-order functions const, id and bothOn. Those three functions could be defined in a straightforward way and in the Haskell programming language as follows: -- takes two arguments, ignores the second and returning ...

Some dev forgot to lock their machine, Tricks! to play?

Some developers are just lazy and forget to lock their session when leaving. We strongly believe here that such bad habits should be punished. It's trick or treat: Invert mouse buttons Change wallpaper for a nice message in picture Send email from his account to everyone: "Bringing cakes tomorrow for being so bad!" What's your trick ...

Interview Question - Flipping Bits

I recently saw an interview question asking the following: Given a 32 bit number, write pseudo code to flip the second last bit What is the best/easiest way to do this? ...