Skip to main content

All Questions

15 votes
1 answer
23k views

Sudoku Puzzle Generator

I've written a Sudoku puzzle generator. It currently runs through each line of the 9x9 grid and places numbers randomly if they're valid. It loops over all the numbers from 1-9 and then if it finds ...
SuperBiasedMan's user avatar
14 votes
4 answers
2k views

Codechef: Prime Number Generator

Peter wants to generate some prime numbers for his cryptosystem. Help him! Your task is to generate all prime numbers between two given numbers! Input The input begins with the number t of test cases ...
Subham Goyal's user avatar
13 votes
1 answer
2k views

Extended stable marriage challenge

I've written a solution for the stable marriage problem in the case that the number of men is not equal to the number of women. My problem is not that I can't prove my code is right. The problem is I ...
Arman Malekzadeh's user avatar
12 votes
3 answers
238 views

Maximizing grad student happiness

A local university's graduate school has a field placement that's a required component for graduation. Each student works in the field (something like a residency for medical students) for one year ...
Edward's user avatar
  • 66.8k
11 votes
1 answer
4k views

Z-Algorithm for pattern matching in strings

I was trying to refactor the following Python code (keeping the same time-complexity) which is an implementation of Z-Algorithm for pattern matching in strings. ...
SohamC's user avatar
  • 221
10 votes
4 answers
14k views

Consolidate list of ranges that overlap

I wanted to implemented an algorithm in Python 2.4 (so the odd construction for the conditional assignment) where given a list of ranges, the function returns another list with all ranges that overlap ...
pedromarce's user avatar
10 votes
1 answer
14k views

K-Mean with Numpy

I have implemented the K-Mean clustering Algorithm in Numpy: ...
Frames Catherine White's user avatar
9 votes
1 answer
14k views

Check if two rectangles overlap

Suppose rectangles are parallel to x-axis/y-axis. Check if two rectangles overlap or not and if they do, output the overlap area. Here is my code and I track min/max x-coordinate and min/max y-...
Lin Ma's user avatar
  • 3,493
9 votes
1 answer
9k views

Find the nearest point of a given set of points

Suppose there are a set of given points (represented by x and y two dimensional coordinates), and for any given point A, I want ...
Lin Ma's user avatar
  • 3,493
9 votes
1 answer
855 views

Check “five in a row” for a 15x15 chess board (part 2)

This is a follow-up from here. I have a further optimization for space complexity by store only direction status data for one row for each directions (refer to variable ...
Lin Ma's user avatar
  • 3,493
8 votes
4 answers
10k views

"Largest power of two less than N" in Python

...
CodeYogi's user avatar
  • 5,137
8 votes
3 answers
188 views

Python methods to reduce running times KTNS algorithm

I have been trying to develop an algorithm called keep the tool needed soonest (for more information about the KTNS explanation (page 3)) but during the simulations, I have realized that it takes too ...
A.Piquer's user avatar
  • 195
8 votes
2 answers
3k views

Sudoku solver recursive solution

Here is my code in Python 2.7 for a Sudoku resolver. Any advice on performance improvement, code bugs or general code style advice is appreciated. My major idea is: Using method generate some random ...
Lin Ma's user avatar
  • 3,493
8 votes
1 answer
1k views

Find the nearest point of a given set of points (part 2)

This is a continued discussion from here, and I use new a approach (bounding box/or envelop algorithm) to improve the algorithm efficiency. Any code bugs, algorithm time complexity improvement or ...
Lin Ma's user avatar
  • 3,493
8 votes
1 answer
451 views

Artificial Neural Network implementaion

I'm looking for some general tips on code practices, doing things properly in idiomatic pythonic way. But mostly I want to know if this was build correctly. I tried making neural nets in the past, but ...
f.rodrigues's user avatar

15 30 50 per page
1
2 3 4 5
11