g | x | w | all
Bytes Lang Time Link
019Uiua 0.12.0dev.1240604T155258ZRomanPro
318Acc!!240524T123003ZMukundan
007Vyxal220705T034825ZnaffetS
062R220616T184143Zpajonk
010Japt171122T084542ZShaggy
063Haskell171122T191727Zcolossus
nanC# .NET Core171126T002515ZAyb4btu
090JavaScript ES6171122T101520Zedc65
009Brachylog v2171124T221536Zuser7624
064dc171123T115105ZR. Kap
011Pyth171122T064447ZMr. Xcod
009Husk171122T141607ZMr. Xcod
060Python 2171122T064909ZColera S
008Jelly171122T150007ZErik the
054Ruby171122T080136ZG B
046J171122T115252ZGalen Iv
013MATL171122T115854ZGiuseppe
069Haskell171122T112633ZLaikoni
008Jelly171122T080611ZDELETE_M
00805AB1E171122T065404ZEmigna
078Python 2171122T082356ZChas Bro
050Wolfram Language Mathematica171122T074850ZJungHwan
147Python 2171122T063918ZNeil

Uiua 0.12.0-dev.1, 19 bytes

\+⊂⊢:▽÷,⟜⍜⌵/↧≡/-◫2.

Try it out!

Acc!!, 318 bytes

Count n while 1 {
_+N%8*8^n
Count i while 0^(_/8^n) {
_*n^n
Count i while n-i {
_+_/n^n/8^i%2*n^(_%n+1)+_/n^n/8^i%4/2
}
((_/n^2-_/n)+0^((_/n^(_%n)%n-_/n^(_%n-1)%n)/(_/n^2%n-_/n%n))*(_/n^(_%n)-_/n^(_%n-1)-_/n^2+_/n))%n+_/n^(_%n)%n*n+_/n%n*n^2
Count i while (_/n-_/n^2+_%n)%n {
Write 49)*(_/n^2%n
Write 9
_+_%n*n^2
}
}
}

Try it online!

Takes input as a newline-separated unary array and outputs a tab-separated unary array.

Explanation

# Format of accumulator:
#   input:
#     + buffer
#   parsing:
#     + buffer*n^n
#     + arr[0]*n + arr[1]*n^2 + ...   # supports upto n - 1 elements
#     + len(arr)
#   print:
#     + curr*n^2
#     + end*n
#     + diff
#
# NOTE: Each element in 'arr' is stored as one more than its actual value.

Count n while 1 {
  _+N%4*4^n  # buffer[n] = getchar()%8

  # if buffer[n] == '\0':
  Count i while 0^(_/4^n) {
    # Convert accumulator to parsing type
    _*n^n

    # Loop to parse into arr
    Count i while n-i {
      # _
      # + n^(_%n+1)      # arr[len(arr)] += 1
      # + _/n^n/4^i%4/2  # len(arr) = buffer[i] == '\n'
      _+n^(_%n+1)+_/n^n/4^i%4/2
    }

    # Convert accumulator to print type
    #  _/n%n*n^2        # curr = arr[0]
    #  + _/n^(_%n)%n*n  # end  = arr[len(arr) - 1]
    #  + ...            # diff = ((arr[len(arr) - 1] - arr[len(arr) - 2]) or (arr[1] - arr[0])) % n  # chosen based on which is closer to zero
    _/n%n*n^2+_/n^(_%n)%n*n+((_/n^2-_/n)+0^((_/n^(_%n)%n-_/n^(_%n-1)%n)/(_/n^2%n-_/n%n))*(_/n^(_%n)-_/n^(_%n-1)-_/n^2+_/n))%n

    # while curr != end + diff: 
    Count i while (_/n-_/n^2+_%n)%n {
      Write 49)*(_/n^2%n-1    # Print '1' (curr % n - 1) times
      Write 9                 # Print '\t'
      _+_%n*n^2               # curr += diff
    }
  }
}

Vyxal, 7 bytes

ḣtṡ?¯ġḞ

Try it Online!

R, 62 bytes

function(x)seq(x[1],tail(x,1),min(abs(d<-diff(x)))*sign(d[1]))

Try it online!

Japt, 12 10 bytes

ÌõUÎUäa rm

Try it

ÌõUÎUäa rm     :Implicit input of array U
Ì              :Last element
  UÎ           :First element
 õ             :Range [first,last] with step size
    Uä         :  Consecutive pairs of U
      a        :    Reduced by absolute difference
        r      :  Reduce by
         m     :    Minimum

Haskell, 63 bytes

f(a:b:c)|s<-[a,b..last c],all(`elem`s)c=s
f a=r$f$r a
r=reverse

Try it online!

Basically works by trying to build the result from the front and, if that fails, from the back. This uses the fact that the first and last members of the input will always be correct, the fact that deleted members have to be consecutive, and the fact that there will always be at least three items in the input. All I have to do is assume that the second or second-to-last members are accurate and check if it works. Luckily Haskell has really beautiful syntax for creating arithmetic series.

