ranges

What do [0, rows) and [1, rows] mean? more specifically [ and )

I understand that it's from 0 to rows and from 1 to rows, but which is including and which is excluding? ...

C#: Algorithm for creating random evenly distributed potentially overlapping ranges

Was thinking I could test the various answers I got in my question about an algorithm for collapsing ranges. So I was thinking I should create a method that creates a whole bunch of ranges and see how the various methods handles it. But when it comes to generating random stuff I am not very good. I created something like this: pri...

Splitting up an interval in weeks in Postgres

Here goes a yet another SQL question about dates… I'm building a calendaring application using PHP and Postgres that would display events spanning days, weeks or possibly months. Each event has a start date and an end date, and selecting them by range is not a problem; however, it would be useful for me if Postgres could split multi-wee...

Streamline Javascript to calculate ranges

I have a bit of javascript that I am using to calculate the y-scale of a graph. I need to adjust the scale according to the value. This works but seems really verbose. Is there a more streamlined way to do this? if (maxValue <= 20000){ chartMaxY = 20000 } if (maxValue <= 10000){ chartMaxY = 10000 } if (maxValue <= 5000){ chartMax...

What's the point (no-pun) of XPointer ranges?

XPointer spec talks about ranges that, as far as I understand, mean you can target two nodes in an XML document and get everything in between them or something. Do people really use this? What is it useful for? ...

Calculating revenue share at different tiers

I'm trying to write a function that can calculate revenue at different tiered levels... For example you sell $10000 worth of widgets. Any earnings from $1 - $999 we take 50%, $1000 - $4999 we take 25%, $5000 - $9999 we take 10%, $10000 - $19999 5%. The percentage is not taken based on the final value. So if you earned $10000 you don't ...

problem with two key ranges in couchdb

I'm having problem getting the right results in my coordinate system. To explain my system, I have this simple database that have x_axis, y_axis and name columns. I don't need to get all the data, I just need to display some part of it. For example, I have a coordinate system that have 10:10(meaning from x_axis -10 to 10 and from y_ax...

Show range of numbers based on thousands of records

I have 15,000 numbers ranging between 1000-8000. Each number is assigned to one of six categories and subcategories, in some cases there are overlaps. Sample data: value cat1 cat2 2333 WHITE A 2334 ORANGE B 2335 ORANGE A 2335 WHITE B 2336 ORANGE A 2336 WHITE B 2336 RED C 2337 RED A 2338 RED A 2...

Converting sets of integers into ranges

What's the most idiomatic way to convert a set of integers into a set of ranges? E.g. given the set {0, 1, 2, 3, 4, 7, 8, 9, 11} I want to get { {0,4}, {7,9}, {11,11} }. Let's say we are converting from std::set<int> into std::vector<std::pair<int, int>>. I treat Ranges as inclusive on both sides, since it's more convenient in my cas...

Ranged integers in .NET (or C#)

Am I being blind, or does the .NET framework not provide any kind of ranged integer class? That is, a type that would prevent you setting a value outside some given bounds that are not the full range of the basic data type. For example, an integer type that would restrict its values to between 1 and 100. Showing my age here, but back in ...

Convert Excel Range to ADO.NET DataSet or DataTable, etc.

I have an Excel spreadsheet that will sit out on a network share drive. It needs to be accessed by my Winforms C# 3.0 application (many users could be using the app and hitting this spreadsheet at the same time). There is a lot of data on one worksheet. This data is broken out into areas that I have named as ranges. I need to be able...

Comparing two date ranges within the same table

I have a table with sales per store as follows: SQL> select * from sales; ID ID_STORE DATE TOTAL ---------- -------- ---------- ------------------------------- 1 1 2010-01-01 500.00 2 1 2010-01-02 185.00 3 1 2010-01-03 135.00 4 1 2009-01-01 165.00...

Is it possible to return a list of all ranges from all worksheets in an Excel 2002 workbook?

Hello all. I want to extract "special" data from an Excel 2002 (client requirement, cannot change) workbook and worksheets contained therein. I have classified ranges in this "special" data category. I would like to acquire a list of all ranges in, ideally, all worksheets in a workbook. The attributes I'm interested in are the range ...

Passing Index Ranges

I'm currently trying to figure out how to pass an index range as a string, but so far have not been having any luck. Here is an example of what I'm trying to do: pos = %w{1 2..4} values = %{x cat} test_string = "This is a test with a string." test_string[pos[1]] = values[1] I know I could just break it down with split or something s...

Is there a method in java that can take 2 numbers and give you the numbers that are in between them(Ranges)?

I read in a file with a few numbers using a scanner, and then split them using the split method. My main issue is if there is a method that can just give me ranges, probably in the math class. The numbers are currently in an array, and I wanna move those numbers and there ranges into a two-dimensional array. Could anyone give me some tip...

Getting relative addresses in Excel Interop

In C# programs using the Excel Interop library, the Range.get_Address(...) method seems to return a relative address only if R1C1 format is specified. Does the library provide a simple way to get relative A1-style addresses? ...

get a range of objects with binary search

I have some data like this: ID Value 1 AAA 1 ABC 2 dasd 2 dsfdsf 2 dsfsd 3 df 3 dwqef they are objects(not plain text). and i want to get all objects with the ID = 2. I can do a binary binary search and get the index 3,but how can i get (2 and 4) is there any efficient algorithm? the real problem has l...

Need help with a SQL query selecting date ranges from a table of period quarters

Hi. I have a table called Periods that looks like this PeriodID | PeriodYear | PeriodQuarter 7 | 2009 | 1 8 | 2009 | 2 9 | 2009 | 3 10 | 2009 | 4 11 | 2010 | 1 12 | 2010 | 2 Each row in the table represents 1 of the 4 quarters of the year (like 3-monthly school terms). E.g. The first row represents Period 1 of 2009 (i.e. the dat...

Need help on designing an algorithm that outputs a time period that can be used for sampling signals within a given range

I need to count frequencies in the 0.1Hz to 1.99GHz range. At my disposal is a 16bit counter with an additional overflow bit, a timer accurate to 1uS, frequency dividers and a microcontroller to glue all these together. The logic I have decided to use is so: Condition the input signal to give a 50% duty cycle 5Vpp square wave Feed th...

Calling 'scalar' on the results of the range operator (..) in Perl

So, I believe this has something to do with the difference between arrays and lists, but I don't understand what's going on here. Can anyone explain how and why Perl treats an expression like (1..4) differently than (1, 2, 3, 4) and @{[1..4]}? $ perl -de1 Loading DB routines from perl5db.pl version 1.31 Editor support available. Enter...