problem-solving

Can Dancing Links be applied to this CSP?

Can the Dancing Links implementation of Knuth's Algorithm X be used to solve this CSP? In this game the first and last number are always already in the board and I belive there's only one solution to each well formulated problem. ...

which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs) ?

I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much faster to develop and less time is spent in programming details which does not actually earn anything solution wise. EDIT 2: I plan to use python-graph lib from Google-codes, Please provide...

When was this clock bought?

The clock on the gym wall also shows the day name and the day of the month. This morning it showed Tuesday - 23. The day obviously rotates through a cycle of 7 - and showed "Tuesday" correctly. The day of the month, though, presumably rotates through a cycle of 31 and showed "23" incorrectly - today is the 1st December (ie. not the 31s...

Can you answer this 2009 ACM International Collegiate Programming Contest Finals problem?

Out of curiosity, I was checking out the problem set to the 2009 ACM international collegiate programming contest. The questions are pretty interesting. They're available at http://cm.baylor.edu/resources/pdf/2009Problems.pdf. I could not come up with an algorithm that solved problem 1, which I will reproduce here. It set off a livel...

What's Wrong? Question relied on: Files,Exceptions -> ERROR: EOFError

EDITED: import pickle filename=input('Enter a file name:') def entoles(): f=open(filename,'w') names=[] grades=[] while True: name=input("Give a student's name:") if name.lower()=='end': f.close() print("File closed") print("Back to M...

k partition algorithm - divide work load equally between k workers

I once read a problem in my Introduction to Algorithms (MIT Press) book which stated. We have a book with 100 pages and each page has a weight associated with it equal to its page number therefore the weights are i.e. 1,2,3,4,5. These weights represent the difficulty of the page in translation to other language. We have K people assigne...

Recurrence Equations

Given a problem, how to come up with a recurrence equation? For example : Let S be a set of n>0 distinct integers. Assume that n is a power of 3. A ternary comparison can compare three numbers from the set S and order them from the largest to the smallest. Describe an efficient algorithm that uses as few as possible ternary compariso...

Searching a file in 3 different ways.

I have been writing a program that searches a file in 3 different ways. But firstly, to choose which search program to use is differentiated in the command line. For example in the command line I type: Program 1 search: python file.py 'search_term' 'file-to-be-searched' program 2 search: python file.py -z 'number' 'search_t...

A good exercise to test one's ability to code?

I'm wondering if there's any good exercise to test and improve one's ability to code? I'm think specifically about program logic and being able to write good OOP code. I thought about writing a simple HTML parser, but it seems that's more of a challenge then it sounds. Anyone got any idea's of something that would test & improve my ...

Ruby book with problems

Hi, I'm looking for a good book on Ruby which has interesting problems with each chapter that help grasp the fundamental concepts in a good way - something similar to Thinking in Java or Problems in General Physics by IE Irodov. Any suggestions? ...

Transmitting hand-written information over a network

A teacher is writing on a blackboard and we want to pass all the information on the blackboard over a low-bandwidth network in real-time. How do we do it? In one interview, I faced this question. ...

For problem solving..

This may be a bit OT... Here's the problem: "N different points with integer coordinates are given in a plane. You are to write a program that finds the maximum number of collinear points (they all belong to the same line)." Now my question: You don't have to solve this for me, instead I want to know where I can find some materials for...

Project Euler - Problem 8 - Help with understanding requirement

Hi All, I am working through the problems on project Euler and am not to certain if my understanding of the question is correct. Problem 8 is as follows: Find the greatest product of five consecutive digits in the 1000-digit number. I have taken this to mean the following: I need to find any five numbers that run consecutively i...

How to solve an LCP (linear complementarity problem) in python ?

Is there a good library to numericly solve an LCP in python ? Edit: I need a working python code example because most libraries seem to only solve quadratic problems and i have problems converting an LCP into a QP. ...

Finding intersect in triangle from a vector originating from a particular side

I know the coordinates of A, B and C.. I also know of a vector V originating from C.. I know that the vector intersects A and B, I just don't know how to find i. Can anyone explain the steps involved in solving this problem? Thanks alot. http://img34.imageshack.us/img34/941/triangleprob.png ...

being able to solve google code jam problem sets

This is not a homework question, but rather my intention to know if this is what it takes to learn programming. I keep loggin into TopCoder not to actually participate but to get the basic understand of how the problems are solved. But to my knowledge I don't understand what the problem is and how to translate the problem into an algorit...

How would you solve this GPS/location problem and scale it? Would you use a Database? R-tree?

Suppose I have a people and their GPS coordinates: User1, 52.99, -41.0 User2, 91.44, -21.4 User3, 5.12, 24.5 ... My objective is: Given a set of coordinates, Out of all those users, find the ones within 20 meters. (how to do a SELECT statement like this?) For each of those users, get the distance. As you probably guessed, these co...

Tricky programming problem that I'm having trouble getting my head around

First off, let me say that this is not homework (I am an A-Level student, this is nothing close to what we problem solve (this is way harder)), but more of a problem I'm trying to suss out to improve my programming logic. I thought of a scenario where there is an array of random integers, let's for example say 10 integers. The user will...

Google Codejam 2009 Qualification problem: Watershed in C++

I tried out this Codejam problem and produced a valid solution in C++. There is a Python solution on the website. Was wondering if any C++ people would offer some improvements/optimizations to this solution. Thanks! BTW: In Codejam the goal is to write code as fast as possible (a reason why Python would have been a better language choic...

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...