EDIT: thanks to @xnor for pointing out a bug and providing a solution!

C# (.NET Core), 167+13=180 145+13=158 bytes

a=>{int x=a[1]-a[0],y=a[2]-a[1],d=x*x<y*y?x:y,s=Math.Abs((a[a.Length-1]-a[0])/d),i=0,j=a[0];var r=new int[s+1];for(;i<=s;j+=d)r[i++]=j;return r;}

Try it online!

+13 for using System;

Surprisingly, this challenge had more nuance that I initially anticipated.

Acknowledgements

-22 bytes saved due to some neat simplifications from @DLosc.

DeGolfed

a=>{
    int x = a[1]-a[0],        // difference between first and second numbers
        y = a[2]-a[1],        // difference between second to last and last numbers
        d = x*x < y*y? x : y, // smallest absolute value difference
        s = Math.Abs((a[a.Length-1] - a[0]) / d), // number of steps in the reconstructed sequence (not the number of elements)
        i = 0,                // step position
        j = a[0];             // next number in reconstructed sequence

    var r = new int[s+1];
    
    // reconstruct the sequence
    for(; i <= s; j+=d)
        r[i++]=j;

    return r;
}

JavaScript (ES6), 92 90

Edit 2 bytes saved thx Arnauld

Easy, as it is enough to check the differences between the first two and the last two. But still unbelievably long.

s=>(e=(z=s.pop(a=s[0]))-s.pop(d=s[1]-a),[...Array((z-(a-=d=e*e>d*d?d:e))/d)].map(_=>a+=d))

Less golfed

s=>{
  a =s[0]
  b =s[1]
  z = s.pop()
  y = s.pop()
  d = b-a
  e = z-y
  d = e*e>d*d?d:e  
  n = (z-a)/d+1
  return [...Array(n)].map((_,i) => a + i*d)
}

Test

var F=
s=>(e=(z=s.pop(a=s[0]))-s.pop(d=s[1]-a),[...Array((z-(a-=d=e*e>d*d?d:e))/d)].map(_=>a+=d))

var test=`In: 2 5 8 14 17 Out: 2 5 8 11 14 17
In: 2 5 17 Out: 2 5 8 11 14 17
In: 2 14 17 Out: 2 5 8 11 14 17
In: 21 9 6 3 Out: 21 18 15 12 9 6 3
In: 10 9 5 Out: 10 9 8 7 6 5
In: 1 10 91 100 Out: 1 10 19 28 37 46 55 64 73 82 91 100`.split`\n`
.map(r=>r.split`Out`.map(x=>x.match(/\d+/g)))

test.forEach(([i,k])=>{
  var o=F(i.slice(0))
  var ok = o+''==k
  console.log(ok?'OK':'KO',i+' => '+o)
})

Brachylog v2, 9 bytes

⊆.s₂ᵇ-ᵐ=∧

Try it online!

This is a function submission. The Brachylog interpreter can be made to evaluate a function as though it were a full program by giving it Z as a command line argument; in this case, the input is specified in the format, e.g., [1, 2, 4] and the output is returned in a similar format, e.g. Z = [1, 2, 3, 4]. (Of course, for a function submission, the input and output aren't in any format at all; they're just lists.)

This actually solves a harder problem than the one the OP asked for: it works out the shortest arithmetic sequence of integers containing the specified values in the specified order, regardless of whether the deletions are consecutive or not. Because it uses brute force, it can be very slow if many values are deleted.

Explanation

The program has three main parts.

finds a supersequence of the input (i.e. a sequence that has the input as a subsequence). When there's more than one possible output from a Brachylog program, the output chosen is the first output in tiebreak order, and the tiebreak order is determined by the first command in the program that has an opinion on it; in this case, specifies an order that favours short outputs over long ones. So the output we'll get will be the shortest supersequence of the input that obeys the restrictions in the rest of the program.

. is used to output the value it sees as input (i.e. the supersequence in this case), but also assert that a specific condition holds on it. In other words, we're outputting the shortest supersequence that obeys a specific condition (and ignoring any intermediate results used to see if it obeys the condition).

Finally, we have s₂ᵇ-ᵐ =, i.e. "all the deltas of the sequence are equal", the condition we're applying to the output. (The return value from this is a list of deltas, rather than the supersequence itself, which is why we need the . to ensure that the right thing is output.)

Brachylog is held back here by not having any builtins that can handle calculation of deltas, applying an operation to overlapping pairs from a list, or the like. Instead, we have to say what we mean explicitly: s₂ᵇ finds all () substrings (s) of length 2 () (the use of is required to keep a link between unknowns in the substrings and in the supersequence; the more commonly used would break this link). Then -ᵐ does a subtraction on each of these pairs to produce a delta. It's annoying to have to write out five bytes s₂ᵇ-ᵐ for something that most modern golfing languages have a builtin for, but that's the way that codegolf goes sometimes, I guess.

dc, 64 bytes

