# tagged [range]

#### What's the most efficient way to test if two ranges overlap?

What's the most efficient way to test if two ranges overlap? Given two inclusive ranges [x1:x2] and [y1:y2], where `x1 ≤ x2` and `y1 ≤ y2`, what is the most efficient way to test whether there is any ...

- Modified
- 17 Nov at 09:44

#### How to loop backwards in python?

How to loop backwards in python? I'm talking about doing something like: I can think of some ways to do so in python (creating a list of `range(1,n+1)` and reverse it, using `while` and `--i`, ...) bu...

#### Making a list of evenly spaced numbers in a certain range in python

Making a list of evenly spaced numbers in a certain range in python What is a pythonic way of making list of arbitrary length containing evenly spaced numbers (not just whole integers) between given b...

#### NameError: global name 'xrange' is not defined in Python 3

NameError: global name 'xrange' is not defined in Python 3 I am getting an error when running a python program: ``` Traceback (most recent call last): File "C:\Program Files (x86)\Wing IDE 101 4.1\sr...

- Modified
- 28 Jun at 21:13

#### How to scale down a range of numbers with a known min and max value

How to scale down a range of numbers with a known min and max value So I am trying to figure out how to take a range of numbers and scale the values down to fit a range. The reason for wanting to do t...

#### Python range() and zip() object type

Python range() and zip() object type I understand how functions like `range()` and `zip()` can be used in a for loop. However I expected `range()` to output a list - much like `seq` in the unix shell....

- Modified
- 27 Aug at 23:24

#### Iterate a certain number of times without storing the iteration number anywhere

Iterate a certain number of times without storing the iteration number anywhere I was wondering if it is possible to perform a certain number of operations without storing the loop iteration number an...

#### Generate random numbers using C++11 random library

Generate random numbers using C++11 random library As the title suggests, I am trying to figure out a way of generating random numbers using the new C++11 `` library. I have tried it with this code: T...

#### Group by range using linq

Group by range using linq how can we use groupped ranges for equal or greater than ? ``` var data = new[] { new { Id = 0, Price = 2 }, new { Id = 1, Price = 10 }, new { Id = 2, Price = 30 }, ...

#### Is it more efficient to perform a range check by casting to uint instead of checking for negative values?

Is it more efficient to perform a range check by casting to uint instead of checking for negative values? I stumbled upon this piece of code in .NET's [List source code](http://referencesource.microso...

- Modified
- 30 Mar at 10:16

#### Get an enumerable range for a given min and max with a given number of steps

Get an enumerable range for a given min and max with a given number of steps I am familiar with the [Enumerable.Range](http://msdn.microsoft.com/en-us/library/system.linq.enumerable.range%28v=vs.100%2...

#### Process a list with a loop, taking 100 elements each time and automatically less than 100 at the end of the list

Process a list with a loop, taking 100 elements each time and automatically less than 100 at the end of the list Is there a way to use a loop that takes the first 100 items in a big list, does somethi...

#### Creating an Array from a Range in VBA

Creating an Array from a Range in VBA I'm having a seemingly basic problem but can't find any resources addressing it. Simply put, I just want to load the contents of a Range of cells (all one column)...

#### How to select values within a provided index range from a List using LINQ

How to select values within a provided index range from a List using LINQ I am a LINQ newbie trying to use it to acheive the following: I have a list of ints:- Now, I want to compare the sum of the fi...

#### finding multiples of a number in Python

finding multiples of a number in Python I'm trying to write a code that lets me find the first few multiples of a number. This is one of my attempts: I figured out that, by putting `for m in (n, m):`,...

#### How does String substring work in Swift

How does String substring work in Swift I've been updating some of my old code and answers with Swift 3 but when I got to Swift Strings and Indexing with substrings things got confusing. Specifically ...

#### Subscript out of range error in this Excel VBA script

Subscript out of range error in this Excel VBA script I would like to copy data from a CSV file into an Excel worksheet. There are 11 .csv files. So far I have this (it is a modified version from a pr...

#### Is there a need for range(len(a))?

Is there a need for range(len(a))? One frequently finds expressions of this type in python questions on SO. Either for just accessing all items of the iterable Which is just a clumbersome way of writi...

#### How to set the subplot axis range

How to set the subplot axis range How can I set the y axis range of the second subplot to e.g. [0,1000] ? The FFT plot of my data (a column in a text file) results in a (inf.?) spike so that the actua...

- Modified
- 15 Sep at 04:44

#### What's a good, generic algorithm for collapsing a set of potentially-overlapping ranges?

What's a good, generic algorithm for collapsing a set of potentially-overlapping ranges? I have a method that gets a number of objects of this class In my case `T` is `DateTime`, but lets use `int` fo...

#### Why is Enumerable.Range faster than a direct yield loop?

Why is Enumerable.Range faster than a direct yield loop? The code below is checking performance of three different ways to do same solution. ``` public static void Main(string[] args) { // for l...

- Modified
- 25 Aug at 15:14

#### How to select a range of values in a pandas dataframe column?

How to select a range of values in a pandas dataframe column? ``` import pandas as pd import numpy as np data = 'filename.csv' df = pd.DataFrame(data) df one two three four five a 0.469112 -...

- Modified
- 10 Aug at 22:28

#### Random number in range with equal probability

Random number in range with equal probability This might be more Math related than C#, but I need a C# solution so I'm putting it here. My question is about the probability of random number generators...

#### How does one make random number between range for arc4random_uniform()?

How does one make random number between range for arc4random_uniform()? so my goal in this codebit is to randomly roll two dice and as we all know your regular die only has 6 sides so I imported Found...

- Modified
- 1 Oct at 14:37