| Bytes | Lang | Time | Link |
|---|---|---|---|
| 042 | AWK | 241113T164812Z | xrs |
| 042 | Tcl | 181007T034711Z | sergiol |
| 012 | Jalapeño | 250212T035507Z | ATaco |
| 021 | Desmos | 250205T051015Z | DesmosEn |
| 024 | CASIO BASIC CASIO fx9750GIII | 241120T181800Z | madeforl |
| 006 | 05AB1E | 181006T201927Z | Kevin Cr |
| 086 | C gcc | 230703T093139Z | l4m2 |
| 053 | JavaScript Node.js | 230703T082715Z | l4m2 |
| 009 | TIBASIC | 230701T043010Z | TiKevin8 |
| 003 | Jelly | 230701T032426Z | Unrelate |
| 005 | Thunno 2 | 230630T162315Z | The Thon |
| 005 | Vyxal | 221122T061441Z | emanresu |
| 036 | Gol><> | 190302T040528Z | KrystosT |
| 049 | PowerShell | 190301T133741Z | mazzy |
| 117 | Java JDK | 190301T220009Z | Sara J |
| 036 | Bash | 190301T225811Z | Joshua D |
| 044 | Python 3.8 prerelease | 190301T121739Z | squid |
| 022 | Perl 6 | 181017T152017Z | Ven |
| 012 | APL Dyalog Unicode | 181029T140816Z | Adalynn |
| 079 | Scala | 181017T130216Z | jrook |
| 006 | APL Dyalog Classic | 181011T081127Z | ngn |
| 032 | Ruby | 181016T073005Z | G B |
| 057 | PHP | 181016T015102Z | Titus |
| 013 | Pip | 181015T230906Z | DLosc |
| 008 | Japt hF | 181015T163231Z | Oliver |
| 4953 | JavaScript Node.js | 181005T213441Z | Chris M |
| 037 | R | 181005T212558Z | Robert S |
| 022 | V | 181008T132409Z | oktupol |
| 012 | APL Dyalog Unicode | 181009T212907Z | Adá |
| 009 | MATL | 181008T145247Z | Sundar R |
| 054 | Perl 5 n M5.010 | 181008T152407Z | Sundar R |
| 038 | Ruby aplF | 181008T124028Z | Kirill L |
| 238 | Java JDK | 181008T070333Z | Jaden Le |
| 039 | Ruby | 181007T132256Z | iBug |
| 112 | F# | 181007T225354Z | Ciaran_M |
| 128 | Rust | 181007T214640Z | Hannes K |
| 101 | Java JDK | 181007T154544Z | Lucy Ste |
| 004 | Jelly | 181006T105847Z | Jonathan |
| 028 | Bash coreutils | 181007T132736Z | iBug |
| 081 | Red | 181006T002414Z | Dick Bry |
| 074 | PHP <=5.6 | 181005T230958Z | Artistic |
| 009 | Actually | 181007T033230Z | user4594 |
| 039 | Runic Enchantments | 181007T023421Z | Draco18s |
| 007 | Pyth | 181006T003405Z | hakr14 |
| 035 | K4 | 181005T214950Z | Thaufeki |
| 022 | Perl 6 | 181005T213617Z | Jo King |
| 054 | XPath 3.1 | 181006T224931Z | Michael |
| 061 | Haskell | 181006T000015Z | Laikoni |
| 041 | Python 2 | 181005T221256Z | Arnav Bo |
| 091 | C gcc | 181006T165541Z | user7740 |
| 102 | Common Lisp | 181006T131752Z | Renzo |
| 016 | Japt | 181005T222737Z | Shaggy |
| 043 | Mathematica | 181006T100534Z | LegionMa |
| 005 | MathGolf | 181006T074242Z | maxb |
| 037 | Python 2 | 181006T080849Z | ovs |
| 015 | Charcoal | 181006T010044Z | Neil |
| 028 | Octave | 181005T215241Z | flawr |
| 009 | Ohm v2 | 181005T214912Z | ThePlasm |
| 044 | Python 2 | 181005T214651Z | Chas Bro |
| 004 | Neim | 181005T212306Z | Okx |
| 013 | CJam | 181005T210256Z | Esolangi |
AWK, 51 42 bytes
{for(;i++<NF;x+=$i!=$1)$i>y&&y=$i}$0=x?y:0
Buggy:
{for(;i++<NF;x+=$i~$NF?1:0)y=$i>y?$i:y;$0=1~x?y:X}1
To test:
awk -F"," '{for(;i++<NF;x+=$i~$NF?1:0)y=$i>y?$i:y;$0=1~x?y:X}1' <<< "7,3,8,4,8,3,9,4,6,1,3,7,5"
{for(;i++<NF; # iterate through numbers
x+=$i~$NF?1:0) # count duplicates
y=$i>y?$i:y; # if new number is bigger
$0= # set output
1~x?y:X}1 # only one match or blank
Jalapeño, 12 bytes
SU₋'↦N{₄⇊,⇈u⇪1
Explained
SU₋'↦N{₄⇊,⇈u⇪1
S # Splitby
U₋' # The literal character 0x2C ("," or "U₋" in Jalapeño encoding)
↦N # Mapby tonumber
{₄ # Applied to the subchain
⇊,⇈ # The list consisting of the minimum followed by the maximum of the input
u # Keeping only unique elements
⇪1 # Take the element at index 1. The max if it's different then the min, or undefiend otherwise.
Hex-Dump of Bytecode
0 1 2 3 4 5 6 7 8 9 A B C D E F
0000: 13 2c 21 d0 43 c8 f2 29 f0 e4 e0 31
Jalapeño, 6 bytes, Standard IO
⇊,⇈u⇪1
Same as above but without the extra work to fix the input
Hex-Dump of Bytecode
0 1 2 3 4 5 6 7 8 9 A B C D E F
0000: f2 29 f0 e4 e0 31
Desmos, 21 bytes
f(l)=v/vl.max
v=l.var
It checks if all elements are identical by calculating the variance, and if it's 0, it leads to a divide by 0 error, otherwise it returns the max.
-4 bytes thanks to Aiden Chow
CASIO BASIC (CASIO fx-9750GIII), 40 24 bytes
(edit: how in the world did i forget the byte count? sorry about that!)
?→List1
Max(List1
" "
Ans≠List1[1⇒Ans
you have to put a { before your input.
I love implicit output
05AB1E, 9 8 6 bytes
',¡ê¦à
-1 byte thanks to @Cowabunghole.
Try it online or verify all test cases.
Would be just the last 3 bytes (ê¦à) if a list input would be allowed:
Try it online or verify all test cases.
Explanation:
',¡ '# Split the (implicit) input-string by ","
ê # Uniquify and sort the list
¦ # Remove the first item
à # Pop and push the maximum, or an empty string if the list is empty
# (which is output implicitly as result)
C (gcc), 86 bytes
a;g(){scanf("%d,",&a);}f(b,c){for(b=g(),c=a;~g();c=a>c?a:c)b&=a==c;b||printf("%d",c);}
Read stdin and write stdout
JavaScript (Node.js), 53 bytes
s=>(s=s.split`,`.sort((a,b)=>a-b))[0]-s.pop()?s[0]:''
Worse than Shaggy's
TI-BASIC, 11 9 bytes
9 Bytes
If max(Ans≠max(Ans
max(Ans
Shaved 2 more bytes - implicit Disp on the final line and optimizing the condition. We instead get a single value from the input list in Ans with max( and check if it is not equal to all the other values of the list with Ans≠max(Ans. We then check if at least one of the elements in the list was different with another max( command. Ultimately this is the same number of tokens in the condition but it saves a byte by eliminating the 2 byte ΔList( command.
11 Bytes
If sum(0≠ΔList(Ans
Disp max(Ans
Takes an input list in Ans. The ΔList( command returns a list of the differences of the elements in the provided list. In TI-BASIC logic performed on lists returns a list with the operation performed on each element in that list, so 0≠ returns a list of 1s and 0s identifying if diffs of consecutive elements were 0 and therefore the elements were equal. By summing this list we identify whether all all elements were different to the next and therefore whether they were all different (we would need to sort the list first if trying to identify the number of different elements, but since we only care about whether they're all the same there's no need to sort). That whole chunk is used as the condition for whether to display the max of the input list in Ans. 11 bytes because the ΔList( command is a 2 byte token.
Jelly, 3 bytes
ṀḟṂ
TIO link uses function I/O for the sake of having a test harness, but it works just fine with a plain comma-separated list. I'd prefer to let a challenge like this stay dead, but if it's been bumped anyways...
Ṁ The maximum,
ḟ unless it's equal to
Ṃ the minimum.
Thunno 2, 5 bytes
G$ạ?"
Explanation
G$ạ?" "# Implicit input
G # Push the maximum
$ # Push the input again
ạ # Is it all equal?
? # If it is:
" "# Push an empty string
# Implicit output
Gol><>, 36 bytes
TIE!tlK1}l4,MF={=}|{?;1W~2K(?$~lM|~h
4 bytes golfed off!!! I realized I was using some redundancies in there... next I think I can really make the part for checking if the array is equal smaller!
# Gol><>, 40 bytes
TIE!tlK1}l4,MF={S&}|{?;1W~2K(Q$~:|~lM|~h
Haha, I had my debug stuff in my previous answer, now this has golfed off 2 bytes, but I just realized how to make it even shorter
PowerShell, 45 49 bytes
+4 bytes thanks Veskah
($l=$args-split','|sort{+$_}-u)[-1]|?{$l.count-1}
Less golfed:
$list=$args-split','|sort{+$_}-unuqie
$max=$list[-1]
$max|?{$list.count-1}
Java (JDK), 112 108 117 bytes
s->{return java.util.Arrays.stream(s.split(",")).mapToLong(Long::new).distinct().sorted().skip(1).max().getAsLong();}
Either returns a long or throws an exception, which presumably counts as not returning anything.
Edit: Fixed a bug that caused incorrect output if the maximum was the first element of the input. (+9 bytes)
Bash, 36 bytes
tr , \\n|sort -un|tail -n+2|tail -n1
takes input on stdin, outputs to stdout
$ echo 1,2,3 | ./f.sh
3
$ echo 1,1,1 | ./f.sh
$ echo 123,231,321,312 | ./f.sh
321
Python 3.8 (pre-release), 45 44 bytes
if~-len(a:=set(eval(input()))):print(max(a))
First time golfing; I'm sure this can be improved.
Also a few months late to the party on this challenge, but whatever. xD
APL (Dyalog Unicode), 12 bytes
(⌈/↑⍨⍬≢1↓∪)⎕
If there were no input requirements, it could just be ⌈/↑⍨⍬≢1↓∪ for 9 bytes.
Scala (91 79 bytes):
def f(s:String){val i=s.split(",");if(i.toSet.size>1)print(i.map(_.toInt).max)}
APL (Dyalog Classic), 6 bytes
⍪⌈/~⌊/
a train computing the maximum (⌈/) without (~) the minium (⌊/) turned into a matrix (⍪)
if the input contains only one distinct element, ⌈/~⌊/ will be empty and ⍪ will return a 0×1 matrix which renders as nothing
otherwise, ⌈/~⌊/ will be a 1-element vector and its ⍪ will be a 1x1 matrix (visually indistinguishable from a scalar) that contains the maximum
PHP, 57 bytes
<?=count(array_unique($a=split(",",$argn)))>1?max($a):"";
requires PHP<7; replace split with explode for current PHP (+2 bytes):
<?=count(array_unique($a=explode(",",$argn)))>1?max($a):"";
Run as pipe with -nR or try them online.
Pip, 13 bytes
a^:',MXaRMMNa
Uses the approach from ngn's APL solution:
MNa Minimum of the list
aRM Remove it from the list
MX Take the max of the remaining elements
The first 5 bytes a^:', split the input string on commas.
Alternate 13-byte solutions:
I!$=Ya^',PMXy
a^:',$=a?uMXa
JavaScript (Node.js), 49/53 bytes
My original version using .every(), 53 bytes
Does a function returning '' count as no output? Sure this can be improved upon...
s=>(a=s.split`,`).every(e=>a[0]==e)?'':Math.max(...a)
Improved version using Set() by Shaggy, 49 bytes
s=>new Set(a=s.split`,`).size>1?Math.max(...a):``
R, 50 37 bytes
-33 bytes thanks to digEmAll! -13 bytes thanks to rturnbull!
x=scan(se=",");if(any(diff(x)))max(x)
V, 22 bytes
Ó,/ò
ún
Dç^"$/d
GYVHp
Hexdump:
00000000: d32c 2ff2 0afa 6e0a 44e7 5e12 2224 2f64 .,/...n.D.^."$/d
00000010: 0a47 5956 4870 .GYVHp
Explanation:
Ó,/ò Replace commas with new lines
ún Sort; cursor ends up in first line
D Delete line (smallest number)
ç^<C-r>"$/d Delete all lines that contain the same number
GYVHp Go to last line, copy, select all, paste
If all numbers are equal, the buffer is empty and nothing will be copied,
resulting in an empty output
APL (Dyalog Unicode), 12 bytes
Full program. Prompts for string from stdin.
{1≠≢∪⍵:⌈/⍵}⎕
⎕ prompt for and evaluate expression (commas concatenate the numbers into a list)
{…} apply the following anonymous lambda (⍵ is the argument; the list of numbers):
1≠ [if] 1 is different from…
≢ the tally of…
∪ the unique numbers in…
⍵ the list
: then
⌈/ return the max across (lit. max reduction)…
⍵ the list
[else: do nothing]
MATL, 15 9 bytes
U&=?}1MX>
Try it online!
Multiple testcases
Just trying to keep my MATL chops from getting too rusty!
Edit: rusty after all; saved 6 bytes, thanks to @LuisMendo.
Explanation
U % str2num - automatically parses comma-separated strings
&=? % Are all the values equal?
} % if not
1M % Get the numeric matrix again on the stack
X> % And find its maximum value.
Ruby -aplF,, 38 bytes
$_=$F.uniq.one?? p: $F.map(&:to_i).max
I'm generally not a fan of extensively using command line switches, but since the I/O format is very rigid - here it goes.
The input is automatically (-a) split into an array $F using comma as a separator (-F,). If it contains only one unique element, we return nil, otherwise, the max value. Finally, the output written into $_ is implicitly printed (-p). The option -l isn't really necessary - it is only there to make empty outputs discernible by line breaks.
Update: Almost forgot that we don't automatically get integers from split, just strings, which brings more boilerplate...
Java (JDK), 238 bytes
Golfed
public static String max(String s){StringTokenizer st=new StringTokenizer(s,",");TreeSet<Integer>t=newTreeSet<>();while(st.hasMoreTokens()){t.add(Integer.parseInt(st.nextToken()));}if(t.first()=t.last())return "";return Integer.toString(t.last());}
Ungolfed
import java.util.StringTokenizer;
import java.util.TreeSet;
public class max {
public static String max(String s) {
StringTokenizer st = new StringTokenizer(s,",");
TreeSet<Integer> t = new TreeSet<>();
while (st.hasMoreTokens()) {
t.add(Integer.parseInt(st.nextToken()));
}
if (t.first() == t.last()) return "";
return Integer.toString(t.last());
}
}
I have already seen this answer, but I still wanted to share my answer.
Ruby, 39 bytes
a=eval gets
puts a.max if a.uniq.size>1
Takes an string-form array and prints the result.
F#, 112 bytes
let m(c:string)=
let n=c.Split ','|>Seq.map int
if Seq.distinct n|>Seq.length=1 then None else Seq.max n|>Some
I get the feeling that it could be made smaller, but I can't quite see how...
Rust, 128 bytes
fn f(s:&str)->Option<u32>{let v=s.split(",").map(|a|a.parse::<u32>().unwrap());let x=v.clone().max();if v.min()==x{None}else{x}}
Java (JDK), 101 bytes
d->{long m=0,c=-1,b;for(var s:d.split(",")){b=new Long(s);c=c<0|c==b?b:0;m=b>m?b:m;}return c>0?"":m;}
Explained
d->{ // Function taking a String input
long m=0,c=-1,b; // Initialise variables
for(var s:d.split(",")){ // Split by comma and loop over elements
b=new Long(s); // Parse String to Long
c=c<0 // If c<0 (i.e. this is the first element)
|c==b // ...or c is equal to the current element
?b // Set c to the current element (all elements are the same so far
:0; // Otherwise set c to zero to denote that list is not all same element
m=b>m?b:m; // Set m to max of b and m
}
return c>0?"" // If c is not zero then all elements are the same, return nothing
:m; // Else return max element
}
Bonus solution!
Despite my best efforts I couldn't get this solution using regex and Streams to less than 105 bytes, but I really liked its elegance so had to give it an honourary mention;
d->d.matches("(.+?)(,\\1)+")?"":java.util.Arrays.stream(d.split(",")).map(Long::new).reduce(0L,Long::max)
Jelly, 4 bytes
ḟṀE?
A full program accepting the input as a command line argument (unquoted) which prints the required output
(Note that it deals with: empty input like , single item input like 7 and multiple item input like 7,8,7 like the spec seems to currently require.)
How?
ḟṀE? - Full program: if one argument is present it is evaluated using Python
- so 7,8,7 -> [7,8,7], while 7 -> 7
ḟṀE? - Main Link: list or integer OR no argument (in which case an implicit argument of 0)
? - if...
E - ...condition: all equal? (for any integer E yields 1 since the argument is
- treated as a list like [integer])
ḟ - ...then: filter discard (since it's undefined the right argument is implicitly
- equal to the left; both are treated as lists, so this
- yields an empty list)
Ṁ - ...else: maximum (again an integer is treated as a list)
- implicit print (Jelly's representation of an empty list is an empty string
- furthermore no newline is printed in either case)
Bash (coreutils), 28 bytes
sort -n|uniq|tail +2|tail -1
Input is a stream, one number on each line
tail +2 strips the first line, and the output is empty if it's the only line coming out from uniq, which squashes identical lines into one after sort.
Red, 81 bytes
x: split input","forall x[x/1: load x/1]sort x: unique x if 1 <>length? x[last x]
Like the R solution, a huge chunk of the code is handling the input string "1,1,2,44,1". If we can have that as a block, eg: x: [1 1 2 44 1], then we can do it in 41 bytes:
sort x: unique x if 1 <>length? x[last x]
PHP (<=5.6) 64 74 bytes
echo array_count_values($a=split(',',$argn))[$m=max($a)]==count($a)?'':$m;
Run as pipe with -nR or test it online
split was removed in PHP7, but as I had to add 10 to fix a few issues, it was worth using instead of explode which is roughly equivalent in this case.
Actually, 9 bytes
;M@╔l1<óX
Actually parses comma-separated items as lists on input, so long as the items look like Python literals, so there is no overhead for the restrictive input format.
Explanation:
;M@╔l1<óX
;M make a copy of the input, maximal element
@╔ remove duplicates from other copy
l1< is 1 less than the length of the deduplicated list?
ó if so, immediately exit, without printing anything
X else, discard the length, and implicitly print the remaining stack element (the maximal element of the input list) at exit
Runic Enchantments, 39 bytes
/u'!}R:'!=?\~or:}(\
\i|'<\ }n/ ;${;?/
Numbers have to be separated with | to be parsed from input correctly (using , causes the list to be read as a single number as , is the group separator and C# doesn't care where it's located in the string, it ignores all of them).
No possibility of removing the three spaces in the lower line, due to the loop entrance and exit locations.
Does have a limited stack size that can be processed (9 items) due to the mana cost of the sort command (and potential bleed from large stack size and low remaining mana). A slightly larger program can handle up to 14 items.
Pyth, 7 bytes
Itl{QeS
Try it online!
All test cases (slightly different code for better output formatting)
As Pyth is based on Python, user input is always interpreted as a string, which then may be passed through eval(). All Pyth programs automatically run Q=eval(input()) as their first instruction.
Itl{QeS | Full code
Itl{QeSQ | with implicit variables filled
---------+-------------------------------
I | If
t | one less than
l | the length of
{Q | the deduplicated input
| is truthy (!=0),
| print
e | the last element of
SQ | the sorted input
K4, 38 35 bytes
{$[1=#:t:?:(7h$","\:x)-48;;*:t@>t]}
Test Cases:
q)k){$[1=#:t:?:(7h$","\:x)-48;;*:t@>t]}"1,2,4,4"
,4
q)k){$[1=#:t:?:(7h$","\:x)-48;;*:t@>t]}"4,4,4,4"
q)
q)k){$[1=#:t:?:(7h$","\:x)-48;;*:t@>t]}"7,3,8,4,8,3,9,4,6,1,3,7,5"
,9
q)k){$[1=#:t:?:(7h$","\:x)-48;;*:t@>t]}"7,7,7,7,7,7,7,7,7,7,7,7,7"
q)
I'm not very fluent in any of the k variants available on TiO, so no online example available, I'll try to come up with one though
Explanation
If you're wondering why certain operations are performed before others, K4 does not have operator precedence, it instead interprets from right to left (though you can use parentheses for precedence). Expressions seperated by semicolons.
$[expr;`True;`False] is the conditional format
{$[1=#:t:?:(7h$","\:x)-48;;*:t@>t]}
","\:x //split string on commas
7h$ //cast strings to long
-48 //they'll be from ascii format, so compensate
?: //get distinct list
t: //set list to variable t
#: //get count of t
1= //check if count t = 1
;; //return nothing if true
t@>t //if false, sort t descending
*: //return first value
Can probably be golfed down more, not a fan of having to use that makeshift max function at the end.
EDIT: If the commas in output are a problem, it can be fixed with two more bytes:
q)k){$[1=#:t:?:(7h$","\:x)-48;;*:,/t@>t]}"1,2,4,4"
4
,/ //joins the single element lists into one
Taking the total to 40 37, but the comma before the number simply means that it's a single element list as opposed to an atom.
Perl 6, 26 23 22 bytes
-1 byte thanks to nwellnhof
{.max if .Set>1}o&EVAL
Returns an empty slip if everything is equal.
Explanation
o&EVAL # Eval the string to a list of integers
{ } # Pass to code block
.max # Return the max
if .Set>1 # If the list converted to a set has more than one element
XPath 3.1, 54 bytes
with the input string as the context item:
let$t:=tokenize(.,',')!xs:int(.)return max($t)[$t!=$t]
Could be reduced by one character if you allow the context to bind a shorter prefix than "xs" to the XML Schema namespace.
Explanation: takes the input string, tokenizes on "," separator, applies xs:int() to each token to convert to an integer, computes the max of the sequence, outputs the max provided the predicate $t!=$t is true. If A and B are sequences, then A!=B is true iff there is a pair of items (a from A, b from B) such that a!=b.
If the input can be supplied as a sequence of integers $s rather than a comma-separated string then the solution reduces to
max($s)[$s!=$s]
(15 bytes - which might well be the shortest solution in a language that isn't purpose-designed for brevity)
NOTE: this doesn't satisfy the requirement "represented as it is in the input" - if there's an integer with leading zeroes or a plus sign in the input, these will be lost. I suspect that's true of many other solutions as well.
Haskell, 77 75 61 bytes
f.read.('[':).(++"]")
f a=[0|any(/=a!!0+0)a]>>show(maximum a)
('[':).(++"]") takes a string (e.g. "1,2,1,3") and encloses it in bracket chars ("[1,2,1,3]"). Then read turns the string into a list of integers ([1,2,1,3]).
The function f uses this tip for a shorter conditional if one of the outcomes is the empty list. any(/=a!!0+0)a checks whether the list a contains any element that is not equal to its first element a!!0. (The +0 is needed such that read knows it has to look for a list of numbers.) If all elements are equal this test results in False and the empty string is returned. Otherwise show(maximum a), that is the maximum of the list converted to a string, is returned.
C (gcc), 91 bytes
M(s)char*s;{long m=atol(s),o,l=0;for(;s=strchr(s,44);o<0?m-=o:0)l|=o=m-atol(++s);s=l?m:-1;}
Degolf
M(s)char*s;{
long m=atol(s),o,l=0; // Read the first integer from string
for(;s=strchr(s,44); // Advance pointer to next ','
o<0?m-=o:0) // End of loop: if difference <0, deduct from max, increasing it to new max.
l|=o=m-atol(++s); // Read next number, and subtract it from current max.
// Bitwise-OR the difference into the l-variable
s=l?m:-1; // End of function: if l is non-zero, there were at least two different values.
// Return -1 if l is zero, otherwise the max value.
}
Common Lisp, 102 bytes
(lambda(x &aux(c(read-from-string(concatenate'string"#.`("x")"))))(or(apply'= c)(princ(apply'max c))))
The size is mainly due to inputting the data; with input as a regular list, the length reduces to 46 bytes:
(lambda(x)(or(apply'= x)(princ(apply'max x))))
Japt, 16 bytes
This would be 9 if not for the unnecessarily strict input format, 7 if throwing an error counts as outputting nothing.
Assumes the string contains at least 2 integers.
q, mn
â ÊÉ?Urw:P
Mathematica, 43 bytes
If[!Equal@@#,Max@#]&@@#~ImportString~"CSV"&
Pure function. Takes a comma-separated string as input and returns either a number or Null. I believe this is valid, as Null is not graphically displayed:

MathGolf, 5 bytes
è▀s╞╙
Explanation
è Read whole input as int array
▀ Get unique elements
s Sort list
╞ Discard from left of array
╙ Get maximum of list
This works because both the max operator and the discard from left operator don't do anything for empty lists. Well, the max operator removes the list and pushes nothing for empty lists.
It could be 4 bytes if input could be taken as a list.
Charcoal, 15 bytes
≔I⪪S,θ¿›⌈θ⌊θI⌈θ
Try it online! Link is to verbose version of code. Explanation:
≔I⪪S,θ
Split the input on commas and cast each value to integer.
¿›⌈θ⌊θ
Test whether the maximum value is greater than the minimum value.
I⌈θ
If so then cast the maximum value to string and print.
Octave, 28 bytes
Returns the maximum (a number, which is an 1x1 matrix) or an empty (1x0) matrix.
@(a)max(a)(1+all(a(1)==a):1)
Ohm v2, 9 bytes
Ul1E?Oq¿↑
Try it online! Explanation:
Ul1E?Oq¿↑
U Uniquify input
l Get length
1E Push whether length is equak to 1
?Oq If so immediately quit
¿↑ Else print maximum