Click here to Skip to main content
15,887,746 members
Home / Discussions / Algorithms
   

Algorithms

 
AnswerRe: theory needed for a described algorithm Pin
Bernhard Hiller16-Mar-12 1:10
Bernhard Hiller16-Mar-12 1:10 
GeneralRe: theory needed for a described algorithm Pin
liquid_16-Mar-12 1:35
liquid_16-Mar-12 1:35 
AnswerRe: theory needed for a described algorithm Pin
Bernhard Hiller16-Mar-12 4:18
Bernhard Hiller16-Mar-12 4:18 
AnswerRe: theory needed for a described algorithm Pin
Luc Pattyn16-Mar-12 4:35
sitebuilderLuc Pattyn16-Mar-12 4:35 
GeneralRe: theory needed for a described algorithm Pin
liquid_16-Mar-12 10:05
liquid_16-Mar-12 10:05 
AnswerRe: theory needed for a described algorithm Pin
Luc Pattyn16-Mar-12 18:57
sitebuilderLuc Pattyn16-Mar-12 18:57 
GeneralRe: theory needed for a described algorithm Pin
Bernhard Hiller18-Mar-12 21:31
Bernhard Hiller18-Mar-12 21:31 
AnswerRe: theory needed for a described algorithm Pin
Skippums19-Apr-12 10:37
Skippums19-Apr-12 10:37 
So you know the following:

1. d ≤ v ≤ x1 - d/2

2. ∀xn, d/2 ≤ xn % v ≤ v - d/2

My dumb algorithm in C# would be (untested):

int FindV(List<int> x, int d) {
    int halfD = (d + 1) / 2;
    // Handle odd d by rounding up to the next even
    d = 2 * halfD;
    for (int v = x[0] - halfD; v >= d; --v) {
        int upper = v - halfD;
        bool solved = true;
        foreach (int xn in x) {
            int mod = xn % v;
            if (mod < halfD || upper < mod) {
                solved = false;
                break;
            }
        }
        if (solved) return v;
    }
    return -1;
}

Sounds like somebody's got a case of the Mondays

-Jeff

Generalcctv video sharing with static ip Pin
sanjib_sinha6-Mar-12 2:30
sanjib_sinha6-Mar-12 2:30 
GeneralRe: cctv video sharing with static ip Pin
Albert Holguin6-Mar-12 4:59
professionalAlbert Holguin6-Mar-12 4:59 
Questionaudio watermarking Pin
sepideh-gh5-Mar-12 4:32
sepideh-gh5-Mar-12 4:32 
AnswerRe: audio watermarking Pin
Richard Andrew x649-Apr-12 4:06
professionalRichard Andrew x649-Apr-12 4:06 
Questionattack codes Pin
sepideh-gh5-Mar-12 4:26
sepideh-gh5-Mar-12 4:26 
QuestionSuper2xSal, SuperEagle, hq2x algorithms Pin
2xSal24-Feb-12 10:28
2xSal24-Feb-12 10:28 
AnswerRe: Super2xSal, SuperEagle, hq2x algorithms Pin
Chris Losinger24-Feb-12 10:57
professionalChris Losinger24-Feb-12 10:57 
QuestionConvert between image file formats??? Pin
supernorb16-Feb-12 22:36
supernorb16-Feb-12 22:36 
AnswerRe: Convert between image file formats??? Pin
Jochen Arndt16-Feb-12 23:41
professionalJochen Arndt16-Feb-12 23:41 
AnswerRe: Convert between image file formats??? Pin
Alan Balkany21-Feb-12 4:11
Alan Balkany21-Feb-12 4:11 
AnswerRe: Convert between image file formats??? Pin
Chris Losinger21-Feb-12 10:50
professionalChris Losinger21-Feb-12 10:50 
QuestionConvert bits to bytes Pin
marca29214-Feb-12 20:15
marca29214-Feb-12 20:15 
AnswerRe: Convert bits to bytes Pin
Peter_in_278014-Feb-12 20:35
professionalPeter_in_278014-Feb-12 20:35 
QuestionOrdering (Poly) Lines Pin
Kyudos13-Feb-12 19:38
Kyudos13-Feb-12 19:38 
AnswerRe: Ordering (Poly) Lines Pin
Alan Balkany16-Feb-12 4:03
Alan Balkany16-Feb-12 4:03 
QuestionCan you do this with a convex hull? Pin
Kyudos12-Feb-12 12:40
Kyudos12-Feb-12 12:40 
AnswerRe: Can you do this with a convex hull? Pin
Kyudos12-Feb-12 14:13
Kyudos12-Feb-12 14:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.