puzzle

Find max length word from arbitrary letters

I have 10 arbitrary letters and need to check the max length match from words file I started to learn RE just some time ago, and can't seem to find suitable pattern first idea that came was using set: [10 chars] but it also repeats included chars and I don't know how to avoid that I stared to learn Python recently but before RE and ...

Python permutation generator puzzle

I am writing a permutation function that generate all permutations of a list in Python. My question is why this works: def permute(inputData, outputSoFar): for elem in inputData: if elem not in outputSoFar: outputSoFar.append(elem) if len(outputSoFar) == len(inputData): print outputSoF...

Check if a number is divisible by 3

Not sure if it's a duplicate. But I need to find whether a number is divisible by 3 without using %, / or *. The hint given was to use atoi() function. Any idea how to do it? ...

double or half coin toss expectation

Came across an interesting problem today. You are given a coin and x money, you double money if you get heads and lose half if tails on any toss. What is the expected value of your money in n tries What is the probability of getting more than expected value in (1) This is how I approached it. The probability of heads and tails is sam...

Modelling combinatorial optimization? problem

I've been unable to match this problem into some canonical one, and I would like some guides to build/use an algorithm and solve it. Description is as follows: We have some people who want breakfast. Each one may order any number of coffee, juice and toast. We accumulate the order for all the group. InitialOrder = { C1, J1, T1 } wit...

Match-three puzzle games algorithm

I am trying to write a match-three puzzle game like 'call of Atlantis' myself. The most important algorithm is to find out all possible match-three possibilities. Is there any open source projects that can be referenced? Or any keywords to the algorithm? I am trying to look for a faster algorithm to calculate all possibilities. Thanks. ...

Puzzled over palindromic product problem

Hi, I've been learning Ruby, so I thought I'd try my hand at some of the project Euler puzzles. Embarrassingly, I only made it to problem 4... Problem 4 goes as follows: A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest p...

C puzzle: how will you print something on console?

/*you cannot change anything from here below*/ main() { exit(0); } /*you cannot change anything from here up*/ This was asked during an interview. I was told to print something on console. anybody? ...

Transact-SQL Query / How to combine multiple JOIN statements?

I'm banging my head on this SQL puzzle since a couple of hours already, so i thought to myself : "Hey, why don't you ask the Stack and allow the web to benefit from the solution?" So here it is. First thing, these are my SQL tables: Fields FieldID INT (PK) FieldName NVARCHAR(50) (IX) FormFields FieldID INT (FK) FormID INT (FK) Va...

How should I cluster items into an ordered collection that makes sense graphically?

I've got an an application wherein I will be provided with an unordered collection of items (objects that can basically be represented as rectangles) and need to put them into a larger rectangular shape (a cluster) based off of their physical location. There may be more than one cluster of items, and some items may be in a cluster by the...

Rotating a section of a two dimensional array.

I've read this SO question on how to rotate a two-dimensional array many times, and I was curious as to how you could expand this situation to work with a section of a two-dimensional array. I've thought about it for a while, and I can't seem to come up with a good equation. Essentially what I'm wanting to do is something like this: ...

How to programatically solve the 15 (moving numbers) puzzle?

Hi, all of you have probably seen the moving number/picture puzzle. The one where you have numbers from 1 to 15 in a 4x4 grid, and are trying to get them from random starting position to 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 My girlfriend or some of my non-programmer friends can solve this with some mumbo-jumbo magic, that th...

How to find repeating sequence of characters in given array

my problem is to find the repeating sequence of characters in the given array. simply, to identify the pattern in which the characters are appearing. example: for the examples in the above image the output for the First array should be "JAMESON" Second array should be "RON" Third array should be "SHAMIL" Fourth ar...

Regular expression puzzle

This is not homework, but an old exam question. I am curious to see the answer. We are given an alphabet S={0,1,2,3,4,5,6,7,8,9,+}. Define the language L as the set of strings w from this alphabet such that w is in L if: a) w is a number such as 42 or w is the (finite) sum of numbers such as 34 + 16 or 34 + 2 + 10 and b) The number ...

What is the quickest way to isolate the source of an error amongst a list of potential sources?

What is the quickest way to isolate the source of an error amongst an ordered list of potential sources? For example, given a list of column mappings, and one of those column mappings is incorrect, what debugging technique would lead you to most quickly identify which mapping is invalid? (By most quickly, I mean, which approach would r...

Rectangular region in an array

Given an N*N matrix having 1's an 0's in them and given an integer k,what is the best method to find a rectangular region such that it has k 1's in it ??? ...

solve this puzzle

I bet you 200 gold coins that if you give me 400 gold coins, I will give you 600 gold coins in return. Would you bet with me? Why? ...

How can I improve this algorithm for solving a modified Postage Stamp problem?

Son of Darts Problem was a contest on Al Zimmermann's Programming Contests that ended on 20 Jun 2010 : Suppose that you have a dartboard that is divided into R regions. Each dartboard region has a positive integer value associated with it. Further suppose that you have D darts and that you throw each of them at the dartboard. Each...

how to optimise this code ?

Hello, I have a solution to the below problem in PHP. But it is taking too much time to execute for 10 digit numbers. I want to know where am I going wrong ? I am new to dynamic programming .Can someone have a look at this ? Problem In Byteland they have a very strange monetary system. Each Bytelandian gold coin has an integer numbe...

Website for C debugging puzzles

Hi, could you recommend some website for C debugging puzzles? Thanks ...