challenge

Grouping consecutive identical items: IEnumerable<T> to IEnumerable<IEnumerable<T>>

I've got an interresting problem: Given an IEnumerable<string>, is it possible to yield a sequence of IEnumerable<string> that groups identical adjacent strings in one pass? Let me explain. 1. Basic illustrative sample : Considering the following IEnumerable<string> (pseudo representation): {"a","b","b","b","c","c","d"} How to get...

Design Pattern - Complex MultiObject Versioning w/Out-of-Sequence awareness

Here's the deal/challenge, We have to keep track of information and it's linear changes. We also have to keep track of changes that are out-of-sequence. For example A happened then B happened. Sometime later, we learn of C which actually happened before B. Along with this challenge, we have many objects that have to be versioned th...

Ideas for building vulnerabilities into your site?

I'm trying to create a programming challenge that would require developers to hack into the MVC site I create. The idea is obviously to teach them about preventing these types of attacks. The current idea I have is to build multiple vulnerabilities into the site - but the second vulnerability would require the first to be completed, et...

Algorithm to pick values from set to match target value?

I have a fixed array of constant integer values about 300 items long (Set A). The goal of the algorithm is to pick two numbers (X and Y) from this array that fit several criteria based on input R. Formal requirement: Pick values X and Y from set A such that the expression X*Y/(X+Y) is as close as possible to R. That's all there is to ...

Ruby Challenge - efficiently change the last character of every word in a sentence to a capital

Hi All I recently was challenged to write some Ruby code to change the last character of every word in a sentence into a capital. Such that the string: "script to convert the last letter of every word to a capital" becomes "scripT tO converT thE lasT letteR oF everY worD tO A capitaL" This was my optimal solution however I'm sur...

A program that creates another program

Hi, I need to create a program that creates another program but not a compiler though. For example, I write a program that accepts a string input from the user. Let's say user enter "Pluto". This program should then create a separate .exe that says "Hello Pluto" when executed. How can I do this? If you could give example in C# and Wi...

Code Golf: ASCII Art number

Possible Duplicate: Code Golf - Banner Generation Post your shortest code to convert a number into a ASCII art digits. Input - Assume that an integer variable called z has already been set containing the number. Output - Print the output to the console. Quality - The lower number of characters, the better. Formatting - Fle...

Generating all Possible Combinations

Hi everyone, Given 2 arrays Array1 = {a,b,c...n} and Array2 = {10,20,15....x} .. how can i generate all possible combination as Strings a(i) b(j) c(k) n(p) where 1 <= i <= 10, 1 <= j <= 20 , 1 <= k <= 15, .... 1 <= p <= x such as a1 b1 c1 .... n1 a1 b1 c1..... n2 ...... ...... a10 b20 c15 nx (last combination) So in all t...

foo(foo(x)) = -x

Possible Duplicate: Interview question: f(f(n)) == -n Like I wrote above, implement a function whose prototype is int foo(int n); such that foo(foo(x)) returns -x ...

Computing the colors of the Olympic flag

Let's say you are helping setting up the Olympics on an alien planet. You are in charge of making the Olympic flag. The Olympic flag would have 6 colors. The flags of every country on the planet must have one of the six colors on the Olympic flag. You already know the colors on a flag. How would you compute the colors on the Olympic flag...

Challenge to calculate maximum quantity and split sets with PHP

I have two items, A and B. You can only have a maximum set of 2 items at any one time. This results in the following combinations: A B 1 0 2 0 0 1 0 2 1 1 If you want 3 or more items, the remainders spill over into a new set. Sets of 2 are preferred over single items in a set. Examples: 2 lots of A and 1 lot of B (total 3 items) wou...

What is the most pythonic way to have a generator expression executed?

More and more features of Python move to be "lazy executable", like generator expressions and other kind of iterators. Sometimes, however, I see myself wanting to roll a one liner "for" loop, just to perform some action. What would be the most pythonic thing to get the loop actually executed? For example: a = open("numbers.txt", "w") ...

Code golf: Digital clock

Possible Duplicate: Code Golf: Seven Segments The task: Write the smallest possible program (least number of characters) that takes input in the hh:mm format and outputs this as a digital clock (seven-segment display). Sample input: 19:27 Sample output: _ _ _ | |_| . _| | | _| . |_ | Sample input: 11:...

Solving jumbled word puzzles with python?

I have an interesting programming puzzle for you: You will be given 2 things: 1. A word containing a list of english words put together : word = "iamtiredareyou" 2. Possible subsets: subsets = ['i', 'a', 'am', 'amt', 'm', 't', 'ti', 'tire', 'tired', 'i', 'ire', 'r', 're', 'red', 'redare', 'e', 'd', 'da', 'dar', 'dare', 'a',...

Understanding the motion of a disk using two static switches

This is a major re-write of the original question, I tried to clarify those points that were evidently confusing for some in my first version of the question. Thanks for the input in helping formulate the problem better! CONTEXT The challenge comes from a real-life coding problem. The first thing that responders should be aware of, is ...

Challenge: SQL check next record against previous

I have some data that needs to be validated, and while I have found a quick formula that works in excel I would like to find some SQL that would do the same so I can use it in my database as a check now and then. The data is simply this: ACACIA ST (KLN) | 1073 | 1149 | FAIL! | 76 ACACIA ST (KLN) | 1073 | 1151 | FAIL! | 78 ACACIA ST (KL...

Is this query possible?

Sorry in advance for the massive queries. I've been trying and cannot for the life of me get this query to work. It's adding wins and losses to both users when two logged in users are playing against each other. (It's rock paper scissors). I can make it work for a single user, but when I try to gather a 'stats-table' summing over use...

Code challenge: Bash prompt path shortener

I implemented a prompt path shortener for bash to be included in the PS1 environment variable, which shortens the working directory into something more compact but still descriptive. I'm curious what other ideas may exist. Here's the challenge: Create a bash function _dir_chomp which can be included into PS1 like this (line breaks inse...

Code Golf: Conway's Game of Life

The Challenge: Write the shortest program that implements John H. Conway's Game of Life cellular automaton. [link] EDIT: After about a week of competition, I have selected a victor: pdehaan, for managing to beat the Matlab solution by one character with perl. For those who haven't heard of Game of Life, you take a grid (ideally infinit...

Code Challenge - Convert var_dump of array back to array variable

I have never really thought about this until today, but after searching the web I didn't really find anything. Maybe I wasn't wording it right in the search. Given an array (of multiple dimensions or not): $data = array('this' => array('is' => 'the'), 'challenge' => array('for' => array('you'))); When var_dumped: array(2) { ["this"]...