?dsx[ksE0_1]sg[scdlcr-d2^vdK>gK0=g+sqz1<l]dslx[pdlE+dlx!=Z]dsZxp

Try it online!

Pyth, 11 bytes

%hS.+SQ}hQe

Try it here!

Thanks to Steven H. for saving a byte!

Pyth, 12 bytes

%.aiF.+Q}hQe

Try it here!

How it works

%.aiF.+Q}hQe ~ Full program.

     .+Q     ~ Get the deltas.
   iF        ~ Reduce by GCD.
 .a          ~ Absolute value.
%            ~ Modular. Get every nth element of...
        }    ~ The inclusive numeric range between...
         hQ  ~ The first element, and...
           e ~ The last element.

Husk, 9 bytes

m←C▼Ẋ≠⁰…⁰

Try it online!

Thanks a lot to H.PWiz for halving the byte count, by pointing that applying on a list rangifies it!...

Python 2, 104 97 89 83 71 67 60 bytes

Thanks to Chas Brown for saving 4 bytes.
Thanks to ovs for saving 7 bytes.

Input the list by arguments.

lambda a,b,*c:range(a,c[-1],min(b-a,c[0]-b,key=abs))+[c[-1]]

Try it online!

Explanation:

Since the removed are consecutive, it is enough to check the differences between two pairs of consecutive elements.

Jelly, 8 bytes

ṂrṀmILÞṪ

Try it online!

Ruby, 65 62 55 54 bytes

->l{a,*,b,c=l;[*a.step(c,[l[1]-a,c-b].min_by(&:abs))]}

Try it online!

-1 byte thanks to Justin Mariner

J, 49, 47 46 bytes

(0-[:<./2|@-/\]){.@[&]\({.<.{:)+[:i.{:(+*)@-{.

Inspired by Emigna's solution.

How it works:

 (0-[:<./2|@-/\]){.@[&]\({.<.{:)+[:i.{:(+*)@-{. - fork of 3 verbs

                        ({.<.{:)+[:i.{:(+*)@-{. - generates a list in the entire range of values
                                     {:     -{. - last minus first element  
                                       (+*)@    - adds the signum of the difference
                                 [:i.           - makes a list 
                       ({.<.{:)                 - the smallest of first and last elements                                     
                               +                - adds the offset to the list (translates all elements according to the first one)

 (0-[:<./2|@-/\])                               - finds the step
         2|@-/\]                                - the absolute differences between all consecutive elements
    [:<./                                       - the smallest one
  0-                                            - negate (for splitting)

                 {.@[&]\                        - splits the list from the right verb into left verb's result sublists and takes their first elements

Try it online!

MATL, 13 bytes

1)0GdYkG0)3$:

Try it online!

Explanation:

Consider the example input [2 14 17]:
           # implicit input, STACK: [[2 14 17]]
1)         # push 1, index, STACK: [2]
0G         # push 0, duplicate input, STACK: [2, 0, [2 14 17]]
d          # take differences, STACK: [2, 0, [12, 3]]
Yk         # get value in [12, 3] nearest to 0, STACK: [2, 3]
G0)        # get last element in input, STACK: [2, 3, 17]
3$:        # 3-input :, computes 2:3:17, the range from 2 to 17 by 3
           # STACK: [[2 5 8 11 14 17]], implicit output.

Haskell, 73 69 bytes

f(h:t)=do(#)<-[(-),(+)];[h,h#minimum(abs<$>zipWith(-)t(h:t))..last t]

Try it online!

Jelly, 8 bytes

ṂrṀmIg/$

Try it online!

Notes:

Explanation:

First, because a continuous segment is deleted and at least 3 elements remains, there are two consecutive numbers in the old list remain, and the deltas will all be multiples of the step. Therefore the gcd of the differences (I, increments) list will be the absolute value of the step.

Fortunately the gcd is signed (see note above)

So the program does:

ṂrṀ

An increasing integer range from the inimum to the aximum.

m

Modular, pick every n'th element.

Ig/$

Monadic ($) chain combine I (increments, differences) and g/ (reduce gcd over elements of the list). If the increments are positive then the gcd will be positive and the returning list will be left-to-right (increasing), and vice-versa.

05AB1E, 9 8 bytes

Ÿs¥¿Äô€н

Try it online!

Explanation

Saved 1 byte using gcd of deltas instead of min delta, inspired by user202729

Python 2, 78 bytes

lambda a:range(a[0],a[-1],[min,max][a[0]>a[1]](a[1]-a[0],a[-1]-a[-2]))+[a[-1]]

Try it online!

Wolfram Language (Mathematica), 50 bytes

Range[#&@@#,#[[-1]],#&@@Differences@#~SortBy~Abs]&

Try it online!

Python 2, 147 bytes

from fractions import*
a=input()
b=[j-i for i,j in zip(a[:-1],a[1:])]
l=min(gcd(i,j)for i in b for j in b)
print list(range(a[0],a[-1]+l/abs(l),l))

Try it online!