|
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
|
|
|
|
|
Any encryption algorithm that allowed you to determine the methods used by simply looking at the encrypted output would be pretty useless.
If someone is able to tell you categorically what the algorithm used was, please remember to avoid it like the plague.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Henry Minute wrote: Any encryption algorithm that allowed you to determine the methods used by simply looking at the encrypted output would be pretty useless.
Not necessarily. You may find, for instance, the letters are all uppercase (or all lower) with no double letter digraphs and that there is one letter of the alphabet missing (eg Q or Z) which could suggest the Playfair cipher.
And the playfair cipher was far from useless
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
Chris Maunder wrote: And the playfair cipher was far from useless
Before the advent of the modern computer that almost certainly would have been true with a long enough key, I doubt it is now though. With a short key I have seen puzzle freaks break it with just pencil and paper.
Admittedly modern Block Ciphers use similar techniques but again require computing power to even encrypt a message let alone break one.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
|
Yet another cheater wanders in tracking crap.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
http://projecteuler.net/index.php?section=problems[^]
The best part about the site is the different solutions available. Once you submit a correct answer, you'll be shown the solutions of others. I thought I was capable of writing optimal, bit-squeezed, minimal CPU/memory consuming code, until I solved some of the problems here and looked at the solutions of others. Life altering, especially if you are seeking to improve your coding logic and ability. Check it out.
ASP - AJAX is SEXY. PERIOD.
|
|
|
|
|
Yep. I discovered it last week. Here[^] are my first impressions.
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.
|
|
|
|
|
Have you seen the code that some of the folks write in Assembler? Amazing stuff!
ASP - AJAX is SEXY. PERIOD.
|
|
|
|
|
Yes, I noticed some assembly solutions, and several unfamiliar programming languages. So far I did everything using C#.
Long time ago, when processing power was much lower, I did several things in assembly too. Not any more, unless I need vector processing (SIMD, MMX, SSE and the like).
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.
|
|
|
|