Counterexamples to Claim that A = (10,1,1,10) for B = (10,1,1,10)?

In summary, the problem seems to be that the sequence B has to be a valid alternating pattern in order for the function max to work.
  • #1
SlurrerOfSpeech
141
11
I'm trying to solve a problem that amounts to:

Given b0, ..., bn-1 where1 <= bi, find the max of |a0 - a1| + |a1 - a2| + ... + |an-2 - an-1| where 1 <= ai <= bi.

I'm 100% confident that each ai is either 1 or bi.

I'm 90% confident that the elements a0, ..., an-1 are either

1, b0, 1, b1, ...,

or

b0, 1, b1, 1, ...

Are there any simple counterexamples?
 
Technology news on Phys.org
  • #2
Can you give a context for your question? Is this some intuitive problem or is it based on some concrete example that someone might already know about?
 
  • #3
SlurrerOfSpeech said:
Are there any simple counterexamples?

it's easy to see, that for all ai-1 and ai+1, ai has to be 1 or bi.
- if ai is smaller than both ai-1 and ai+1, setting it to 1 will make the sum bigger.
- if ai is biggger than both ai-1 and ai+1, setting it to bi will make the sum bigger.
- if ai is between ai-1 and ai+1 setting it to 1 or to bi
will make the sum bigger.
The only case where the last possibility doesn't work, is when one of the neigbours is 1 and the other >= b. In that case the maximum sum is the same whatever ai is.
You can force such a situation with a 1,2,3,1 sequence. a1 can be anything <=2.
A non-conforming sequence with a larger sum of differences isn't possible.
 
  • #4
jedishrfu said:
Can you give a context for your question? Is this some intuitive problem or is it based on some concrete example that someone might already know about?

An algorithms problem I'm trying to solve https://www.hackerrank.com/challenges/sherlock-and-cost

The solution I tried is essentially

X = [1, b0, 1, b1, ... ]
Y =[b0, 1, b1, 1, ... ]
max(diffs(X), diffs(Y)]

and was surprised that it didn't pass all test cases.
 
  • Like
Likes jedishrfu
  • #5
To get the maximum, all ai can be either 1 or bi, but it doesn't have to be an alternating pattern of 1s and bis.
B = (10,1,1,10) needs A = (10,1,1,10)
 

1. What is a counterexample?

A counterexample is an exception or instance that contradicts or disproves a claim or theory. It is used to demonstrate that a statement, idea, or argument is not universally true.

2. Why are counterexamples important in scientific research?

Counterexamples are important in scientific research because they challenge existing theories and help scientists refine their understanding of the world. They provide evidence that can lead to the development of new theories or the modification of existing ones.

3. How do you identify a counterexample?

To identify a counterexample, you need to carefully examine the claim or theory in question and try to find an instance or example that contradicts it. This can involve conducting experiments, collecting data, or analyzing existing evidence.

4. Can a counterexample completely disprove a claim?

Yes, a well-supported counterexample can completely disprove a claim. However, it is important to note that a single counterexample may not be enough to completely discredit a theory. Multiple counterexamples and further research may be necessary to fully reject a claim.

5. What should be done if a counterexample is found?

If a counterexample is found, it should be carefully evaluated and considered in the context of the claim or theory. Scientists should examine the evidence and determine if the counterexample is valid and if it has implications for the claim. If necessary, the claim may need to be revised or abandoned based on the counterexample.

Similar threads

  • Quantum Interpretations and Foundations
2
Replies
38
Views
4K
  • Programming and Computer Science
Replies
1
Views
2K
Replies
2
Views
2K
  • Special and General Relativity
Replies
30
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Programming and Computer Science
Replies
2
Views
2K
Replies
10
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
2K
Replies
6
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
885
Back
Top