Skip to main content

All Questions

Filter by
Sorted by
Tagged with
1 vote
1 answer
1k views

Project RoboNest - Nestable/Breakable For Loops + Basic While Loops for Robot Framework

I'm implementing things in Robot Framework that it does not support by default, including nestable For Loops and, now, While Loops. I'm looking for readability, algorithm, methodology, and/or ...
Brandon Olson's user avatar
4 votes
4 answers
21k views

Use Python to determine the repeating pattern in a string

I am writing an algorithm to count the number of times a substring repeats itself. The string is between 1-200 characters ranging from letters a-z. There should be no left overs at the end of the ...
Jake Steele's user avatar
5 votes
1 answer
839 views

Counting the number of elements in a sorted array

Suppose I have a sorted array, and each element may appear multiple times. To make it simple, here is an example: ...
Lin Ma's user avatar
  • 3,453
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,453
3 votes
1 answer
119 views

Beating a dead horse: Project Euler 4

The task 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 palindrome made from the ...
N3buchadnezzar's user avatar
3 votes
2 answers
936 views

Checking literary works for Zipf's Law

I wrote a Python script that, given a literary work in text file format, takes it apart, makes a word list, counts how many times each words appears in the literary work, and then checks if it follows ...
Additional Pylons's user avatar
4 votes
2 answers
7k views

Binary tree data structure

I am learning about the binary tree data structure and implemented some basic functionality. It was working great with module level functions until I realized that I need to keep track of the root ...
CodeYogi's user avatar
  • 5,127
4 votes
1 answer
4k views

Find values in list which sum to a given value within tolerance

This is really a follow on from a question I asked earlier this year on Stack Overflow. I received a great answer to the following problem: I'm trying to code up something simple and pythonic to ...
Mark's user avatar
  • 163
7 votes
2 answers
991 views

Generating 3 combinations in Python

I have been experimenting around with generating all the n-combinations of an array. This code quickly generates all \$\text{k-combinations}\$ of a given array. I am testing my own implementation ...
CodeYogi's user avatar
  • 5,127
4 votes
4 answers
655 views

Count the ways to partition an array into two equal sets

I need to count the number of ways to partition an array into two contiguous arrays such that those arrays contain exactly same set of items. Suppose ...
Nijin Narayanan's user avatar
6 votes
1 answer
1k views

Smoothing Function in Python

...
user3613886's user avatar
4 votes
2 answers
4k views

Getting the unique factors of a number recursively

I have written the below code to get the unique factors. Please offer suggestions for better results. ...
deep's user avatar
  • 143
0 votes
1 answer
94 views

Using Comprehensions to Handle a Large Dataset in Python 2.7

I have a Python 2.7.6 script parsing large files (~60MB to ~2GB) containing lines of the following format: componentA componentB < floating point value > My goal is to sum the floating point ...
skrrgwasme's user avatar
6 votes
1 answer
488 views

Python knapsack program

I have this data for the knapsack problem: List of product prices = MENU Most popular product count = MOST_POPULAR_COCKTAIL ...
lmasikl's user avatar
  • 109
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