output:
1
2
2[A-C]
3
3A
[4-6]
32[C-D]
50
51/1
51/2
[60-62]
200-2[E-H]
201C
201/21[P-S]
300
300A
301-2A
542/2[K-L]
583-1
583-585[D-E]
605
605[A-C]
800A
code output= merged: [1, 2, 2A, 2B, 2C, 3, 3A, [4-6], 32C, 32D, 50, 51/1, 51/2, [60-62], 200-2E, 200-2F, 200-2G, 200-2H, 201C, 201/21P, 201/21R, 201/21S, 300,300A,301-2A,542/2K, 542/2L,583-1, 583-585D, 583-585E, 605, 605A, 605B,605C 800A]
"51/1" ve "51/2" "51 / [1-2]" No need to edit it.
Martin Vashko wrote:
I still don't understand why "51/1" and "51/2" in the example weren't merged into "51/[1-2]". Did you make a mistake in your original post, or is it part of the requirement?
Junilu Lacar wrote:So how does 300A, 301B, 302C get merged? Would it be [300-301][A-C]?
Martin Vashko wrote:
Junilu Lacar wrote:So how does 300A, 301B, 302C get merged? Would it be [300-301][A-C]?
Assuming this is true, what would we do with this sequence: 300A, 300B, 300C, 301A, 301B, 301C, 302A, 302B, 302C?
Martin Vashko wrote:
Junilu Lacar wrote:So how does 300A, 301B, 302C get merged? Would it be [300-301][A-C]?
Assuming this is true, what would we do with this sequence: 300A, 300B, 300C, 301A, 301B, 301C, 302A, 302B, 302C?
Edit: and why not [300-302][A-C]?
There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:Two other quick questions:
1) are the letters always consequtive? Or can we have, say, 1A, 1C, 1Q?
2) are the letters always in alphabetic order, like 1A, 1B, 1C? Or is 1C, 1A, 1B possible?
Sorry if these questions are already answered, I might have missed them.
Junilu Lacar wrote:Piet, by my understanding,
1A, 1C, 1Q would not be merged
1C, 1A,1B ==> 1C, 1[A-B]
Piet Souris wrote:Two other quick questions:
1) are the letters always consequtive? Or can we have, say, 1A, 1C, 1Q?
2) are the letters always in alphabetic order, like 1A, 1B, 1C? Or is 1C, 1A, 1B possible?
Sorry if these questions are already answered, I might have missed them.
Carey Brown wrote:Or, as a regular expression: "(([0-9]+)([^a-zA-Z0-9]*))([a-zA-Z]+)".
Junilu Lacar wrote:I got better match results with the sample inputs that OP gave with this: (([0-9]+)([^0-9]*[^a-zA-Z]*))([a-zA-Z]?)
There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:I am experimenting with a TreeMap with a suitable Comparator. A bit clumsy right now, but this is how far I am.
I looked at the output of the code.
Close to what I want.
Piet Souris wrote:I am experimenting with a TreeMap with a suitable Comparator. A bit clumsy right now, but this is how far I am.
There are three kinds of actuaries: those who can count, and those who can't.
Carey Brown wrote:I don't understand how P, R, S is a sequence when it is missing the 'Q'.
Piet Souris wrote:hi Kiraz,
the map that I created was only meant to be an intermediate result. It was my intention to go on processing. My further ideas were:
create an enum
and have new new Class:
Now, I would have a method that processes my intermediate results in the map, and creates a List<FinalToken>. Supose you have this entry in the map:
Because of the empty char at the start of the list (coming from the Token 300 without any chars) I create two FinalTokens: with 300 and type JUST_A_NUMBER, and 300 with list [A, B, C], with type NUMBER_WITH_ChAR.
The last one will output the toString result: 300[A-C].
So I have a List<FinalToken>. My last step is to go from top to bottom, and when I encounter type JUST_A_NUMBER, I will check if the next couple of elements are also of type JUST_A_NUMBER and have consecutive ints. Then I will output the [300 - 350] form.
Well, sounds more complicated than it is (I hope), but I have not yet had time (or courage) to implement all this (well, I do have the enum).
This was what I had in mind. Wondering if others have come up with someting more simple.
Carey Brown wrote:I don't understand how P, R, S is a sequence when it is missing the 'Q'.
There are three kinds of actuaries: those who can count, and those who can't.
Don't get me started about those stupid light bulbs. |