|
first define "first"
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
|
Yes sorry had a bad time yesterday. Simply overhead this stuff.
Can happen.
Cheers
You have the thought that modern physics just relay on assumptions, that somehow depends on a smile of a cat, which isn’t there.( Albert Einstein)
|
|
|
|
|
No problem. It happens all the time. Have a great day
Eslam Afifi
|
|
|
|
|
Thanks
You too.
Cheers
You have the thought that modern physics just relay on assumptions, that somehow depends on a smile of a cat, which isn’t there.( Albert Einstein)
|
|
|
|
|
Why do you even need an algorithm for this?
If you have the pairs (A,B) and (C,D) (assuming the enddate is always after the startdate - if not just swap them)
return (A > C && A < D) || C < B;
works because:
two cases are handled:
1) A is after C, they only overlap if A is also before D otherwise (A,B) is completely after (C,D)
2) A is before C, they only overlap if C is somewhere before B otherwise (C,D) is completely after (A,B)
disclaimer: it was 2 AM when I wrote this, it could easily be complete crap. Sorry!
|
|
|
|
|
will am asking this question becuase i need to take care of my performance issue. taking into concideration
that there are many date intervals i should check and your code ( my old code ) is not good at that scenario regardin performance
|
|
|
|
|
I severely doubt there is a faster way. If, however, you are checking overlap on many dates at once (which I suspect you are, because you are having a performance issue with it), there is a better algorithm than a naive "O(n*n) tests" algorithm. I don't remember it now, but I'm quite sure it exists..
|
|
|
|
|
If you mean that you're checking more than 2 intervals at the same time you can sort them by start date ascending (complexity depends on the choosen sorting algorithm) then loop over them and check with the next interval for the next's start date < current's end date (O(n) complexity).
And you're welcome.
Eslam Afifi
|
|
|
|
|
bool overlap=(start2>=start1 && start2<end1) ||
(start1>=start2 && start1<end2);
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
As far as I recall, I make only two comparisons: ( Start1 <= End2 ) && ( End1 >= Start2 )
I believe that properly handles all the possible situations.
|
|
|
|
|
That looks great.
However I would rewrite it as ( Start1 <= End2 ) && (Start2 <= End1 ) to stress symmetry, which should be present in the expression.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Tomahto!
|
|
|
|
|
Nah. It is tomato, you do know that.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Well Yes I think this covers all possible cases , anyways am going to implement it again in my work since it is stated as a buggggggggggggg , and i will reply back for all of you if there is any scenario that this cases doesnt cover,
|
|
|
|
|
Hi,
you can trust PIEBALD to give good advise.
and you can verify for yourself there are only five cases, which you can easily check by hand.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I thought there were 6 cases?
0) S1 E1 S2 E2 (1 entirely before 2)
1) S1 S2 E1 E2 (1 halfway before 2, partly overlapping)
2) S2 S1 E1 E2 (1 contained within 2)
3) S2 S1 E2 E1 (1 partly contained within 2, partly extending beyond it)
4) S2 E2 S1 E1 (1 entirely after 2)
5) S1 S2 E2 E1 (case 2 inverted - 2 contained within 1)
Did I do something wrong?
|
|
|
|
|
That is a valid stance.
However if you call the larger one S1-E1 then your #2 cannot occur. And the 5 remaining cases are all really distinct.
That is an advantage of symmetric problems given symmetric solutions: you tend to get fewer cases.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Ah yes that's true thanks
edit: no wait, that's an extra comparison, cheaters
So it's still 3, unless you already known they are ordered.. Last modified: 42hrs 13mins after originally posted --
|
|
|
|
|
Hello,
An encryption program produces the following output for a text input
HlNmVaGYVPE!
nNCDp6cR19bsiplYwcVklA!!
Zlv417YGpmY!
just seeing if it is possible to know what kind of encryption is used to encrypt the data ?
modified on Monday, July 6, 2009 4:15 PM
|
|
|
|
|
Sorry, a couple of Non-Disclosure Agreements prevent me from answering that.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Looks like a substitution cipher to me (possibly polyalphabetic), seeing as how they are all printable characters - it would just be too much coincidence if a good encryption algorithm did this.
I would have said base64, but I checked it and the base64 reverse of this is just gibberish. It does decode though, that can still be coincidence but I'd keep the option open.
But anyway, I'd need more data to be sure of anything. Can you get more data? And more importantly, can you encrypt arbitrary text with it? A good ol' known-plaintext attack works great on substitution ciphers - and also on finding out whether it even is one.
|
|
|
|
|
..why?
(Just being curious)
I are troll
|
|
|
|
|
I could tell, but then I would have to shot you ...
|
|
|
|
|
That looks like TM32 to me. TM32 is produced by Technical Mumbling of a 32 year old.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|