Algorithm for dividing a range into ranges and then finding which range a number belongs to


  • a minimum
  • a maximum
  • number of ranges
  • a value between minimum and maximum

I’m trying to come up with a method, or two, which would calculate which range the provided value belongs to.

For min=1, max = 10, number of ranges=5 the ranges would be [1,2],[3,4],[5,6],[7,8],[9-10]

The other method would behave like shown below:

  • method(1)->[1-2]
  • method(2)->[1-2]
  • method(3)->[3-4]
  • method(4)->[3-4]
  • method(5)->[5-6]
  • method(6)->[5-6]
  • method(7)->[7-8]
  • method(8)->[7-8]
  • method(9)->[9-10]
  • method(10)->[9-10]

This would be used for generating a legend for a map where the size of the marker depends on the range a value belongs to.

I wonder if there is a nice algorithmic solution for this.

The numbers I work with are integers.


Another example:

For min=1, max = 3, number of ranges=2 the ranges would be

a) [1-2],[3-3]


b) [1-1],[2-3]

The other method would behave like shown below:


  • method(1)->[1-2]
  • method(2)->[1-2]
  • method(3)->[3-3]

or b)

  • method(1)->[1-1]
  • method(2)->[2-3]
  • method(3)->[2-3]

I don’t have a preference for a) or b).

If alghorithm solves NP problem, for what f(n) can we claim that R belongs to TIME(f(n))?

This is my problem:

Suppose that for the problem R belongs to NP the algorithm of solution check M(x,y) runs in time O(n^3) and uses additional information y, which is long ≤5 log n bits. For what f(n) can we claim that R belongs to TIME(f(n))?

I have no idea how can I know what must to be f(n) that R belongs to TIME(f(n)). Every suggestions are very welcome!

Excel : Summation of data which belongs to certain id

This is my first post in stack exchange. please bear with me and I accept any advice for questioning ethic.

It is easier to illustrate the problem based on the following example:

I have 2 sheets : mapping and data.

1. This Mapping sheet contains a mapping table between a country name and the corresponding ID

2. This table (from Data sheet) contains the country name with the corresponding GDP

The objective is to create a summary table which maps the group id with the SUM of GDP in a seperate sheet

I tried to use the SUM IFS formula as recommended here. They propose the following formula based on their own example.


However, the challenge arises due to 2 reasons:

  1. I cannot list down the ID in an array form as I have many ID variations. Also, the actual ID consists of both numbers and alphabets.
  2. I must follow a guideline not to merge the tables into a single sheet.

Thank you in advance!

Could we always find a curve on the manifold whose tangent vector always belongs to a linear subspace?

Suppose we have a smooth manifold $ M$ and the tangent space of every point $ x \in M$ has non-empty intersection with a given linear subspace. Could we find a curve on $ M$ such that the tangent vector of point on thus curve always belongs to this linear subspace?

$ \textbf{My attempt:}$ If the dimension for the linear subspace is one or two, I think I can find the curve. But I don’t know if the dimension is bigger than two?

I will appreciate for any useful answers and comments

If $f$ belongs to $M^{+} $ and $c \ge 0$ then $cf$ belongs to $M^{+}$ and $ \int cf = c\int f$

If $ f$ belongs to $ M^{+} $ and $ c \ge 0$ then $ cf$ belongs to $ M^{+}$ and $ \int cf = c\int f$ .

I need to proove that, using the following observation:

if $ f\in M^{+}$ and $ c>0 $ , then the mapping $ \varphi \rightarrow \psi = c\varphi$ is a one-toone mapping between simple function $ \varphi \in M^{+}$ with $ \varphi \le f $ and simple functions $ \varphi$ in $ M^{+} $ with $ \psi \le cf $ .

I know that this question is already answer here:One-to-one mapping of simple functions $ \phi \to \psi = c\,\phi$ implies $ \int cf\,d\mu = c \int f\,d\mu$ ?

But I can’t follow the verbal explanation.

My original idea was to proove $ $ c \int f \le \int cf \le c\int f $ $ But I can’t… some idea?