For challenges involving ways to organize data (data types, arrays, binary trees ...)

learn more… | top users | synonyms

21
votes
1answer
452 views

Stack Exchanging

Problem Say you have N stacks named S1 through SN, where each Sk (k = 1 to N) contains N copies of the number k. For example, when N = 3 the stacks looks like this: 1 2 3 <- top of stack 1 2 ...
5
votes
2answers
178 views

Shortest class to implement Perl hash-of-hashes

At some point, I bumped into an SO question asking how to implement Perl's trivial hash-of-hashes data structure in Java. For those who don't know Perl, the hash value can be a scalar or another ...
13
votes
7answers
278 views

Prefix Tree Traversal

Write a program that takes in (via stdin or command line) a string with the recursive form PREFIX[SUFFIXES] where PREFIX may be any string of lowercase letters (a-z), including the empty string, ...
17
votes
6answers
416 views

Numbering Hierarchical Outlines

Write a program that takes in a string where every line consists of the character 0 indented by some number of spaces. The top line is not indented and every other line will be indented by at most one ...
5
votes
1answer
209 views

Most efficient table storage for determining recurrence

The goal of this challenge is to implement a storage and retrieval pattern that will most quickly determine if a set of recurrence definitions fall within a date range. Consider the schema: Event -|-...
19
votes
2answers
352 views

Turn over a new leaf

You're given a tree, which in computer science tradition, has the root at the top and leaves at the bottom. The leaf nodes are labelled with numbers. Your goal is to take the special leaf marked -1 ...
5
votes
2answers
313 views

Heaps of trouble

Challenge You must, in the least bytes possible, implement the Binary Heap data structure and each of the following methods that operate on it: A function which takes no arguments and returns an ...
5
votes
2answers
305 views

Collatz Graph Plotting

Write a program that outputs a graph of the collatz sequence any way you want (ASCII Image Video etc). You have to implement it that way that you can adjust the size of the graph by either the maximum ...
2
votes
1answer
186 views

Immutable dictionaries in Haskell [closed]

You need to implement immutable dictionaries using only functions without any other data types (custom or built-in). The dictionary must be indexed by any data type of class Eq and contain values of ...
6
votes
10answers
1k views

Generate the python dictionary of phone keypresses for any letter

In the fewest bytes, generate the dictionary of keypresses for any letter (as described in https://code.google.com/codejam/contest/351101/dashboard#s=p2) In Python, the dictionary literal itself: {'...
0
votes
8answers
687 views

Build a numerical library without using any primitive data type

The task is to build a numerical library for working with arbitrarily large integers that supports the following operations: addition subtraction multiplication division modulo operation However, ...
3
votes
2answers
719 views

Shortest implementation of a linked list, stack and queue

Challenge Write the shortest program that implements the minimum requirements for a linked list, stack and queue. Minimum requirements Functions that allow the user to add and remove elements from ...
-4
votes
2answers
539 views

Strings: Microsoft interview

You are given an array of strings , you have to construct a single array containing all of them so that the same array of strings can be reconstructed from the large array. The strings may contain any ...
22
votes
9answers
2k views

Implement lazy lists, preferably in a language you don't know well [closed]

This is a nice exercise for becoming more fluent in that programming language you've been meaning to learn, but have only tinkered with lightly. This involves working with objects, using or ...
4
votes
2answers
352 views

Implement cdbmake

Write the shortest program to build a cdb database, using the following syntax for input: +klen,dlen:key->data followed by a newline. Example: +3,5:one->Hello +3,7:two->Goodbye (Unlike ...