I rephrased the question in a way that makes more sense to me and sketched this out.
pragma solidity 0.4.19;
contract Ranges {
address public owner;
uint public lowerLine;
uint public upperLine;
modifier onlyOwner {
require(msg.sender == owner);
_;
}
event LogNewLines(address sender, uint lower, uint upper);
function isValidRange(uint lower, uint upper) public pure returns(bool isIndeed) {
return lower > 0 && upper > lower;
}
function Ranges(uint lower, uint upper) public {
require(isValidRange(lower,upper));
owner = msg.sender;
lowerLine = lower;
upperLine = upper;
LogNewLines(msg.sender, lower, upper);
}
function isInRange(uint check) public view returns(bool isIndeed) {
return check >= lowerLine && check <= upperLine;
}
function setRange(uint lower, uint upper) public onlyOwner returns(bool success) {
require(isValidRange(lower,upper));
lowerLine = lower;
upperLine = upper;
LogNewLines(msg.sender, lower, upper);
return true;
}
}
Hope it helps.
UPDATE
Based on the comment below, I'm going to suggest that you invert responsibilities.
Relying on the contract to determine which range the number falls in is intuitive in a world of approximately unlimited CPU power. It will always involve some sort of search that will increase in cost, by recursion or interations, etc. Make the client do that.
Clients will already have sufficient information to figure it out for themselves based on the event log. That is to say, with knowledge of the current ranges, a client doesn't even need help from the contract. The contract's function is to protect the integrity of the application from wrong, fraudulent, invalid, etc. input.
So have the contract check the validity of client claims.
Consider:
function isInRange(uint rangeId, uint candidate) public view returns(isIndeed)
Hope it helps.