Challenge

In this challenge, the input will be an ordered set of numbers and the program should be able to tell if the set of numbers is an Arithmetic Sequence.

Input

• The input will be a list separated by ,(comma) or , (comma+space). The minimum length of the list should be 3 elements.

Output

• The Output can be a Boolean (True or False), or a number (1 for True, 0 for False).

In: 1, 3, 5
Out: True

In: 1,4, 7
Out: 1

In: 5, 9,10
Out: 0

In: 5,3,1
Out: False

Rules

• This is , so the shortest code by bytes wins.
• The input will be finite

Best of Luck

• Welcome to Code Golf Stack Exchange. Nice challenge. It is highly recommended to allow input and output by our default rules, instead of having arbitrary restrictions like prohibiting functions. Some languages only have functions.
Jul 3 '20 at 11:52
• It is also highly recommended to provide some test cases.
Jul 3 '20 at 11:53
• Will the input have a minimum of 2 elements.
Jul 3 '20 at 11:57
• You say "a set of numbers". Does that mean they might not be in order?
– xnor
Jul 3 '20 at 12:03
• Why is 5,3,1 false?
– xnor
Jul 3 '20 at 21:57

MathGolf, 5 bytes

ê│▀£┴

Input ,-delimited; outputs 1/0 for truthy/falsey respectively.

Try it online. (MathGolf is able to execute multiple test cases at once for each line of STDIN input, but feel free to only use a single input if you'd like.)

Explanation:

ê      # Read the comma-delimited input-string as integer-list
│     # Get the forward differences of each overlapping pair in this list
▀    # Uniquify these differences
£   # Pop and push the length to get the amount of unique differences
┴  # Check that this length is equal to 1 (1 if 1; 0 if >= 2)
# (after which the entire stack joined together is output implicitly as result)

Retina 0.8.2, 47 bytes

\d+
$* A(1+),(?!\1) (?<=(1+),)\1 ^1*(,1*)\1*$

Try it online! Only works on nondescending sequences of at least two integers. Explanation:

\d+
$* Convert to unary. A(1+),(?!\1) Check that the sequence is ascending. (?<=(1+),)\1 Compute the differences after the first value. ^1*(,1*)\1*$

Check that all of the differences are equal.

• If it only handles non-descending input, then it doesn't handle "a set of numbers" as specified by OP, does it?
Jul 3 '20 at 12:01
• @Adám Well, I wasn't sure what ordering of the set I could assume... I could easily sort the numbers if necessary, it would only cost 7 bytes I think.
– Neil
Jul 3 '20 at 12:20

APL (Dyalog Unicode), 8 bytes (SBCS)

1=≢∪2-/⎕

Try it online!

1= Is 1 equal to

the count of

unique

2-/ pairwise differences

in the evaluated input?

The prompts for input and executes it. Luckily, , is APL's concatenation functions, so the required input format evaluates to a list. Spaces are ignored.

05AB1E, 5 bytes

',¡¥Ë

Input ,-delimited; outputs 1/0 for truthy/falsey respectively.

Explanation:

',¡   '# Split the (implicit) input-string on ","
¥   # Get the deltas (forward differences) of each overlapping pair in this list
Ë  # Check if all differences are equal (1 if truthy; 0 if falsey)
# (after which this result is output implicitly)

Of course, this would have been 2 bytes with default I/O rules by taking a list input: ¥Ë.