Questions tagged [numeric-ranges]

22 questions
8
votes
1 answer

Python- How to make an if statement between x and y?

I've recently been breaching out to Python, as C++ is fun and all, but python seems kinda cool. I want to make Python do something as long as the input is between a certain number range. def main(): grade = float(input("“What’s your…
7
votes
6 answers

Regex to match 2-10, but not 99

I have a field on a form that takes the following values: -1, 2-10, 99 I have a business rule that's concerned with answers 2-10. I'm trying to write a regular expression that will match 2-10 but not 99, and I'm having trouble. The original…
peacedog
  • 1,415
  • 20
  • 32
6
votes
6 answers

Interpreting Number Ranges in Python

In a Pylons webapp, I need to take a string such as "<3, 45, 46, 48-51, 77" and create a list of ints (which are actually IDs of objects) to search on. Any suggestions on ways to do this? I'm new to Python, and I haven't found anything out there…
Eric the Red
  • 5,364
  • 11
  • 49
  • 63
3
votes
2 answers

Dynamically create ranges from numeric sequences

I have a table like the following: +----+-----+-----+ | ID | GRP | NR | +----+-----+-----+ | 1 | 1 | 101 | | 2 | 1 | 102 | | 3 | 1 | 103 | | 4 | 1 | 105 | | 5 | 1-2 | 106 | | 6 | 1-2 | 109 | | 7 | 1-2 | 110 | | 8 | 2 | 201 | | 9…
Felix Bayer
  • 363
  • 2
  • 11
3
votes
1 answer

How to index numeric fields and search them by range in Lucene.Net?

I'm looking for an efficient way to index and search numeric fields in Lucene.Net. Right now my need is for integer values only. I want to search by ranges of values (between x and y, more than x...). Right now I'm indexing the number as is and…
David Thibault
  • 8,638
  • 3
  • 37
  • 51
2
votes
1 answer

SoapUI GroovyScript assertion within (+ or - ) 0.05 of expected values

I currently have the following assertion script to check the value of three fields. import org.junit.Assert def response = messageExchange.getResponseContent() def xml = new XmlSlurper().parseText(response) def nodelist =…
Ross
  • 2,463
  • 5
  • 35
  • 91
2
votes
1 answer

Generate random number in given range from random bytes

There are similar questions, but most of them too language specific. I'm looking for a general solution. Given some way to produce k random bytes and a number n, I need to produce a random number in range 1...n (inclusive). What I've come up with so…
2
votes
2 answers

Adding Numeric Range Filtering to ActiveAdmin

Greetings and Happy Holidays 2015 -- I tried to add numeric range filtering per the excellent blog post by Boris Stall. I'm running: Rails 4.2.4 Ruby 2.2.3 ActiveAdmin 1.0.0pre2 I keep running into this error: Unable to find input class…
2
votes
2 answers

perl - convert string of numeric values/ranges to actual values

I'd like to convert a sting of the form 1,2,25-27,4,8,14,7-10 into a list of the actual values: 1,2,4,7,8,9,10,14,25,26,27. I've searched and found nothing that does this sort of expansion. Anyone aware of way to do this easily?
SecondGear
  • 1,093
  • 1
  • 12
  • 18
1
vote
2 answers

Optimizing code to map numbers 1 - 25 uniformly to 5 colors

I am currently learning JavaScript, and I made this code (and it works fine) but I know that there must be a way to automate this better. I'm little bit fuzzy on loops, but from what I know of them, I don't know that one could be used in this…
1
vote
1 answer

Detect if Integer is within multiple ranges of Integers efficiently

Let's say you have an integer n. And let's say you have a list of non-overlapping integer ranges, for example: 1-9 99-105 160-205 503-600 // many more thousands of ranges, etc .... I could very easily iterate over all of these and check if n is…
Landon
  • 4,088
  • 3
  • 28
  • 42
1
vote
2 answers

How to use an array to select a range of numbers and then the desired output?

For example, if I wanted to create a program that gives a person a discount based on how many items they have. If they were to purchase 0-5 items they do not get a discount. If they purchase 5-10 items they get a 5% discount, if they get 10-20…
Sabotenderizer
  • 187
  • 2
  • 7
  • 13
0
votes
3 answers

Numeric Ranges with a Regular Expression python

So I am working on a text analytics problem and I am trying to remove all the numbers between 0 and 999 with regular expression in Python. I have tried Regex Numeric Range Generator to get the regular expression but I didn't succed. I can only…
kawai
  • 7
  • 5
0
votes
1 answer

awk - print overlapping ranges

I'm afraid I haven't come across a direct way of doing this, although I tried adapting some provided solutions for similar scenarios (but not quite for what I need). Given this data: 1118 1120 1121 1124 1122 1127 1125 1126 1128 1133 1130 1135 1136…
one-liner
  • 791
  • 1
  • 9
  • 19
0
votes
0 answers

Pickle psycopg2 NumericRange

I'm trying to write some data to a cache of which some has been retrieved from a postgres db using psycopg2 and sqlalchemy. Some of them are NumericRange instances. Unfortunately, when I try to pickle the objects before writing them to the Redis…
orange
  • 7,755
  • 14
  • 75
  • 139
1
2