#### Discussion

Scans `aString` for two integers which are used as the location and
length values, in that order, to create an`NSRange` struct.
If `aString` only contains a single integer, it is used as the location
value. If `aString` does not contain any integers, this function returns
an `NSRange` struct whose location and length values are both 0.

A Foldy but a Goody
Problem Description
Suppose you have a strip of paper and are given instructions to fold the
paper in one of two ways: an upper fold, where the right end of the
paper is brought over to the top of the left end; and a lower fold,
where the right end of the paper is brought below the left end. The
diagram below illustrates both types of folds.

#### Declaration

SWIFT

`func NSRangeFromString(_ aString`String)
-> NSRange

OBJECTIVE-C

`NSRange NSRangeFromString ( NSString *aString );`

If the left end of the folded strip is placed at the origin and the
first right angle is at , it is natural to ask the questions: Where will
the second right angle be located? The third right angle? Where will the
other end of the strip be located? Well, that’s for us to know and you
to figure out.

Now, after meticulously folding the strip several times, you are asked
to unfold it by making a 90 degree angle at each crease. The example
below shows the result of an upper fold, followed by a lower fold and
then an unfolding.

#### Availability

Available in iOS 2.0 and later.

今天发现一个由 NSRangeFromString

``````NSString *str1 = @"abcdef";
NSString *str2 = @"1-105";
NSString *str3 = @"13";
NSString *str4 = @"13 34";
NSString *str5 = @"15 32 77";
NSRange range = NSRangeFromString(str1);
NSLog(@"\nlocation:%ld  length:%ld", range.location, range.length);
//location:0  length:0

range = NSRangeFromString(str2);
NSLog(@"\nlocation:%ld  length:%ld", range.location, range.length);
//location:1  length:105

range = NSRangeFromString(str3);
NSLog(@"\nlocation:%ld  length:%ld", range.location, range.length);
//location:13  length:0

range = NSRangeFromString(str4);
NSLog(@"\nlocation:%ld  length:%ld", range.location, range.length);
//location:13  length:34

range = NSRangeFromString(str5);
NSLog(@"\nlocation:%ld  length:%ld", range.location, range.length);
//location:15  length:32
``````

Input
The input file will contain multiple test cases. The first line of the
file will contain a single integer indicating the number of test cases.
Each case will consist of a string of letters U and L indicating a
series of upper and lower folds followed by an integer m. The length of
the string will be between 1 and 30, inclusive. The value of m
identifies a position on the paper. A value of m = 0 indicates the left
end (at location . If there are n folds, then a value of m = 2n
indicates the right end of the strip. Any value for m between these two
extremes represents one of the right angles; m = 1 indicates the first
right angle, and so on.

Returns a range from a textual representation.

Output
For each test case, output a single line of the form indicating the
location of the right angle (or end point) specified by the problem. You
should assume that if there are n folds in the test case, the length of
the string is 2n so that the distance between creases is 1 unit long.

Sample Output

Sample Input
3
UL 4
UL 3
LLUL 13