| Bytes | Lang | Time | Link |
|---|---|---|---|
| 027 | AWK | 250331T162546Z | xrs |
| 002 | Thunno 2 | 230614T173040Z | The Thon |
| 004 | GolfScript | 230224T141727Z | emirps |
| 011 | Julia 1.0 | 230223T141409Z | Ashlin H |
| nan | Piet + asciipiet | 230224T061936Z | Aiden Ch |
| 022 | Alice | 230224T034235Z | Julian |
| 006 | Pyt | 230224T015455Z | Kip the |
| 091 | Pascal | 230224T015012Z | Kai Burg |
| 010 | K ngn/k | 221014T084800Z | oeuf |
| 011 | Factor | 221014T081230Z | chunes |
| 001 | Vyxal | 221014T075921Z | DialFros |
| nan | Pxem | 210322T104653Z | user1004 |
| 024 | Dash | 210322T084527Z | user1004 |
| 2923 | Rust | 180923T112143Z | null |
| 038 | PHP | 201017T231546Z | Zsolt Sz |
| 017 | Rust | 190101T002525Z | don brig |
| 003 | Husk | 201016T205546Z | LegionMa |
| 022 | JavaScript | 180903T102552Z | Shaggy |
| 002 | MathGolf | 180925T065942Z | maxb |
| 005 | Pyth | 181006T173130Z | Tryer |
| 077 | Pepe | 180923T110517Z | u-ndefin |
| 005 | Braingolf | 180927T042316Z | FatalErr |
| 032 | C clang | 180922T143855Z | user3604 |
| 038 | Lua | 180921T185400Z | Marcio M |
| 006 | Jelly | 180907T162207Z | Kitten H |
| 023 | JavaScript | 180922T193038Z | guest271 |
| 252 | Common Lisp | 180920T202945Z | Renzo |
| 029 | Math++ | 180920T191451Z | SuperJed |
| 067 | JavaScript Node.js | 180914T104708Z | user5812 |
| 002 | Jelly | 180920T173023Z | dylnan |
| 014 | q | 180920T171741Z | Thaufeki |
| 026 | Haskell | 180920T003452Z | Matt R |
| 002 | Python | 180919T140454Z | Milbrae |
| 003 | Stax | 180919T134059Z | Multi |
| 017 | ><> | 180904T084817Z | PidgeyUs |
| 012 | Pari/GP | 180914T053713Z | alephalp |
| 025 | Powershell | 180905T145509Z | mazzy |
| 006 | Brachylog | 180910T101640Z | Kroppeb |
| 011 | Ruby | 180910T100848Z | G B |
| 024 | SmileBASIC | 180908T000404Z | 12Me21 |
| 091 | brainfuck | 180907T235029Z | Prismo |
| 003 | Pyth | 180907T164031Z | user4854 |
| 024 | Julia 1.0 | 180907T154448Z | gggg |
| 004 | K oK | 180905T151225Z | mkst |
| 037 | SWIFT 37 Bytes | 180905T071437Z | Leena |
| 039 | TSQL | 180905T204023Z | BradC |
| 026 | C gcc | 180904T161017Z | gastropn |
| 013 | R | 180904T085008Z | J.Doe |
| 021 | Red | 180905T074641Z | Galen Iv |
| 004 | J | 180905T073850Z | Galen Iv |
| 025 | Cubix | 180904T084036Z | Luke |
| 013 | Mathematica | 180904T112121Z | LegionMa |
| 027 | Java 9 | 180904T012401Z | Quintec |
| 020 | R | 180904T121805Z | Kirill L |
| 025 | Flobnar | 180904T061933Z | Jo King |
| 041 | C gcc | 180904T080934Z | etene |
| 016 | Ruby | 180904T075227Z | G B |
| 030 | PHP | 180904T030149Z | Titus |
| 010 | Attache | 180904T022742Z | Conor O& |
| 007 | Perl 6 | 180903T232809Z | nwellnho |
| 032 | Clean | 180903T213230Z | Οurous |
| 014 | Charcoal | 180903T122942Z | Neil |
| 017 | Triangularity | 180903T112551Z | Mr. Xcod |
| 002 | 05AB1E | 180903T105708Z | Kevin Cr |
| 020 | Python 3 | 180903T100547Z | TFeld |
| 003 | Japt N | 180903T102416Z | Shaggy |
| 003 | APL Dyalog Unicode | 180903T101958Z | Adá |
AWK, 27 bytes
1,$0=$1!~$2&&$2!~$3&&$1!~$3
35 bytes but will work for arbitrarily long string:
{for(x=1;i++<NF;)x*=!b[$i]++}1,$0=x
Thunno 2, 2 bytes
Explanation
U # Uniquify the input list
ċ # Or, take the set union of the input list with itself
ȯ # Or, take the set intersection of the input list with itself
⁼ # Then, check if this new list is equal to the input list
GolfScript, 4 bytes
..|=
Input is taken as an array of three numbers
Explanation
..|=
.| # Setwise OR the input array with itself
. = # Is it equal to the initial input?
Julia 1.0, 18 11 bytes
~x=x==x∪x
-7 bytes (!!) thanks to MarcMush: replace length(x∪x)>2 with x==x∪x
Piet + ascii-piet, 37 bytes (24×2=48 codels)
TAbTlTiTrTtTLDqMmMEuAkAaAqQIBSAMVcRrr
Probably not the golfiest that could happen but manipulating the stack order in Piet is a bit of a pain.
Pointer Path
Alice, 22 bytes
3&/ M \.!-~?-Zn'0+O@
3&/ M \ Reads the three arguments and puts them on the stack
.!-~?- Compares the two last arguments, then the first with the last
It leaves [0, 0] on the stack if the two numbers are the same
Otherwise any other pair of numbers
Z Packs the two numbers together [0, 0] yields 0
n Logical not, if the pack result is 0 return 1 and any other number returns 0
'0+O@ Output and bye
Pyt, 6 bytes
ĐỤ=Ʃ3=
Đ implicit input; Đuplicate
Ụ get Ụnique items
= is equal element-wise?
Ʃ Ʃum of list (coerce booleans to ints)
3= is equal to 3?; implicit print
Pascal, 91 B
This is a complete program conforming to ISO standard 10206 “Extended Pascal” and at 91 bytes certainly more readable than brain****.
program p(input,output);var x,y,z:integer;begin read(x,y,z);write(ord(card([x,y,z])=3))end.
The [x,y,z] denotes a set, thus duplicate values get collapsed.
This means, the set literal [4, 4, 4] is identical to [4].
The card function returns the number of distinct elements in the set.
Here this will be anything between 1 and 3 inclusive.
We test for equality to 3 (… = 3) which evaluates to a Boolean expression (denoted by the built-in constants false and true) and convert this enumeration value into an integer using ord.
K (ngn/k), 10 bytes
{(#x)=#?x}
A little bit more interesting answer in my opinion, but still boring. Takes a list of integers as input.
Explanations:
{(#x)=#?x} Main function. x is input
? Unique (Remove all duplicated elements)
# Length
= Is it equal to
(#x) The length of x itself
Pxem, Filename: 28 bytes + Content: 0 bytes = 28 bytes.
- Filename:
._._._.e.z.c.c.z1.o.d.a.a0.o - Content: enpty.
Try it online! (with pxem.posixism)
With comments
XX.z
# for three times; do push( read integer); done
.a._._._XX.z
# call subroutine
## NOTE. When DOT-e is performed when stack is a,b,c,bottom,
## then subroutine begins with same content of stack
## And when subroutine ends when stack is d,e,f,bottom,
## then previous stack would be d,e,f,a,b,c,bottom
## to continue origimal procedure
## In this program content is empty, so is subroutine
## thus x,y,z,bottom to x,y,z,x,y,z,bottom,
## which duplicates entire stack
.a.eXX.z
# while size < 2 && pop != pop; do
.a.zXX.z
# dup; dup; while size<2 && pop!=pop; do
## this is equal to while stack is empty; do
.a.c.c.zXX.z
# push '1'; putc pop; exit
.a1.o.dXX.z
# done
.a.aXX.z
# done
.a.aXX.z
# push '0'; putc pop; (implicity) exit
.a0.oXX.z
.a
Dash, 27 24 bytes
$(($1-$2&&$2-$3&&$3-$1))
Sorry for a boring answer; at first if bashism would work, but I could not get out of POSIXism.
The code above evaluates to a string of either 0 or 1.
PHP, 38 bytes
echo(4==count(array_unique($argv)))*1;
Called with e.g. php codegolf.php 2 3 4. $argv always contains the filename of the script, hence 3 unique numbers make 4 elements.
Rust, 17 bytes
Anything XORd with itself yields zero. So. Any language with multiplication and XOR can do this:
(a^b)*(b^c)*(a^c)
Since input specifics were rather vague I chose a liberal interpretation. Or if you want to be more strict, we can define it as a closure (kind of like a lambda function),
24 bytes
|a,b,c|(a^b)*(b^c)*(a^c)
JavaScript, 22 bytes
If we can output boolean values then the last 2 bytes can be removed.
a=>new Set(a).size>2&1
For the same byte count, this works on arrays of any size but assumes the input will never contain a 0 and output is a boolean.
a=>!a[new Set(a).size]
Pyth, 5 bytes
s<2l{
Looks like someone already did pyth but I didn't know about the I for testing invariants.
Pepe, 85 77 bytes
rEeEREeErrEEEEEeRrEeErrEEEEEerEEEEEEERerEEEEEerRrEEEEEEeErREEREEEEErEeReeReEE
Try it online! Input is a,b,c. Change the "separated by" box to , to make it work!
Jelly, 5 6 bytes
ɠḲQL=3
From 5 to 6 bytes because this is my first time and I messed up (whoops) fixed it now
ɠḲQL=3
^^^^^
||||Is it equal to three?
|||How many unique numbers do we have? (length of unique numbers array)
||Sort By Unique
|Split by Spaces
Read Input
JavaScript, 25 24 28 27 23 bytes
Using bitwise, comparison and logical operators Try it online!
(4 bytes saved courtesy of Jonathan Frech)
(a,b,c)=>a!=b&a!=c&b!=c
Math++, 40 29 bytes
?>a
?>b
?>c
(a-b)&(b-c)&(a-c)
JavaScript (Node.js), 67 bytes
f=a=>a.map((m,i)=>a.map((n,j)=>m==n&i!=j).every(z=>!z)).every(y=>y)
q 14 bytes
{x~distinct x}
Technically this solution will return '1b' or '0b', which is the way a boolean value is distinguished from a numeric type, though it retains all arithmetic functionality, and so is in essence a 1 or 0:
q)1b +35
36
To return 1 or 0 non-boolean you have the below, which takes the byte count to 21
{$[x~distinct x;1;0]}
Haskell, 26 bytes
g a b c=and$map(==)[a,b,c]
Python 2
def e(a,b,c):return 1 if len(set([a,b,c]))>2 else 0
...could be shortened to
def e(a,b,c):return len(set([a,b,c]))>2
Stax, 3 bytes
ä▼Z
Explanation
ux= #Full program, unpacked, implicit input as array
u #Keep only unique elements in array, maintaining first order of appearance
x= #Copy original input onto stack, is it equal to unique-ified array.
Short and sweet. Wish Stax would implicitly check against "X" register if there was nothing to check against, but it works out regardless.
Powershell, 27 25 bytes
-2 bytes thanks @AdmBorkBork
+!(($args|group).Count-3)
Test script:
$f = {
+!(($args|group).Count-3)
}
&$f 1 2 3
&$f 3 2 1
&$f 2 1 3
&$f 2 2 3
&$f 2 1 1
&$f 2 1 2
Explanation:
$args|group # Group arguments
( ).Count # Count of groups
( -3) # is 0 if inputed integers are unique
! # operator not converts int to boolean: true if integers are unique
+ # converts boolean to int: 1 if integers are unique, otherwise 0
Brachylog, 6 bytes
d?∧1|0
short explanation
d? deduplcates input an test if still equal to input(?)
∧1 if true return 1
|0 else return 0
SmileBASIC, 25 24 bytes
READ A,B,C?A-B&&B-C&&C-A
brainfuck, 91 bytes
,>,>,[-<-<->>]>>+++++++[>+++++++<-]+<<<<[>]>>[<<<[-<->]<[>]>>->[>.<<<->>-]<+]<+[>>>[>]<-.>]
How it works
,>,>, 'read input as A, B, and C
[-<-<->>]>>+ 'compute A-C, B-C
++++++[>+++++++<-]+ 'prepare output
<<<<[>]>> 'if A-C != 0 && B-C != 0
[
<<<[-<->] 'compute A-B
<[>]>>-> 'if A-B != 0
[>.<<<->>-] 'print 1
<+
]
<+
[ 'else (this else is for both of the if statements, even though they are nested... wierd, I know)
>>>[>]
<-.> 'print 0
]
Pyth, 3 bytes
s{I
Takes input as a list.
Try it here
Explanation
s{I
{IQ Check if the (implicit) input is invariant under deduplication.
s Cast to int.
If we're allowed to treat True and False as 1 and 0 (which they are under the hood in Pyth), we can drop the s to get down to 2 bytes.
SWIFT 37 Bytes
Set(Array(readLine()!)).count==3 ?1:0
T-SQL, 39 bytes
SELECT IIF(a=b OR b=c OR c=a,0,1)FROM s
Input is taken as separate columns a, b, c from a pre-existing table s, per our IO standards.
Tried a variation using COUNT DISTINCT from input taken as separate rows, but that was a couple bytes longer.
Cubix, 55 25 bytes
-29 thanks to Jo King
O@O1u|@O@II-!/;I-!/;u^?-p
It should be possible to golf off quite a few bytes.
Mathematica, 13 bytes
Boole[E!=##]&
Pure function. Takes three integers as input and returns 0 or 1 as output. I know that this is rather similar to David G. Stork's answer, but it exploits SlotSequence to shave off a byte (as compared to Boole@*Unequal).
Java 9, 43 27 bytes
thanks to @Olivier Grégoire
(a,b,c)->a!=b&b!=c&a!=c?1:0
Previous attempt:
(a)->a[0]==a[1]||a[0]==a[2]||a[1]==a[2]?0:1
R, 24 22 20 bytes
all(table(scan())<2)
Returns a boolean, but as folks have already discussed on the Python answer, this should be OK.
Thanks to digEmAll for saving 2 bytes.
C (gcc), 50 41 bytes
-9 bytes thanks to GB !
m(int*a){a=*a==a[2]^*a==*++a^*a==*++a^1;}
No built-in sets in C, and iterating is too long, but at least i can shave off a few bytes by taking advantage of the fact that *a == a[0] ...
PHP, 30 bytes
<?=array_unique($argv)==$argv;
takes input from command line arguments; prints 1 for truthy, empty string for falsy
Attache, 10 bytes
`==#Unique
This is a fork of the operator `== and Unique, equivalent to:
{ _ == Unique[_] }
Alternatives
{#_=#Unique[_]} (15 bytes)
Any##Same=>Pairs@Sort (21 bytes)
Any@{`=&>_[[0'1,1'2,2'0]]} (26 bytes)
&${not(x=y or y=z or x=z)} (26 bytes)
&${x/=y and y/=z and x/=z} (26 bytes)
{Any!Same=>Chop&2!_[0'1'1'2'2'0]} (33 bytes)
Charcoal, 14 bytes
≔E³NθI¬⊖⌈Eθ№θι
Try it online! Link is to verbose version of code. 5 bytes could be saved by using a slightly non-standard input format [[x, y, z]]. Explanation:
≔E³Nθ
Input 3 numbers and make a list.
I¬⊖⌈Eθ№θι
Count the number of occurrences of each number in the list. Take the maximum, subtract 1, take the logical not, then cast to string for implicit print.
Triangularity, 17 bytes
..i..
.MiC.
}u)3=
How it works
Excluding the mandatory triangular padding, we're left with:
iMiC}u)3=
Which can minimally be explained as: Push all STDIN as an array of strings (representing each line of input), count the occurrences of all of STDIN's elements in itself (which, in case all are distinct, should yield [1, 1, 1]), sum, then check whether the sum is equal to 3. There are 2 tricks here (which together save no less than 14 bytes):
- Using
iand treating the inputs as strings rather than integers – which is quite uncommon, as)IEis frequently used instead, taking input as a list. - Instead of checking whether they all are equal to 1 and then taking the product – or equivalently, taking the product and checking whether it is equal to 1 – this takes the sum and compares it with 3. Proving the validity of this method is obviously trivial: [1, 1, 1] is the only valid way to partition 3 into 3 positive integers summing to it and the contents of this list are always positive, as every element of a collection must occur at least once in it :P.
05AB1E, 2 bytes
ÙQ
Try it online or verify some more cases.
Explanation:
Ù # Uniquify the (implicit) input
Q # Check if it's still equal to the (implicit) input
Japt -N, 3 bytes
eUâ
Explanation
Uâ deduplicates the input and e tests if it's equal to the original.
APL (Dyalog Unicode), 3 bytesSBCS
Anonymous tacit prefix function. Takes list as argument.
∪≡⊢
∪ does the set of unique elements from the argument
≡ match
⊢ the unmodified argument?
