title: Is it a pangram?

text:
# Question
Title: Is it a pangram?
Write a function or program that takes as its input a string and prints a truthy value if the string is a pangram (a sequence of letters containing at least one of each letter in the English alphabet) and a falsey value otherwise.

Case of letters should be ignored; If the string is `abcdefghijklmnopqrstuvwXYZ`, then the function should still return a truthy value. Note that the string can contain any other characters in it, so `123abcdefghijklm NOPQRSTUVWXYZ321` would return a truthy value. An empty input should return a falsey value.

---

Test cases

```
AbCdEfGhIjKlMnOpQrStUvWxYz

==> True

ACEGIKMOQSUWY
BDFHJLNPRTVXZ

==> True

public static void main(String[] args)

==> False

The quick brown fox jumped over the lazy dogs. BOING BOING BOING

==> True

```

This is code golf. Standard rules apply. Shortest code in bytes wins.

# Answer
## Pyth, 7 bytes

```
L!-Grb0

```

Explanation:

```
L             lambda (implicit b:)
    rb0       Convert b to lowercase
   G          Lowercase alphabet, "abcd...z"
  -           Set difference, all elts of first that aren't in second
 !            Logical NOT (The empty string is falsey)

```

Try the full-program, single-line version here.
> 27 votes

# Answer
## Perl 6, 20 bytes

```
'a'..'z'⊆*.lc.comb

```

usage:

```
my &code = 'a'..'z'⊆*.lc.comb;
#  the parameter is ^ there

say code '123abcdefghijklm NOPQRSTUVWXYZ321' # True
say code '123abcdefghijklm NOPQRSTUVWXY'     # False

```

I used the 3 byte "french" version () of `U+2286 SUBSET OF OR EQUAL TO` operator instead of the 4 byte "texas" version (`(<=)`) which would have also required an extra space in front of it.
> 18 votes

# Answer
# GS2, ~~11~~ 9 bytes

```
☺ 6ΘàB1."

```

*Thanks to @MitchSchwartz for golfing off 2 bytes!*

The source code uses the CP437 encoding. Try it online!

### How it works

```
☺              Push 32 (code point of space).
  6            Bitwise OR.
   Θ           Make a block of these two instructions and map it over the input.
               This turns uppercase letters into their lowercase counterparts.
      à        Push the lowercase alphabet.
       B1      Swap and apply set difference.
         ."    Push the logical NOT of the length of the result.

```
> 12 votes

# Answer
# JavaScript ES6, 51 ~~57~~

**Edit** 6 bytes save thx @user81655

```
a=>new Set(a.toUpperCase().match(/[A-Z]/g)).size>25

```

Test snippet

```
F=a=>new Set(a.toUpperCase().match(/[A-Z]/g)).size>25

function update() {  O.innerHTML=F(I.value) }
I.value='qwertyuiopasdfghjklzxcvbnm';update()
```

```
input { width: 70% }
```

```
<input id=I oninput='update()'>
<pre id=O></pre>
```
> 12 votes

# Answer
# R ~~50~~ ,~~46~~ 39 bytes

```
all(sapply(letters,grepl,readline(),T))

```

Edit drops the need for `tolower` by adding `ignore.case=TRUE` (`T`)
> 11 votes

# Answer
# Python 2, ~~53~~ 51 bytes

```
f=lambda s,c=65:c>90or(chr(c)in s.upper())*f(s,c+1)

```

Alternate solutions:

```
lambda s:all(chr(c)in s.upper()for c in range(65,91))

lambda s:not set(range(65,91))-set(map(ord,s.upper()))

```

Thanks to xnor for pointing out that sets have an `<=` operator, for an alternate 51:

```
lambda s:set(range(65,91))<=set(map(ord,s.upper()))

```
> 9 votes

# Answer
# O, 11 bytes

```
GQ_s{n-}dS=

```

Try it online.

Sadly, O does not have set difference :/

## Explanation

```
G            Pushes the alphabet to the stack
 Q           Pushes input to the stack
  _          Converts the string to lowercase
   s         Split string into char array
    {  }d    Iterate through array
     n       Pushes current element to the stack
      -      String subtraction
         S   Pushes a blank string to the stack
          =  Equals

```
> 8 votes

# Answer
All of these regexes use their engines' respective case insensitivity flags, so that has not been counted towards the byte counts. Even though some use `\pL` (a shorthand for `\p{L}`) instead of `[A-Z]`, they still need the flag, due to comparing characters via backreference. Without it, they would need to apply the flag inline, `(?i)` inserted at the beginning, costing 4 extra bytes.

# Regex (Perl 5 / PCRE / Boost / Python`regex`), 21, 22, 24, or 25 bytes

Quite simply, this regex works by asserting that there are at least 26 alphabetical characters in the string that do not match with any character to the right of themselves. Each of these characters will be the last occurrence of a given letter of the alphabet in the string; as such, they are all guaranteed to be different letters, and asserting that there are 26 of them implies that the full set A-Z is covered.

`(.*(\pL)(?!.*\2)){26}` (21 bytes) - Try it online! (Perl 5)

Using `\pL` instead of `[A-Z]` to match alphabetical characters imposes the requirement that the input must be in ASCII, because `\pL` matches all Unicode alphabetical characters (including those that are extended ASCII in common codepages); so an accented letter, for example, would count towards consuming the target of 26 loop iterations. Some other regex engines only support this syntax in the form of `\p{L}` (which offers no advantage over `[A-Z]` for this particular problem, being equal in length) and not with the shortened syntax of `\pL`.

This bare-bones version of the regex is extremely slow, due to an excessively huge amount of backtracking both for pangrams and non-pangrams, but will always give the correct result when given enough time. Its search for the 26 matches proceeds in the most pessimal way possible.

Using a lazy quantifier speeds it up greatly when matching pangrams, but it's still incredibly slow to yield non-matches when given non-pangrams:

`(.*?(\pL)(?!.*\2)){26}` (22 bytes)

Try it online! (Perl 5)
Try it online! (PCRE2 / C++, with backtrack limit adjusted)
Try it online! (PCRE2 / PHP, with backtrack limit adjusted)

Changing the main loop to an atomic group allows the regex to also yield non-matches at a reasonable speed:

`(?>.*?(\pL)(?!.*\1)){26}` (24 bytes)

Try it on regex101 (PCRE1)
Try it online! (Python `import regex`)

Adding an anchor is not necessary to make the regex yield correct results, but speeds up non-matches further, by preventing the regex engine from continuing to try for a match at every character of the string (because if it fails to match at the beginning, we know it's guaranteed not to match anywhere in the same string, but the regex engine can't know that):

`^(?>.*?(\pL)(?!.*\1)){26}` (25 bytes)

Try it on regex101 (PCRE1)
Try it online! (Python `import regex`)
Try it online! (Perl 5)
Try it online! (PCRE2 / C++)
Try it online! (PCRE2 / PHP)
Try it online! (Boost / C++)

## Regex (.NET / Java / Ruby), 23, 24, 26, or 27 bytes

These regex engines don't support `\pL` (they support `\p{L}`, but that isn't useful when we already need the case insensitivity flag anyway), thus `[A-Z]` is used:

`(.*([A-Z])(?!.*\2)){26}` (23 bytes)
`(.*?([A-Z])(?!.*\2)){26}` (24 bytes)
`(?>.*?([A-Z])(?!.*\1)){26}` (26 bytes)
`^(?>.*?([A-Z])(?!.*\1)){26}` (27 bytes)

```
^            # 1. Anchor to the start of the string (without this, the regex would still
             #    work but would be slower in its non-matches, due to trying to match at
             #    every character position in the string, which we know will fail, but
             #    the regex engine can't know)
(?>          # 2. Start an atomic group (every complete iteration of matching this group
             #    is set in stone, and will not be backtracked); without only a normal
             #    group, the regex would still work, but with most non-pangram inputs,
             #    would take longer than the age of the universe to yield a non-match,
             #    due to trying every way of matching ".*?" at every iteration of the loop
    .*?      # 3. Skip zero or more characters, as few as possible in order to make the
             #    following match
    ([A-Z])  # 4. Capture and consume an alphabetical character in \1
    (?!      # 5. Negative lookahead: Match outside (with zero-width) only if the inside
             #    does not match
        .*   # 6. Skip forward by zero characters or more in an attempt to make the
             #    following expresison match
        \1   # 7. Match the character captured in \1
    )        # 8. The effect of this negative lookahead is to assert that at no point
             #    right of where \1 was captured does any character match \1
){26}        # 9. Only match if this group can be matched exactly 26 times in a row,
             #    i.e. if we can find 26 characters in the range A-Z that don't match
             #    any character right of themselves, i.e. that we can find the last
             #    occurrence of 26 different alphabetical character in the string.

```

Try it online! (.NET / C#)
Try it online! (Java)
Try it online! (Ruby)

## Regex (ECMAScript / Python), 23, 24, 32, or 33 bytes

The same progression of speed applies:

`(.*([A-Z])(?!.*\2)){26}` (23 bytes) - Try it online! (ECMAScript) / (Python)
`(.*?([A-Z])(?!.*\2)){26}` (24 bytes) - Try it online! (ECMAScript) / (Python)

ECMAScript and Python lack atomic groups, so they must be emulated using lookahead+capture+backref:

`((?=(.*?([A-Z])(?!.*\3)))\2){26}` (32 bytes) - Try it online! (ECMAScript) / (Python)
`^((?=(.*?([A-Z])(?!.*\3)))\2){26}` (33 bytes) - Try it online! (ECMAScript) / (Python)

---

*Edit: Silly me, I assumed that this problem required variable-length lookbehind or other tricks that substitute for it, without even trying to do it without that. Thanks to @Neil for pointing this out.*
> 8 votes

# Answer
# Julia, 38 bytes

```
s->endof(∩('a':'z',lowercase(s)))>25

```

This is simple - `lowercase` deals with the uppercase/lowercase issue, `'a':'z'` holds all of the lowercase letters,  is intersection, removes any character that isn't a letter and, because `'a':'z'` comes first, will only have one of each letter that appears in `s`. `endof` is the shortest way to get the length of the resulting array, and if it's 26, then it's a pangram (it can't be more than 26, and `>25` saves a byte relative to `==26`).
> 6 votes

# Answer
# Ruby, ~~41~~ 33

```
->s{(?a..?z).all?{|c|s[/#{c}/i]}}

```

## Usage

```
p=->s{(?a..?z).all?{|c|s[/#{c}/i]}}
p["AbCdEfGhIjKlMnOpQrStUvWxYz"]
  #=> true
p["ACEGIKMOQSUWY
BDFHJLNPRTVXZ"]
  #=> true
p["public static void main(String[] args)"]
  #=> false
p["The quick brown fox jumped over the lazy dogs. BOING BOING BOING"]
  #=> true

```

Thanks to Vasu Adari for saving me 8 bytes
> 6 votes

# Answer
# 05AB1E, 4 bytes

```
lêAå

```

Try it online!

```
l    # Push lowercase input.
 ê   # Push sorted, uniquified lowercase input.
  A  # Push lowercase alphabet.
   å # Is lowercase alphabet in sorted, uniquified, lowercase input?
     # True if panagram, false if not.

```
> 6 votes

# Answer
## Retina, 22 bytes

```
Msi`([a-z])(?!.*\1)
26

```

Try it online.

The first line matches any letter which does not appear again later in the string. That ensures that we don't match each letter at most once, no matter how often it occurs. Match mode will by default replace the string with the number of matches found. So in the second stage, we match `26` against the result of the first input, which will give either `0` or `1`, depending on whether we found the maximum of 26 matches or not.
> 5 votes

# Answer
# Python 3.5, 47 bytes

```
lambda s:{*map(chr,range(65,91))}<={*s.upper()}

```

Same principle as Mitch Schwartz's answer, but using the PEP 0448 enhancements to `*` unpacking, first introduced in Python 3.5.

This version differs slightly from what I wrote in my comment to Mitch's post, in that I turn the numbers into letters rather than vice versa. That's because that's how I wrote my original attempts at a solution, before discovering that I couldn't out-golf Mitch without outright copying his approach. So consider that tweak my one remaining shred of originality!
> 5 votes

# Answer
# Haskell, ~~59~~ ~~56~~ ~~53~~ 51 bytes

```
p s=and[any(`elem`map toEnum[a,a+32])s|a<-[65..90]]

```

Try it online!

**Explanation:**

Give an input string `s`, for each `a` in range 65 to 90 (the ASCII codes for `A` to `Z`) it is checked whether any character in `s` is equal to either `a` (the upper case character) or `a+32` (the lower case character), converted to a character by `toEnum`. This generates a list of booleans. `and` checks if they're all `True`.

**Old version:**

```
import Data.Char
p s=and[any((==)a.toUpper)s|a<-['A'..'Z']]

```

For every upper case alphabet letter, check whether some letter from `s` in upper case is equal to it. `any(==a)s` is the same as `elem a s` but allows to modify the elements of `s` before the comparison - in this case, covert them to upper case.
> 5 votes

# Answer
# Haskell, 43 bytes

```
f s=until(all(`notElem`s))(succ<$>)"Aa">"["

```

Try it online!

Iterates through the lowercase/uppercase pairs until it finds one where both are not elements of the input, and checks that this failure is past the alphabet.
> 5 votes

# Answer
These have the same regex as in my regex answer. I felt it was worth posting a standalone answer showing its use in languages that don't require an import to access regex functions (resulting in very effective golf). In order of how favorably it compares against the current best non-regex answer.

This answer previously showed programs/functions that couldn't handle multiline input (as the challenge demonstrates is required by its second test case), but they all do so properly now unless otherwise noted.

# Java, 46 bytes

`a->a.matches("(?si:.*([A-Z])(?!.*\\1)){26}.*")` (46 bytes, always slow) - Try it online!
`a->a.matches("(?si:.*?([A-Z])(?!.*\\1)){26}.*")` (47 bytes, slow for non-matches) - Try it online!
`a->a.matches("(?si)(?>.*?([A-Z])(?!.*\\1)){26}.*")` (50 bytes, reasonable speed) - Try it online!

# PHP, 53 or 55 bytes

PHP imposes a strict backtracking limit (or time limit?) on its regexes, so the version that would be 52 bytes doesn't work at all; it always returns an empty result (except for very short non-pangram strings, for which it prints `0`).

`<?=preg_match('/(.*?(\pL)(?!.*\2)){26}/si',$argv[1]);` (53 bytes) - Try it online!

The 53 byte version, however, actually runs fast; it prints an empty result or `0` for false, and prints `1` for true. However, with sufficiently long pangram strings having a long separation between occurrences of new letters, it returns a false negative, due to taking too long to process the string.

`<?=preg_match('/(?>.*?(\pL)(?!.*\1)){26}/si',$argv[1]);` (55 bytes) - Try it online!
`<?=preg_match('/^(?>.*?(\pL)(?!.*\1)){26}/si',$argv[1]);` (56 bytes) - Try it online!

These versions print `0` for false and `1` for true.

This beats 640KB's answer when it is ported to handle multiline input:

`<?=!array_diff(range(a,z),str_split(strtolower($argv[1])));` (59 bytes) - Try it online!

# JavaScript ES9, 38 bytes

`a=>/(.*([A-Z])(?!.*\2)){26}/si.test(a)` (38 bytes, always slow) - Try it online!
`a=>/(.*?([A-Z])(?!.*\2)){26}/si.test(a)` (39 bytes, slow for non-matches) - Try it online!
`a=>/((?=(.*?([A-Z])(?!.*\3)))\2){26}/si.test(a)` (47 bytes, fairly reasonable speed) - Try it online!
`a=>/^((?=(.*?([A-Z])(?!.*\3)))\2){26}/si.test(a)` (48 bytes, very reasonable speed) - Try it online!

When looping this set of test cases, it can be seen that the 48 byte version is about 12 times as fast as the 47 byte version (in SpiderMonkey's regex engine).

This now ties in length with l4m2's answer, which counts individual regex matches. Given the speed difference, that answer obviously wins.

# Ruby, 35 bytes

`->s{s=~/(.*([A-Z])(?!.*\2)){26}/mi}` (35 bytes, always slow) - Try it online!
`->s{s=~/(.*?([A-Z])(?!.*\2)){26}/mi}` (36 bytes, slow for non-matches) - Try it online!
`->s{s=~/(?>.*?([A-Z])(?!.*\1)){26}/mi}` (38 bytes, fairly reasonable speed) - Try it online!
`->s{s=~/^(?>.*?([A-Z])(?!.*\1)){26}/mi}` (39 bytes, very reasonable speed) - Try it online!

When looping this set of test cases, the same result is seen: the 39 byte version is 12 times as fast as the 38 byte version.

This is 2 bytes longer than Alexis Andersen's mixed code/regex answer.

# Ruby `-n0`, 30 bytes

Prints `nil` for false and `0` for true, which are respectively falsey and truthy in Ruby. If printing `0` or `1` is desired, replace `~` with `!!` (+1 byte).

`p ~/(.*([A-Z])(?!.*\2)){26}/mi` (30 bytes, always slow) - Try it online!
`p ~/(.*?([A-Z])(?!.*\2)){26}/mi` (31 bytes, slow for non-matches) - Try it online!
`p ~/(?>.*?([A-Z])(?!.*\1)){26}/mi` (33 bytes, fairly reasonable speed) - Try it online!
`p ~/^(?>.*?([A-Z])(?!.*\1)){26}/mi` (34 bytes, very reasonable speed) - Try it online!

This is 2 bytes longer than Alexis Andersen's answer when it is ported to be a full program using `-n0` instead of a lambda (and it prints `false` or `true`):

`p (?a..?z).all?{|c|~/#{c}/i}` (28 bytes) - Try it online!

# Perl 5 `-p0`, 28 bytes

`$_=/(.*(\pL)(?!.*\2)){26}/si` (28 bytes, always slow) - Try it online!
`$_=/(.*?(\pL)(?!.*\2)){26}/si` (29 bytes, slow for non-matches) - Try it online!
`$_=/(?>.*?(\pL)(?!.*\1)){26}/si` (31 bytes, fairly reasonable speed) - Try it online!
`$_=/^(?>.*?(\pL)(?!.*\1)){26}/si` (32 bytes, very reasonable speed) - Try it online!

This is 2 bytes longer than Xcali's regex + hash answer when its `[a-z]` is replaced with `\pL`. Also, for some reason that answer only requires the `-p` command-line parameter yet still works with multiline input, while this one requires `-p0` to do so.

# Perl 5, 40 bytes

`say@ARGV[0]=~/(.*(\pL)(?!.*\2)){26}/si+0` (40 bytes, always slow) - Try it online!
`say@ARGV[0]=~/(.*?(\pL)(?!.*\2)){26}/si+0` (41 bytes, slow for non-matches) - Try it online!
`say@ARGV[0]=~/(?>.*?(\pL)(?!.*\1)){26}/si+0` (43 bytes, fairly reasonable speed) - Try it online!
`say@ARGV[0]=~/^(?>.*?(\pL)(?!.*\1)){26}/si+0` (44 bytes, very reasonable speed) - Try it online!

This is 4 bytes longer than a port of Xcali's regex + hash answer with `[a-z]` replaced with `\pL`:

`++@a{(uc@ARGV[0])=~/\pL/g};say%a==26` (36 bytes) - Try it online!

Reading multiline input from stdin instead of a command-line argument would be 4 bytes longer, replacing `@ARGV[0]` with  `join('',<>)`.
> 5 votes

# Answer
# Vim, ~~30~~ 26 bytes

```
:%s/\A*/\r/g
:sor ui
26Dr1

```

Try it online!

Let's get this language of the month started! I am still a beginner in Vim, so golfing suggestions are much appreciated :)

### Explanation

The first line of the program uses a regex to substitute any (possibly empty) sequence of non-alphabetic characters (`\A*`) with a newline; since the empty string also gets matched, this will result in a series of lines each containing at most one character, which will be a letter. The first line will always be empty (the initial empty string became a newline).

`:sor ui` `sor`ts the lines `i`gnoring case, and removes duplicates (also ignoring case). If the input was a pangram we will now have an empty line followed by 26 lines each with a character from `a` to `z`; if the input was not a pangram, some of those lines will be missing.

`26D` deletes the first 26 lines, which will leave us with either `z` (for a pangram) or an empty string (for a non-pangram). The only truthy values in Vim are non-zero numbers (or strings starting with a non-zero number), so our last step will be `r1` (replace the first character with `1`) which will result in `1` for a pangram, and an empty string otherwise.
> 5 votes

# Answer
# MATLAB / Octave, ~~35~~ 33 bytes

```
@(x)~nnz(setdiff(65:90,upper(x)))

```

Try it online!

---

The anonymous function returns a logical 1 if the input `x` is a pangram, or a logical 0 if it isn't.

Essentially it uses the same approach as @ThomasKwa's Pyth solution. The set difference between all characters in the upper case alphabet range (`65:91`) and the input string (converted to upper case). Any characters that are in the alphabet but not in the input string are returned by `setdiff`. Only if the array returned by the set difference is empty is the string a pangram.

Using upper case instead of lower case saves a couple of bytes compared with `'a':'z'` because the ASCII value can be used instead to make the range.
> 4 votes

# Answer
# CJam, 11 bytes

```
'[,65>qeu-!

```

This is a complete program. Try it online.

Explanation:

```
'[,65>  Build upper case alphabet (see CJam tips thread).
q       Get input.
eu      Convert to all upper case.
-       Set difference between alphabet and upper cased input.
!       Negate.

```
> 4 votes

# Answer
## Minkolang 0.14, 18 bytes

```
$o7$ZsrlZ'26'$ZN.

```

Try it here.

### Explanation

```
$o                    Read in whole input as characters
  7$Z                 Uppercase every letter
     s                Sort
      r               Reverse
       lZ             Alphabet - uppercase and lowercase
         '26'         Pushes 26 on the stack
             0$Z      Count how often the top 26 numbers of the stack appear in the stack
                N.    Output as number and stop.

```
> 4 votes

# Answer
# R, ~~53~~ 45 bytes

```
all(97:122%in%utf8ToInt(tolower(readline())))

```

**Old version at 53 bytes:**

```
all(letters%in%strsplit(tolower(readline()),"")[[1]])

```

Usage:

```
> all(97:122%in%utf8ToInt(tolower(readline())))
The quick brown fox jumps over the lazy dog
[1] TRUE
> all(97:122%in%utf8ToInt(tolower(readline())))
Write a function or program that takes as its input a string and prints a truthy value if the string is a pangram and a falsey value otherwise.
[1] FALSE
> all(97:122%in%utf8ToInt(tolower(readline())))
123abcdefghijklm NOPQRSTUVWXYZ321
[1] TRUE
> all(97:122%in%utf8ToInt(tolower(readline())))
Portez ce vieux whisky au juge blond qui fume
[1] TRUE

```
> 4 votes

# Answer
## PowerShell v3+, ~~65~~ ~~56~~ 52 Bytes

```
($args.ToLower()-split''|sls [a-z]|group).Count-eq26

```

Thanks to TessellatingHeckler for the 9-byte golf.

* Takes the input string, converts it `.ToLower()`case, then `-split`s on every character
* Those are fed into an alias `sls` for `Select-String` which matches based on a regex `[a-z]` to pull out only the letters
* Those are then fed into `Group-Object`, so we're only selecting one individual instance of each letter
* That is then `.Count`ed to see if it's `-eq`ual to 26, and prints `True` or `False` accordingly
* Requires PowerShell v3 or newer for the `sls` alias
> 4 votes

# Answer
# 2sable, ~~6~~ 5 bytes

6 byte version:

```
AIl-g_

```

Try it online!

Explanation:

```
A        Push alphabet
 Il      Push lowercase input
   -     Remove all chars of input from alphabet
    g    Get length of the remainder
     _   Print negative bool, where length < 1 = 1 (true), length > 0 = 0 (false)

```

---

5 byte version, inspired by carusocomputing's 05AB1E answer:

```
lÙ{Aå

```

Try it online!

Explanation:

```
l        Push lowercase input
 Ù{      Push sorted uniquified input
   A     Push alphabet
    å    Is alphabet in sorted, uniquified input?

```
> 4 votes

# Answer
# , 23 bytes

```
(u:65+i.26)*/@e.toupper

```

Try it online!
> 4 votes

# Answer
# Brachylog, 4 bytes

```
ḷo⊇Ạ

```

Try it online!

```
        The input
ḷ       lowercased
 o      sorted
  ⊇     is a superlist of
   Ạ    the lowercase alphabet.

```
> 4 votes

# Answer
# Julia, ~~26~~ 25 bytes

```
!s='a':'z'⊆lowercase(s)
```
* remove `.` by @MarcMush

Attempt This Online!
> 4 votes

# Answer
# K (ngn/k), ~~36~~ ~~19~~ 17 bytes

```
{~#(97+!26)^0+_x}

```

Try it online!

*-2 bytes thanks to ngn!*

Return `1` for true, `0` for false.

Explanation:

```
{~#(97+!26)^0+_x}      / Main program. x is input
              _        / Lowercase
            0+         / Convert each character to ASCII value
           ^           / Without (set function)
   (97+!26)            / Lowercase alphabet (ASCII value)
  #                    / Length
 ~                     / Not

```
> 4 votes

# Answer
# Prolog (SWI), 57 bytes

```
\O:- \+ (between(97,122,Z),\+sub_atom_icasechk(O,_,[Z])).

```

Try it online!

Buried deep within the Prolog library is the very convenient predicate `sub_atom_icasechk`, which is a "half case-insensitive" check for a substring (half as in lowercase characters can match uppercase but not vice-versa). We just need to surround this in a check that all lowercase letters succeed this check.
> 4 votes

# Answer
# Javascript, ~~110~~ ~~109~~ ~~99~~ ~~95~~ 93 bytes

```
a=prompt(b=0).toUpperCase();for(i=65;i++<91;)b+=!~a.indexOf(String.fromCharCode(i));alert(!b)

```

Saved 6 bytes thanks to Thomas Kwa, and 10 thanks in part to ev3.
> 3 votes

# Answer
# Japt, 14 bytes

```
#ao#{ e@Uv fXd

```

Try it online!

### How it works

```
        // Implicit: U = input string
#ao#{   // Generate a range of integers from charCode("a") to charCode("{").
e@      // Check if every item X in this range returns truthily to:
Uv fXd  //  convert U to lowercase, and put all instances of X.toCharCode() in an array.
        // This returns false if U does not contain one of the characters.
        // Implicit: output last expression

```
> 3 votes

# Answer
# Bash, 45 42 bytes

41 byte program, plus 1 because it must be invoked with `bash -e`:

```
for i in {a..z}
{ [ ${1//[^$i${i^}]} ]
}

```

Amazingly, I managed a Bash answer with no quote characters! (yes, I checked with inputs beginning with `-f`  and the like).

This assumes a locale where the lower-case English letters are contiguous from `a` to `z`. Input is via the first argument to the program.

The way this works is, for each alphabetic letter `$i`, we test whether the string contains `$i` or its upper-case equivalent `${i^}` by removing all other characters. If this results in the empty string, then the input did not contain that letter, and we exit with `1` (false). If we have a non-empty result, then we passed the test and move on to the next letter. If the input string contains every English letter, we will reach the end of the program, thus exiting with `0` (true).
> 3 votes

# Answer
# Rust, 64 bytes

```
|s:&str|(65u8..91).all(|c|s.to_uppercase().contains(c as char))

```

You can take a range over chars in Rust,

```
'a'..'{'

```

but it's presently useless since you can't iterate over it or collect it or do anything with it. They say arithmetic with characters doesn't make sense, so they won't implement the Add and One traits for it.

Still, lambdas and iterators and type inference keeps it reasonably small.
> 3 votes

# Answer
# APL (Dyalog Extended), 6 bytes

```
∧/⎕A∊⌈

```

Try it online!

Explanation:

```
∧/⎕A∊⌈  ⍝ Monadic function train
      ⌈  ⍝ Convert the input to uppercase
  ⎕A∊   ⍝ For each item in the set of uppercase
         ⍝ letters, determine if it exists in the
         ⍝ uppercased input
∧/       ⍝ And-reduce: test if all letters exist

```
> 3 votes

# Answer
# Retina, 20 bytes

```
T`L`l
D`.
C`[a-z]
26

```

Try it online!

## Explained

```
T`L`l        Transliterate stage. Replaces uppercase letters with lowercase letters.
D`.          Deduplicate stage - keep one copy of every match (meaning every character in this case), discarding suplicates.
C`[a-z]      Count stage - Count lowercase letters
26           (implicit) Count stage - Match the string "26"
             (Since there can't be duplicates, a match means each character occurred once.)
             (output the result of the last stage - 1 for pangrams, 0 for non-pangrams)

```
> 3 votes

# Answer
# APL (Dyalog Extended), 1̶8̶ 1̶4̶ 12 bytes

```
{⎕A(∧/∊)⌈⍕⍵}
 ⎕A(∧/∊) ⍝ Check membership in Alphabet array and bitwise reduce by logical AND.
        ⌈ ⍝ Convert to uppercase
         ⍕⍵ ⍝ Encode as character array (handles matrices, empty sets and integers)

```

Edit: Changed `1⎕C` to  thanks to rak1507

Edit: Changed `1(819⌶)` to `1⎕C` thanks to Razetime.

Try it online!
> 3 votes

# Answer
# Vyxal `r`, 5 bytes

```
⇩kaF¬

```

Try it Online!

## How?

```
⇩kaF¬
⇩       # Push the input converted to lowercase
 ka     # Push the lowercase alphabet
   F    # Filter - Remove items from the lowercase alphabet that are in the
        # lowercase-converted input.
    ¬   # Logical Not - Returns truthy for an empty list, falsey otherwise.

```
> 3 votes

# Answer
# Vyxal, ~~6~~ 5 bytes

```
ɽǍkaƈ

```

Try it Online!

```
ɽ   # Convert input to lowercase.
Ǎ   # Remove non-alphabetical characters.
ka  # Push the lowercase alphabet.
ƈ   # Are the set of characters in the two strings the same?

```
> 3 votes

# Answer
# Thunno 2, 4 bytes

```
LḳẠƇ

```

Attempt This Online!

#### Explanation

```
LḳẠƇ  # Implicit input
L     # Convert to lowercase
 ḳ    # Sort and uniquify
   Ƈ  # Does this string contain...
  Ạ   # ...the lowercase alphabet?
      # Implicit output

```
> 3 votes

# Answer
# JavaScript ES6, ~~124~~ ~~114~~ 113 bytes

I'm sure this can be golfed more.

```
v=(Q,s=[...Array(26)].map((x,i)=>String.fromCharCode(i+97)))=>s.length-1?Q.search(RegExp(s.pop(),"i"))+1&&v(Q,s):1

```

Generates an anonymous function.

```
v=(Q,s=[...Array(26)].map((x,i)=>String.fromCharCode(i+97)))=>s.length-1?Q.search(RegExp(s.pop(),"i"))+1&&v(Q,s):1

alert(v(prompt("Enter pangram:")));
```
> 2 votes

# Answer
# TeaScript, 12 bytes

```
Sz.e»xL.I(l©

```

First TeaScript post since I killed TeaScript :p

Try it online

### Ungolfed

```
Sz.e(#xL.I(l))

Sz   // Lower case alphabet
.e(#   // Loop through alphabet, ensure
       // for every character, below returns true
    xL    // Input lowercased
    .I(l) // Checks if above contains current char
)

```
> 2 votes

# Answer
# C, 107 bytes

```
#include<string.h>
int p(char*i){int a=64;while(++a<91)if(!strchr(i,a)&!strchr(i,a+32))return 0;return 1;}

```
> 2 votes

# Answer
## ES6, 68 bytes

```
s=>[..."abcdefghijklmnopqrstuvwxyz"].every(x=>RegExp(x,"i").test(s))

```

That string looks awfully wasteful, but I don't know any better way.
> 2 votes

# Answer
## Scala, ~~59~~ ~~48~~ 46 bytes

```
print(('a'to'z'diff(readLine.map(_|32)))==Nil)

```
> 2 votes

# Answer
# C#, 91 bytes

Requires (18 bytes):

```
using System.Linq;

```

Actual function (73 bytes):

```
bool P(string s)=>s.ToUpper().Distinct().Where(x=>x>64&&x<91).Count()>25;

```

How it works: the function first converts everything to uppercase, then removes all duplicates and only keeps the letters. If count of items in the resulting enumerable exceeds 25 (then it must be 26), it's a pangram.
> 2 votes

# Answer
# PlatyPar, 14 bytes

```
'a'z_,X,F(x;l!

```

Explanation (stack visualizer feature coming soon!):

```
               ## Implicit: push the input (as a string) to the stack
'a'z_          ## Push the range of a-z (the alphabet) to the stack
     ,X        ## Invert stack, expand input string into individual characters
       ,       ## Invert again
        F  ;   ## Fold (While stack.length > 1)
         (      ## Rotate left, moving the first letter of the input string to the top
          x     ## remove any occurences of that letter from the alphabet array
            l! ## Negate the length of the array, so if there's nothing left
               ## output true, else output false

```

If I had a ridiculous "push all letters of the alphabet" function this would be 10...

Try it online!
> 2 votes

# Answer
## Batch, 126 + 2 = 128 bytes

```
@set p="%*"
@for %%a in (a b c d e f g h i j k l m n o p q r s t u v w x y z)do @set q=!p:%%a=!&if !q!==!p! exit/b 1
@exit/b

```

Requires `CMD /V /C <filename> <input string>` so I added 2 bytes for the `/V`. Alternative 87 + 2 + 26 = 115 byte version:

```
@set p="%*"
@for %%a in (?)do set q=!p:%%a=!&if !q!==%p% exit/b 1
@exit/b

```

(+26 for the files named `a`, `b`, `c` ... `z` that need to exist in the current directory.)
> 2 votes

# Answer
## Pyke, 6 bytes

```
l1GR-!

```

Try it here!

```
l1     -   input().lower()
  G -  -  set_difference(alphabet,^)
     ! - not ^

```
> 2 votes

# Answer
# Java 8, 69 bytes

```
s->s.toUpperCase().chars().distinct().filter(c->c>64&c<91).count()>25

```

Alternatives with same byte count:

```
s->s.chars().map(c->c&~32).distinct().filter(c->c>64&c<91).count()>25
s->s.chars().map(c->c|32).distinct().filter(c->c>96&c<123).count()>25

```

Try it online.

Similar to *@ProgramFOX*' C# answer.
> 2 votes

# Answer
# Perl 5 `-p`, ~~30~~ 28 bytes

```
@a{lc=~/[a-z]/g}++;$_=26==%a

```

Try it online!
> 2 votes

# Answer
# PHP, ~~59~~ 56 bytes

```
<?=!array_diff(range(a,z),str_split(strtolower($argn)));

```

Try it online!

Alt version **67 bytes**

```
<?=array_intersect($a=range(a,z),str_split(strtolower($argn)))==$a;

```

Try it online!

Call with `php -nF` input is from `STDIN`.
> 2 votes

# Answer
# MathGolf, ~~11~~ 7 bytes

```
!▀_▄+▀=

```

Try it online!

## Explanation

MathGolf just got a lowercase operator!, `!` is the factorial operator for ints, floats and lists, but now it also works as a lowercase operator for strings.

```
!          convert input to lowercase
 ▀         get unique characters as string
  _        duplicate
   ▄+      add the lowercase alphabet to the second copy
     ▀=    get unique elements and check that they are unchanged

```
> 2 votes

# Answer
# GolfScript, 18 bytes

Port of the GS2 answer.

```
{32|}%[123,97>]\-!

```

Try it online!

## Explanation

```
{   }%             # Map for every item in input
 32|               # Toggle the 6th bit (turning capitalization on)
      [123,        # Generate exclusive range from '}' (previous 'z') to 0
           97>]    # Select all that are >= 'a'
                   # Yielding the lowercase alphabet
               \-  # Set difference between them
                 ! # Negate the value

```
> 2 votes

# Answer
# Dyalog APL, 13 bytes

```
∧/⎕A∊1(819⌶)⊢

```

explanation:

```
1(819⌶)⊢ ⍝ uppercase
⎕A∊      ⍝ check if all uppercase letters belong to the string
∧/        ⍝ AND reduction of the boolean vector

```
> 2 votes

# Answer
# Kotlin, 47 bytes

```
{s:String->('a'..'z').all{s.contains(it,true)}}

```

Try it online!
> 2 votes

# Answer
# C# (Visual C# Interactive Compiler), 48 bytes

```
x=>x.ToUpper().Distinct().Count(c=>c>64&c<91)>25

```

Try it online!
> 2 votes

# Answer
# Husk, 9 bytes

```
¦m_⁰…'a'z

```

Try it online!

## Explanation

```
¦m_⁰…'a'z
    …'a'z inclusive range from a to z
 m_⁰      convert input to lowercase
¦         are all alphabets present in it?

```
> 2 votes

# Answer
# Perl 5 `-MList::Util=uniq -p0`, 22 bytes

```
$_=26==uniq uc=~/\pL/g

```

Try it online!
> 2 votes

# Answer
# Jelly, ~~7~~ 6 bytes

```
ŒlØaḟṆ

```

Try it online!

Unless I'm missing something, this is the first jelly answer here.

*-1 thanks to the Jelly gurus (caird/chartz and unrelatedstring) in the JHT chat room. Y'all are poggers.*

## Explained (old)

```
ŒlQṢØaẇ → a monadic link. Takes a single string as input. We will call that string "S". The flow value of the chain starts as S.
Œl      → The lower case atom. The flow value of the chain is now S.lowercase()
  Q     → The uniquify atom. The flow value of the chain is now unique_elements(S.lowercase())
   Ṣ    → The sort atom. The flow value is now sorted(unique_elements(S.lowercase()))
    Øaẇ → A nilad-dyad pair of the lower case alphabet atom and the is sublist atom. ẇ requires the needle to search for to be on the left and the haystack to search to be on the right. The flow value is now "abcd...xyz" in sorted(unique_elements(S.lowercase())). This consequently has the effect of testing if S, when sorted and case ignored, has every letter of the alphabet.

```

Explanation of the 6 byter coming in maybe 12 hours.
> 2 votes

# Answer
# Zsh `--nocaseglob`, 19 bytes

```
>_${1//\/}<*{a..z}*
```

Attempt This Online!

Outputs via exit code: 0 for pangram, 1 for non-pangram

If we don't have to handle the empty string, then the `_` can be removed for -1 byte.

If we don't have to handle strings with slashes in them, the `${1//\/}` can be changed to just `$1` for -6 bytes:

## Zsh `--nocaseglob`, 12 bytes

```
>$1<*{a..z}*
```

Attempt This Online!

Zsh ties APL and K, and beats J??

## Explanation

* `$1`: input
* `//\/`: remove all slashes (because filenames can't contain them)
* `_`: prepend underscore (because you can't create files with empty names, so we have to ensure it is non-empty)
* `>`: create a file with that name
* `<*{a..z}*`: search for files matching each of the patterns `*a*`, `*b*`, etc.

This effectively checks that the created file contains each letter between `a` and `z`. If any check fails, the program with exit with status code 1. Otherwise, it exits with 0.
> 2 votes

# Answer
# Prolog (SWI), 103 bytes

```
_^[].
S^[H|T]:-member(H,S),S^T.
\B:-string_lower(B,O),string_codes(O,C),C^`abcdefghijklmnopqrstuvwxyz`.

```

Try it online!
> 2 votes

# Answer
# Kotlin, 56 bytes

```
{print(('A'..'Z').all{a->it.toUpperCase().contains(a)})}

```

Using a list of characters where every character has to be found within the input.

Try it online!
> 2 votes

# Answer
# APL, 10 bytes

```
∧/⊃∊/⎕C⎕A⍞

```

Explanation:

```
⍞   ⍝ Character input and…
⎕A  ⍝ …alphabet are enclosed into a nested array
⎕C  ⍝ Convert both to lower case
∊/  ⍝ Put membership function between them
⊃   ⍝ Disclose the nested array
∧/  ⍝ Reduce by conjuction

```
> 2 votes

# Answer
# K (ngn/k), 13 bytes

```
~#(!26)^97!_:

```

Try it online!

* `_:` lowercase the (implicit) input
* `97!` mod the ASCII character codes by 97 (so `a` becomes `0`, `f` `6`, `z` `25`, etc. etc.)
* `(!26)^` remove the character codes that are present from `0..25`
* `~#` do any character codes corresponding to letters remain?

An alternative 14-byte answer is:

```
~26-/~"a{"'?_:

```

Try it online!

* `?_:` get the distinct lowercased characters in the input
* `~"a{"'` identify which characters in the input are letters (`1` in the resulting bitmask) and which are not letters (these become `0`s)
* `~26-/` `not` the result of a minus-reduce seeded with `26` (if all letters are present in the input, this will return `1`, and otherwise `0`)
> 2 votes

# Answer
# JavaScript (ES6), 80

I wrote out a solution virtually identical to edc65's entry before I scrolled to the bottom of the page and saw it was already there! Anyway, here's still another alternate JavaScript approach:

```
s=>[...Array(26)].every((v,i)=>~s.search(RegExp(String.fromCharCode(i+65),"i")))

```

My original solution (83) with `toUpperCase`, before I got the idea to use a case-insensitive `RegExp` from Cᴏɴᴏʀ O'Bʀɪᴇɴ's solution:

```
s=>[...Array(26)].every((v,i)=>~s.toUpperCase().indexOf(String.fromCharCode(i+65)))

```

The code uses `every` to test whether or not every value of `i` from `0` to `25` casues the expression `String.fromCharCode(i+65)` to produce a character that exists in the input string (according to a case-insensitive match).
> 1 votes

# Answer
# Java, ~~97~~ 96 bytes

```
boolean s(String t){for(int a=65;++a<91;)if(t.toUpperCase().indexOf(a)<0)return 1<0;return 0<1;}

```

Assumes ASCII or compatible character encoding.

It loops over the capital letters (65-90), checking if each one is present with `indexOf`, which takes an `int`.
> 1 votes

# Answer
# Mathematica, 44 bytes

```
Characters@ToLowerCase@#~SubsetQ~Alphabet[]&

```

Usage:

```
In[1]:= Characters@ToLowerCase@#~SubsetQ~Alphabet[]&[
         "The quick brown fox jumps over the lazy doge."]

Out[1]= True

```
> 1 votes

# Answer
# PHP, 92 bytes

The code:

```
echo!array_diff(range(a,z),array_keys(array_count_values(str_split(strtolower($argv[1])))));

```

There is not much golfing in it (the clear code is 102 bytes).

Prepend it with the PHP marker `<?php`  (technically, it is not part of the code), put it into a file (`is-it-a-pangram.php`) and run it like:

```
$ php -d error_reporting=0 is-it-a-pangram.php '123abcdefghijklm NOPQRSTUVWXYZ321'

```

Or put the code directly in the command line:

```
$php -d error_reporting=0 '... the code here ...' AbCdEfGhIjKlMnOpQrStUvWxYz

```

It outputs `1` when the input string is a pangram; it doesn't output anything when the string is not a pangram. This is the default representation for boolean values in PHP.

An unambiguous output can be obtained by adding a `+` sign in front of the echo-ed expression (`echo+!array_diff(...);`). This way, the boolean value is converted to an integer (`1` or `0`).

### How the code works

It makes the input string lowercase, splits it to individual characters, count the number of occurrences for each character that appears in the string, then makes the difference between the alphabet characters (`a` to `z`) and the characters found in the string. If the difference is not empty then not all the letters are found in the string (i.e. the string is not a pangram).

The code and the testcase (using the samples provided in the question) can be found on Github.
> 1 votes

# Answer
# R, ~~97~~ 92 bytes

Not competing with @mnel's excellent answer, but nevertheless :

```
function(s){a=strsplit(s,"")[[1]];m=match;sum(unique(c(m(a,letters,0),m(a,LETTERS,0))))=351}

```

This function takes your input, breaks it into its letters (`strsplit`), matches (`match` function, obviously) each letters of the input with both `letters` and `LETTERS`, built-in constant containing lowercases and uppercases letters. The unmatched positions are replaced with `0`'s.

Then, it eliminates all the redundant positions (`unique`), and make their sum. Considering there are 26 letters in the alphabet and the 1-indexed positions in **R**, if all the letters are contained at least once in your input, the sum of their positions will be `1+2+...+25+26`, which is `351`

*\- 5 bytes* thanks to @plannapus !
> 1 votes

# Answer
# Japt `-!`, ~~6~~ 4 bytes

```
;CkU

```

Try it here
> 1 votes

# Answer
# APL(NARS), 22 chars, 44 bytes

```
{∧/×↑+/↑¨{+/⍵=⎕a⎕A}¨⍵}

```

test:

```
  h←{∧/×↑+/↑¨{+/⍵=⎕a⎕A}¨⍵}
  h 'abcdefghijklmnopqrstuvwXYZ'
1
  h '123abcdefghijklm NOPQRSTUVWXYZ321'
1
  h 'public static void main(String[] args)'
0
  h 'The quick brown fox jumped over the lazy dogs. BOING BOING BOING'
1

```
> 1 votes

# Answer
# Charcoal, ~~9~~ 6 bytes

```
⬤β№↧θι

```

Try it online! Link is to verbose version of code. Outputs a Charcoal boolean (`-` for true, nothing for false). Just checks that each lowercase letter appears at least once in the lowercase input Explanation:

```
 β      Lowercase alphabet
⬤       All characters satisfy
  №     (Non-zero) count of
     ι  Current lowercase letter in
    θ   First input
   ↧    Lowercased
        Implicitly print

```
> 1 votes

# Answer
# Burlesque, 16 bytes

```
zzXX@azr@Jx/IN=s

```

Try it online!

```
                                                 [IN]
zz    # Lowercase input                          [in]
XX    # Split into characters                    [i,n]
@azr@ # Push lowercase alphabet                  [i,n],[a,..,z]
Jx/   # Duplicate and bring the input to the top [a,..,z],[a,..,z],[i,n]
IN    # Intersection of the two                  [a,..,z],alpha IN input
=s    # Is equal to the alphabet when sorted     1/0

```
> 1 votes

# Answer
# Stax, 5 bytes

```
é►Ö_Z

```

Run and debug it
> 1 votes

# Answer
# **BaCon, 49 bytes**

?IIF(AMOUNT(UNIQ$(EXPLODE$(LCASE$(s$))))\>25,1,0)
> 1 votes

# Answer
# Factor \+ `math.unicode`, ~~34~~ 23 bytes

```
[ >lower ALPHABET ⊃ ]

```

Try it online!

*-11 bytes thanks to @Bubbler!*

## Explanation:

This is a quotation (anonymous function) that takes a string as input and leaves a boolean value as output.

* `>lower` Convert a string to lowercase.
* `ALPHABET` Push a string containing the lowercase alphabet to the data stack.
* Is the input a superset of the alphabet?
> 1 votes

# Answer
# C, 87 bytes

For platforms that use ASCII character coding.

```
f(char*s){char*t=s,i,r=0;for(;*t;)*t++|=32;for(i=97;i<123;)r|=!strchr(s,i++);return!r;}

```

This first modifies the input string to make it all lower-case (it doesn't matter what happens to non-letters, as they will not become letters or NUL). Then we test each lower-case letter to see whether it's present.

For an EBCDIC version, we need to replace `*t++|=32;` with `*t++|=64;` and `for(i=97;i<123;)` with `for(i=193;i<234;i+=7*(i&16==9)+i==161)`.

Simple test program:

```
#include<stdio.h>
int main(int argc, char **argv)
{
    while (*++argv) {
        printf("%s: ", *argv);
        printf("%s\n", f(*argv) ? "Yes" : "No");
    }
}

```

Online test
> 1 votes

# Answer
# Scratch, 145 bytes

```
define(s
set[z v]to[abcdefghijklmnopqrstuvwxyz
set[i v]to[
set[o v]to[1
repeat[26
change[i v]by(1
set[o v]to((o)*<(s)contains(letter(l)of(z
say(o

```

Uses scratchblocks syntax.

Function should have "Run before screen refresh" checked. Defines a function with an empty name and one argument (`s`). Output is `1` if `s` is a pangram and `0` if it is not.

`<[]contains[]>` works in scratchblocks syntax (which I used), but `<[]contains[]?>` is used in Scratch. This adds an extra byte, but because I'm using scratchblocks syntax, I don't think it should count.
> 1 votes

# Answer
# C, 64 bytes

```
n=63<<26;f(char*s){while(*s)n|=1<<(tolower(*s++)-97);return!~n;}

```

### Explanation

* Create a mask of 32-26 = 0b111111 = 63 and shl by 26 (you will understand why) with `n=63<<26;`
* Iterate over string, set bit at index `tolower(*s) - 'a'` with `while(*s)n|=1<<(tolower(*s++)-97);`
*NB: Characters beyond 'z', `{|}~`, do not matter, as flags are already set.*
* Reverse all bits with `~`, if all letters were encountered it should give 0, else it would give value of all letters that were missing in the char array. We return the opposite with `!`, so it becomes true if it is a pangram, else false.
> 1 votes

# Answer
# JavaScript (ES9), 38 bytes

```
a=>a.match(/$|([A-Z])(?!.*\1)/igs)[25]

```

Try it online!

`$|` just to not crash if there's no letter. Worth mentioned competitor
> 1 votes

# Answer
# Fig, \\$9\log\_{256}(96)\approx\\$ 7.408 bytes

```
lca+//KUa

```

Try it online!

Returns `-1` for falsy, and a non-negative integer for truthy.
> 1 votes

# Answer
# Uiua, ~~17~~ 14 bytes

```
/↧/↥∊⊠+"aA"⇡26

```

Try it!

-3 thanks to Lynn

```
/↧/↥∊⊠+"aA"⇡26
           ⇡26  # 0..25
     ⊠+"aA"     # get lowercase and uppercase alphabet
    ∊           # masks of which letters are in the input
  /↥            # max of each column
/↧              # minimum

```
> 1 votes

# Answer
## Seriously, ~~14~~ ~~13~~ 12 bytes

```
,ûOk"A["Ox-Y

```

Hex Dump:

```
2c964f6b22415b224f782d59

```

Try it online!

Explanation:

```
,                  read in the string from stdin
 û                 make it uppercase
  O                push all the character codes to the stack
   k               listify the stack
    "A["           push this string
        O          pop it and push all of its character codes
         x         push range(65,91)
          -        do set subtraction with the lists
           Y       logical not the result (so a zero length list becomes 1)

```

EDIT: moved input to the beginning to save a byte, thanks to @Mego
> 0 votes

# Answer
# Bash 4+, ~~86~~ 48 bytes

Thanks to @Dennis for saving me 38 bytes!

Since return codes are what's checked by `test`/`[` for truthy-ness in bash, the return code should be valid truthy/falsy output, right? If not, I'll edit to echo more typical truthy/falsy values (since bash true/false values are inverted compared to most things)

```
for x in {a..z}
{ [[ ${1,,} =~ $x ]] || exit 1
}

```
> 0 votes

# Answer
# Ruby, ~~39~~ 33 bytes

This is the case insensitive version.

```
->s{(?a..?z).all?{|x|s[/#{x}/i]}}

```

---

# Ruby, 32 bytes

### Invalid (lowercase only)

No one has posted a ruby answer yet, so I made this. Nice and simple.

```
->s{(?a..?z).all?{|x|s.index x}}

```
> 0 votes

# Answer
## C, 97 bytes

```
c;t=26;i=26;f[26];p(char*s){while(*s)(c=*s++&~32-65)>=0&c<t?f[c]=1:0;while(i)t-=f[--i];return!t;}

```

Assumes ASCII or compatible character encoding.

C is not the best tool when it comes to string-related golf, nevertheless it was fun to code.

Globals are not reset, so this function will work as expected only once, but, hey, nobody said it should work the second time! ;-)

Test main:

```
#include <stdio.h>

int main(int argc, char **argv) {
  if (argc < 2) {
    fprintf(stderr, "Usage: %s <phrase>\n", argv[0]);
    return 1;
  }

  printf("%d\n", p(argv[1]));
}

```
> 0 votes

# Answer
# SpecBAS - 107 bytes

```
1 INPUT a$: LET a$=UP$(a$),c=0
2 FOR EACH l$ IN ["A" TO "Z"]: IF POS(l$,a$)>0 THEN INC c: NEXT l$
3 TEXT c=26

```

Set a counter to 0, loops through "A" to "Z" and increments the counter if found. Prints 0 (false) or 1 (true) if counter is 26.
> 0 votes

# Answer
# Mumps, 86 bytes

```
R S F I=65:1:90{S J(I)=0} F I=1:1:$L(S){S Q=$A($E(S,I)) S:Q>92 Q=Q-32 K J(Q)} W '$D(J)

```

I built an array of nodes with all the ordinals of upper case characters, took the ordinal of each character in the string, converted lowercase to uppercase if necessary, and killed the associating node in the array. Here's my routine a bit more 'ungolfed':

```
R S                   ; Read STDIN into S
F I=65:1:90{S J(I)=0} ; Create an array of J() with all the uppercase ASCII ordinals
F I=1:1:$L(S)         ; loop through the # of characters in S
    {S Q=$A($E(S,I))  ; Set Q=the ordinal number of each character
    S:Q>92            ; if Q>92 (above the upper case, below the lower case ordinals
    Q=Q-32            ; subtract 32 from Q to convert to upper case.
    K J(Q)}           ; Kill the J(Ordinal) node of the array.
    W '$D(J)          ; $D will output False if there's no nodes in the array, true if some remain. \
                      ; write out the binary 'NOT' of this value.

```

The braces enable one-liners a bit more easily *(multiple lines could add a few characters)* and is a function of InterSystems Cache's version of Mumps.
> 0 votes

# Answer
# R, 77 bytes

```
g=function(x){length(intersect(unlist(strsplit(tolower(x),"")),letters))==26}

```

### Test cases:

```
> g("AbCdEfGhIjKlMnOpQrStUvWxYz")
[1] TRUE
> g("ACEGIKMOQSUWY
+ BDFHJLNPRTVXZ")
[1] TRUE
> g("public static void main(String[] args)")
[1] FALSE
> g("The quick brown fox jumped over the lazy dogs. BOING BOING BOING")
[1] TRUE
> g("")
[1] FALSE

```
> 0 votes

# Answer
# Groovy, 57 bytes

```
u={print it.toLowerCase().toList().containsAll('a'..'z')}

```

Will groovy ever win?
> 0 votes

# Answer
## C++, 121 bytes

```
int P(char *s){int c;bitset<26> a;while(c=*s){c=tolower(c)-'a';if(c>=0&&c<26)a.set(c);if(a.all())return 1;s++;}return 0;}

```
> 0 votes

# Answer
# 32-bit x86 machine code, 27 bytes

In hex:

```
31c031d2ac48780d344024df3c1977f40fabc2ebef31d0c1e006c3

```

Input: `ESI`: NULL-terminated string. Returns: `EFLAGS.ZF` (`1`=truthy, `0`=falsey).

```
0:  31 c0               xor eax, eax
2:  31 d2               xor edx, edx  ;Bit array to keep track of letters
_loop :
4:  ac                  lodsb         ;Read next char
5:  48                  dec eax       ;Align 'A' to the power of two boundary, i.e. 0x40
6:  78 0d               js _break     ;...which also tests for NULL
8:  34 40               xor al, 0x40  ;Swap block [0x40..0x7f] (with letters) with [0..0x3f]
a:  24 df               and al, 0xdf  ;Map [0x60..0x7f] to [0x40..0x5f], that's toupper()
c:  3c 19               cmp al, 25    ;Letter are now in the [0..25] range
e:  77 f4               ja _loop      ;Anything else is greater if taken as unsigned
10: 0f ab c2            bts edx, eax  ;Set AL-th bit in EDX
13: eb ef               jmp _loop
_break :
15: 31 d0               xor eax, edx  ;EAX=~EDX (EAX==-1 here), for pangram EDX==0x03FFFFFF
17: c1 e0 06            shl eax, 6    ;Shift out 6 unused bits. EFLAGS.ZF=EAX<<6==0?1:0
1a: c3                  ret

```
> 0 votes

# Answer
# Javascript (using external library - Enumerable) (83 bytes)

```
 n=>_.From("abcdefghijklmnopqrstuvwxyz").All(x=>_.From(n.toLowerCase()).Contains(x))

```

Link to library: https://github.com/mvegh1/Enumerable

Code explanation: Load the lowercase alphabet as char array, then test that every single char is contained in the lowercased input
> 0 votes

# Answer
# K4, 12 bytes

**Solution**

```
&/.Q.a in\:_

```

**Examples:**

```
q)k)&/.Q.a in\:_"AbCdEfGhIjKlMnOpQrStUvWxYz"
1b
q)k)&/.Q.a in\:_"ACEGIKMOQSUWY\nBDFHJLNPRTVXZ"
1b
q)k)&/.Q.a in\:_"public static void main(String[] args)"
0b
q)k)&/.Q.a in\:_"The quick brown fox jumped over the lazy dogs. BOING BOING BOING"
1b

```

**Explanation:**

Lowercase the input, check whether each letter in `a..z` is in this. Take the min.

```
&/.Q.a in\:_ / the solution
           _ / lowercase
       in\:  / apply in to left and each-right (\:)
  .Q.a       / "abcdefghijklmnopqrstuvwxyz"
&/           / take the minimum

```
> 0 votes

# Answer
# Smalltalk, 44 bytes

```
(($ato:$z)intersection:s asLowercase)size=26

```
> 0 votes

# Answer
# 05AB1E, 5 bytes

```
lA€åP

```

Try it online!

```
lA€åP  # full program
    P  # product of...
  €    # each letter of...
 A     # "abcdefghijklmnopqrstuvwxyz"...
   å   # in...
       # implicit input...
l      # in lowercase
       # implicit output

```
> 0 votes

# Answer
# Pxem, Filename: 118 bytes + Content: 0 bytes = 118 bytes.

* Filename: `@@€€.!.!.!.cX.w.i.c`\``.x .-XX.a.c@.x.c[.yA.-.t.m.w.!.m.-.c.t.a.t.c.m.$.%.z.m.+XX.aXX@.aXX.a.+.a.t.!.-.m.z.d.aY.o`
    + Escaped: `\100\100\200\200.!.!.!.cX.w.i.c\140.x\040.-XX.a.c@.x.c[.yA.-.t\001.m.w\002.!\001.m.-.c.t.a.t.c.m.$\002.%\001.z.m.+XX.aXX@.aXX.a\001.+.a.t\002.!\001.-.m.z.d.aY.o`
* Content: empty.

Try it online!

## Usage

* Input from stdin
* `Y` to stdout for truthy, no output for falsey

## With comments

```
XX.z
# push 2^26; dup; push non-zero value;
## NOTE 2^26 is initialized table
# while empty||pop!=0; do
.a\100\100\200\200.!.!.!.cX.wXX.z
  # push getchar
  .a.iXX.z
  ## NOTE capitalizing here
  .a.c\140.x\040.-XX.aXX.z
  # if isalpha top; then
  .a.c@.x.c[.yXX.z
      # let c is difference between 'A' and the character
      .aA.-.tXX.z
      # let m is 1; what digit to see
      ## NOTE m==2^c
      .a\001.m.w\002.!\001.m.-.c.t.aXX.z
      ## NOTE actual updating table
      # if tbl&m!=1; then tbl&=m; fi
      ## NOTE no logical operators
      .a.t.c.m.$\002.%%\001.z.m.+XX.aXX.z
      # push rando character and get out
      .aXX@.aXX.z
  .aXX.aXX.z
  # get out if EOF (-1)
.a\001.+.aXX.z
# finally: if tbl==2^27-1; then putchar Y; fi
.a.t\002.!\001.-.m.z.d.aY.o

```
> 0 votes

# Answer
# PHP, 172 bytes

```
function is_pangram ($s) {
return  preg_match("#^".implode(
   array_map(function ($x) {return "(?=.*{$x})" ;} ,
   str_split("ABCDEFGHIJKLMNOPQRSTUVWXYZ")))."#uis", $s);
}

```
> -1 votes

---
Tags: code-golf, string, decision-problem
---


title: In Search of a Soulmate

text:
# Question
Title: In Search of a Soulmate
Given a nonempty finite list of integers, output a *truthy* value if there are exactly two equal entries and all other entries are distinct, and a *falsey* value otherwise.

### Examples

```
truthy:
[1,1]
[1,2,1]
[1,6,3,4,4,7,9]

falsey:
[0]
[1,1,1]
[1,1,1,2]
[1,1,2,2]
[2,1,2,1,2]
[1,2,3,4,5]

```

# Answer
> 23 votes
# Python 3, ~~30~~ 28 bytes

```
lambda m:len({*m})+1==len(m)

```

Try it online!

`{*m}` casts the list to a `set` object, an unordered list of items without duplicates. Doing this will always decrease the length of the list by the number of duplicates in it. By computing how much the length has changed, we can easily tell if the list had a single duplicate and return the result of the test.

-2 bytes thanks to ovs.

# Answer
> 11 votes
# Husk, 4 bytes

```
εṠ-u

```

Try it online!

## Explanation

```
εṠ-u  Implicit input.
   u  Unique elements.
 Ṡ-   Delete them from input, counting multiplicities.
ε     Is the result a singleton list?

```

# Answer
> 8 votes
# Haskell, 34 bytes

```
f x=[1|a<-x,b<-x,a==b]==1:1:(1<$x)

```

Try it online! Based on H.PWiz' answer.

# Answer
> 7 votes
# Jelly, ~~8~~ 5 bytes

```
QL‘=L

```

Try it online!

# Explanation

```
QL‘=L  - Main link, argument L (a list)   e.g [1,6,3,4,4,7,9]
Q      - Deduplicated elements                [1,6,3,4,7,9]
 L     - Length                               6
  ‘    - Increment                            7
    L  - Length of the input                  7 ([1,6,3,4,4,7,9])
   =   - Are they equal?                      1

```

If the output values can be any consistent values, then `QL_L` works, which outputs `-1` for truthy and any other non-positive number for falsey (thanks @JonathanAllan)

# Answer
> 7 votes
# MATL, ~~7~~, 6 bytes

```
&=sp4=

```

Try it online!

One byte saved thanks to @Guiseppe!

Explanation:

```
&=  % Table of pair-wise equality comparisons
    %
    % [1 0 0 0 0 0 0
    %  0 1 0 0 0 0 0
    %  0 0 1 0 0 0 0
    %  0 0 0 1 1 0 0
    %  0 0 0 1 1 0 0
    %  0 0 0 0 0 1 0
    %  0 0 0 0 0 0 1]
    %
s   % Sum each Column. Stack:
    %
    % [1 1 1 2 2 1 1]
    %
p   % Product of the array. Stack:
    %
    % [4]
    %
4=  % Compare the stack to '4'

```

# Answer
> 5 votes
# JavaScript (ES6), 30 bytes

```
a=>new Set(a).size==a.length-1

```

Try it online

# Answer
> 4 votes
## Retina, ~~15~~ ~~12~~ 11 bytes

*Thanks to Neil for saving 1 byte.*

```
D`
Mm2`^$
1

```

Try it online!

Input is linefeed-separated. (The test suite uses comma-separation for convenience.)

### Explanation

```
D`

```

Deduplicate the lines in the input, which removes any integer that has appeared before (but leaves the surrounding linefeed(s)).

```
Mm2`^$

```

Count the number of empty lines, which is equal to the number of duplicates we removed, but only consider the first two matches. So the output will only be `0` (no duplicates), `1` (one duplicate), `2` (two or more duplicates).

```
1

```

Make sure that exactly one duplicate was removed.

# Answer
> 4 votes
# , ~~7~~ 6 bytes

```
=&#0,=

```

`=` check every element for equality with every unique element, creates a matrix with **m** rows for **m** unique elements.
`0,` add an empty row on top.
`=&#` does the number of rows equal the length of input?

Try it online!

# Answer
> 4 votes
# Octave, 25 bytes

This is not using a `group` or `unique` approach as many of the other answers, but rather the "cartesian product" of all possible comparisions.

```
@(x)nnz(triu(x==x',1))==1

```

### Explanation

```
             x==x'        %create a matrix where the entry at (i,j) compares whether x(i) == x(ju)
        triu(x==x',1)     %only consider the strict upper triangular matrix
    nnz(triu(x==x',1))    %count the number of nonzero entries
@(x)nnz(triu(x==x',1))==1 %check whether this number is actually 1

```

Try it online!

And because no program would be complete without a convolution (thanks @LuisMendo for fixing a mistake):

# Octave, 40 bytes

```
@(x)nnz(~conv(sort(x),-1:2:1,'same'))==1

```

Try it online!

# Answer
> 4 votes
# Pushy, 8 bytes

Simple implementation of checking whether `len(set(list)) == len(list)-1`:

```
LtvuL^=#

```

Explanation:

```
       \ Implicit: Put all input on stack
Ltv    \ Get the stack length - 1, save in auxiliary stack
u      \ Remove non-unique elements
L      \ Get the new length
^=     \ Compare with the previously saved length
#      \ Print result

```

This works as the length will only decrease by 1 if there was only exactly 1 non-distinct integer in the initial list.

Try it online!

# Answer
> 4 votes
# , ~~32~~ 31 bytes

*-1 byte thanks to @JarkoDubbeldam*

```
cat(sum(duplicated(scan()))==1)

```

Try it online!

Reads from stdin, writes to stdout.

`duplicated` iterates through the list, replacing the values of `l` with `TRUE` if that value occurs earlier in the list, and `FALSE` otherwise. If there's a unique pair of soulmates, there should be exactly one `TRUE` value, so the sum should be `1`.

# Answer
> 4 votes
# K (ngn/k), 10 bytes

```
1=-/#'1?:\

```

Try it online!

A tacit version of `{1=(#x)-#?x}`.

* `1?:\` run a distinct-do-scan for one iteration, returning a two-item list containing the original input and the distinct items of the input
* `#'` take the count/length of each item in that list
* `1=-/` is the difference between the counts one?

# Answer
> 4 votes
# K (ngn/k), 8 bytes

```
2=*/#'=:

```

Try it online!

Checks if the product of the counts of unique elements is 2. This works because the only way to get the product of 2 is (1, 1, 1, ..., 1, 2) in some order.

# Answer
> 3 votes
# PowerShell, ~~40~~ 37 bytes

```
($args|sort -u).count-eq$args.count-1

```

Try it online!

The `Sort-Object` command (alias `sort`) with the `-u`nique flag pulls out only the unique components of the input. For example, for input `@(1,3,3,2)`, this will result in `@(1,2,3)`.

Thus, we just need to make sure that the `.count` of this object (i.e., how many elements it has) is `-eq`ual to the `.count` of our input array `-1` (i.e., we have exactly one duplicate entry).

*Saved 3 bytes thanks to Sinusoid.*
*Fixed bug thanks to TessellatingHeckler.*

# Answer
> 3 votes
# 05AB1E, 4 bytes

```
{¥_O

```

Try it online!

Outputs `1` as truthy, any other non-negative integer as falsy. In 05AB1E, `1` is the only truthy number (thanks @Emigna for the insight!).

### Explanation

```
{       Implicit input. Sort
 ¥      Consecutive differences
  _     Boolean negate
   O    Sum. Implicit display

```

# Answer
> 3 votes
# Ruby, 32 bytes

```
->(s){s.uniq.length==s.length-1}

```

# Answer
> 3 votes
# Pyth, 6 bytes

```
qtlQl{

```

**Verify all the test cases.**

* `l{` \- Gets the number of unique elements.
* `tlQ` \- Gets the length of the input list, decremented.
* `q` \- Checks equality.

# 7 bytes

```
q1l.-Q{

```

**Verify all the test cases**

# Answer
> 3 votes
# C# (.NET Core), 35 + 18 bytes

+18 for using `System.Linq`.

```
n=>n.Distinct().Count()==n.Length-1

```

Try it online!

**67 byte alternative without Linq:**

```
n=>new System.Collections.Generic.HashSet<int>(n).Count==n.Length-1

```

Try it online!

# Answer
> 3 votes
## Excel, 42 bytes

**Danish language version**

```
=TÆLV(A:A)=SUM(--(FREKVENS(A:A,A:A)>0))+1

```

Assumes each integer from the list in separate cell in column `A`.
If we were allowed for inconsistent *falsey* values, we could save 3 bytes:

```
=TÆLV(A:A)+SUM(-(FREKVENS(A:A,A:A)>0))

```

**English language version (44 bytes)**

```
=COUNTA(A:A)=SUM(--(FREQUENCY(A:A,A:A)>0))+1

```

# Answer
> 2 votes
# Jelly, 10 bytes

```
ċ@€`QṢ⁼1,2

```

Try it online!

a longer but different approach

# Answer
> 2 votes
# 05AB1E, ~~6~~ 5 bytes

```
{¥>ΘO

```

Try it online!

```
{¥>ΘO   # example input:               [1, 6, 3, 4, 4, 7, 9]
{       # sort                      -> [1, 3, 4, 4, 6, 7, 9]
 ¥      # get deltas                -> [  2, 1, 0, 2, 1, 2 ]
  >     # increment                 -> [  3, 2, 1, 3, 2, 3 ]
   Θ    # truthify (only 1 gives 1) -> [  0, 0, 1, 0, 0, 0 ]
    O   # sum                       -> 1

```

`1` being the only truthy value in 05AB1E, we can stop here. (Thanks @Emigna for pointing that out.)

To get only two distinct values, we can optionally add:

```
     Θ  # equals 1?                 -> 1

```

# Answer
> 2 votes
# Haskell, 37 bytes

```
f x=sum[1|0<-(-)<$>x<*>x]==2+length x

```

Try it online!

# Answer
> 2 votes
# Perl 5, 36 + 1 (`-a`) = 37 bytes

```
map$k{$_}++,@F;@a=keys%k;say@a+1==@F

```

Try it online!

# Answer
> 2 votes
# 05AB1E, 5 bytes

```
gIÙg-

```

Try it online!

```
g     # Get number of elements in input
 IÙg  # Get number of unique elements in input
    - # Subtract

```

In 05AB1E 1 is the only truthy value, so for a truthy result there must be exactly 1 duplicate element removed by the uniquify.

# Answer
> 2 votes
# Haskell, 37 bytes

```
f x=sum[1|a<-x,b<-x,a==b]==2+length x

```

Try it online!

# Answer
> 2 votes
# Octave / MATLAB (with Statistics package / toolbox), 21 bytes

```
@(x)nnz(~pdist(x))==1

```

Anonymous function. Input is a column vector. Output is `true` (displayed as `1`) or `false` (displayed as`0`).

**Try it online!**

### Explanation

`pdist(x)` computes a vector of Euclidean distances between all pairs of rows from `x`. It considers each pair only once (order of the two rows doesn't matter), and doesn't consider pairs formed by the same row twice.

In our case `x` is a column vector, so Euclidean distance between two rows is just absolute difference between the two numbers.

`~` is logical (Boolean) negation, `nnz` is number of nonzeros, and `==1` compares to `1`. So the result is `true` if and only if there is only one pair that gives zero distance.

# Answer
> 2 votes
# Julia, ~~39~~ 26 bytes

```
!a=sum(a.==a')==endof(a)+2

```

## Explanation

The code generates a 2-dimensional table of booleans, which is then collected using the sum function, counting the number of same-element pairs in the cartesian square of A. Then this is compared to the length of the string plus two, and the quantities are equal only when there is exactly one repeat character.

This code redefines the NOT operator.

# Answer
> 2 votes
# Jq 1.5, ~~53~~ 25 bytes

```
length-(unique|length)==1

```

Inspired by Riley's answer and much shorter then my original solution.

Try it online!

# Answer
> 2 votes
# Octave, ~~23~~ 26 bytes

```
@(x)prod(sum(x==x'))==4

```

Try it online!

The `x==x'` part was inspired by flawr's answer. This is longer than Luis' answer, but it doesn't use any toolboxes.

### Explanation:

This is an anonymous function that takes a vector `x` as input, and compares it to itself transposed. This will give a matrix where all diagonal elements are `1`, and any off diagonal elements signals that there are duplicates elements.

The sum along any given column shows how many duplicates there are of that number. We want two of the numbers to have a duplicate, so we two values equal to two, and the rest unequal to two.

If we take the product of this matrix, we'll get `4` if there are only two equal elements (`2*2*1*1*1*1*...`), and something other than `4` if there are no duplicates, or more than two.

# Answer
> 2 votes
# PHP, 46 bytes

```
<?=count(array_unique($argv))==count($argv)-1;

```

Counts the number of entries in `$argv` and compares it to the number of unique entries. If the former is higher than the latter by 1 then truthy, else falsey.

Try it on eval.in!

# Answer
> 2 votes
# APL (Dyalog Unicode), 7 bytesSBCS

```
1=≢-≢∘∪

```

Try it online!

Explanation:

```
1=≢-≢∘∪  ⍝ Monadic function train
    ≢∘∪  ⍝ Generate a list of unique items in the input,
         ⍝ and return the length of that list
  ≢-     ⍝ Take the length of the input and subtract the above
1=       ⍝ If the difference is 1, true, otherwise false

```

# Answer
> 2 votes
# Uiua, 7 bytes

```
=1-⧻⊃⊝⧻

```

Try it!

```
=1-⧻⊃⊝⧻
    ⊃⊝⧻  # length and unique elements of input
   ⧻     # length (of unique elements)
  -      # subtract
=1       # is it equal to one?

```

# Answer
> 1 votes
# Japt, 7 bytes

```
â Ê¶UÊÉ

```

Try it

---

## Explanation

Remove duplicates (`â`), get length (`Ê`) and compare equality () with the length (`Ê`) of the input (`U`) minus 1 (`É`).

# Answer
> 1 votes
# Bash \+ coreutils, 36 bytes

```
sort|uniq -dc|grep -Pqz '^ *2 .*\n$'

```

Output is via exit code, where **0** is success (truthy) and **1** is failure (falsy).

Try it online!

# Answer
> 1 votes
# C (GCC), ~~80~~ 78 bytes

```
i,j,t;f(x,l)int*x;{for(i=t=0;i<l;++i)for(j=0;j<i;)t+=x[i]==x[j++];return!~-t;}

```

-1 thanks to Jonathan Frech

-1 thanks to Kevin Cruijssen

Try it Online!

`f` is a function that takes in an `int*` pointing to the list, and an `int` that is the length of the list, and returns 1 if there are exactly two equal entries and all other entries are distinct, and 0 value otherwise.

The function checks all pairs of numbers in the list, counting the number of pairs, and returns whether the number of pairs is 1.

# Answer
> 1 votes
# Java 8, ~~46~~ 44 bytes

```
l->l.stream().distinct().count()==l.size()-1

```

-2 bytes thanks to *@Nevay*. (Old answer: `l->new java.util.HashSet(l).size()==l.size()-1`)

**Explanation:**

Try it here.

```
l->                // Method with List parameter and boolean return-type
  l.stream()       //  Stream over the List
   .distinct()     //  ignoring all duplicated items
   .count()        //  and get the total amount of non-duplicated items in the List
     ==            //   And check if it's size is equals to
       l.size()-1  //   the size of the input-list - 1
                   // End of method (implicit / single-line return-statement)

```

# Answer
> 1 votes
# Bash, ~~36~~, 35 bytes

```
for k;{ H[$k]=;};((${#H[@]}+1==$#))

```

TIO exit status 0: true, 1: false, `((..))` can be changed to `echo $((..))`, to see boolean value (1:true, 0:false)

# Answer
> 1 votes
# Clojure, 31 bytes

```
#(=(count(set %))(-(count %)1))

```

Try it online!

Does the same as LyricLy's answer

# Answer
> 1 votes
# Japt, 7 bytes

```
ÊÉ¶Uâ Ê
      Ê // Return whether the number of
   Uâ   // unique items in the input
  ¶     // is equal to
ÊÉ      // the input's length minus one.

```

Try it online!

# Answer
> 1 votes
# Brachylog, 7 bytes

```
dl.&l-₁

```

Try it online!

Truthy/falsy input is achieved through predicate success/failure, as if this predicate is run as the entire program on a single input, it will print `true.` if it succeeds and `false.` if it fails. The header on TIO is there so you can run all of the cases at once.

```
dl         The length of the input with duplicates removed
  .        is the output variable,
   &       and
    l-₁    so is the length of the input minus 1.

```

# Answer
> 1 votes
# Regex (ECMAScript), ~~69~~ 67 bytes

The input is in the form of a comma-delimited list of nonnegative integers in decimal.

```
^(?=.*\b(\w+\b).*,\1\b)(?!(.*\b\1\b){3}|.*\b(?!\1\b)(\w+\b).*,\3\b)

```

Try it online!

```
^
(?=
    .*\b(\w+\b)          # \1 = an element that occurs at least twice
    .*,\1\b              # locate the second occurrence of \1; since there's at least one
                         # element before it, it's guaranteed to have a commma in front
)
(?!
    (.*\b\1\b){3}        # Assert that \1 does not occur 3 or more times
|
    .*\b(?!\1\b)(\w+\b)  # \3 = any element that's different from \1
    .*,\3\b              # Assert that \3 does not occur again; since there's at least one
                         # element before it, it's guaranteed to have a commma in front
)

```

# Regex (ECMAScript), ~~67~~ 65 bytes

```
^(?=.*(\bx+\b).*,\1\b)(?!(.*\b\1\b){3}|.*\b(?!\1\b)(x+\b).*,\3\b)

```

Try it online!

This is a straight port of the decimal version to positive unary, changing both occurrences of `\w+` to `x+`. Input is a list of positive unary numbers separated by `,`. Each one is a string of `x`s whose length represents the number.

# Regex (ECMAScript), 92 bytes

This version fully supports nonnegative unary. That is very costly; `\b` can no longer be used at all. The part that ballooned the most in length was where it's asserted that no element other than `\2` is repeated 3 or more times, because with a simple `{3}` loop, it would get a false negative due to falsely finding a repeated zero consisting of 3 repeated zero-width matches with no commas consumed.

```
^(?=.*(^|,)(x*(?!x)).*,\2(?!x))(?!.*(^|,)(\2(?!x)(.*,\2(?!x)){2}|(?!\2(?!x))(x*(?!x)).*,\6(?!x)))

```

Try it online!

```
^
(?=
    .*(^|,)(x*(?!x))          # \2 = an element that occurs at least twice
    .*,\2(?!x)                # locate the second occurrence of \2; since there's at least one
                              # element before it, it's guaranteed to have a commma in front
)
(?!
    .*(^|,)
    (
        \2((?!x).*,\2){2}     # Assert that \2 does not occur 3 or more times
    |
        (?!\2(?!x))(x*(?!x))  # \6 = any element that's different from \2
        .*,\6                 # Assert that \6 does not occur again; since there's at least one
                              # element before it, it's guaranteed to have a commma in front
    )
    (?!x)
)

```

# Answer
> 1 votes
# Jelly, 4 bytes

```
QṁƑḊ

```

Try it online!

```
Q       Is the input uniquified
 ṁƑ     the same length as
   Ḋ    the input without its first element?

```

# Answer
> 0 votes
# Mathematica, 26 bytes

```
(l=Length)@Union@#+1==l@#&

```

Try it online!

# Answer
> 0 votes
# Convex, 7 bytes

```
_Å,)\,=

```

Try it online!

# Answer
> 0 votes
## Batch, 109 bytes

```
@set/ap=1,s=0
@for %%x in (%*)do @(for %%y in (%*)do @set/a"s+=!(%%x-%%y)")&set/ap*=s,s=0
@if %p%==4 echo 1

```

Port of @DJMcMayhem's answer.

# Answer
> 0 votes
# Perl 5, 25+1 (-p)=26 bytes

```
$H{$_}=1}{$\=$.-1==keys%H

```

TIO

# Answer
> 0 votes
# Batch, 131

```
set b=,%*,
goto j
:l
call set f=%%b:,%1,=,#,%%
if "%b%"=="%f%" exit 1
set b=%f%
goto:eof
:j
FOR %%A IN (%b%) DO call :l %%A

```

The `%errorlevel%` can be checked for the result. it works by tokenising the input, `FOR %%A IN (%b%) DO call :l %%A` every instance of that token + to commas is then replaced in a copy of the input with a ",#," `call set f=%%b:,%1,=,#,%%` the resulting string is then compared to the copy of the previous string. If there is no change in the string, it is because that number has already occured.

`c:\>batfile.bat 1,2,3`

# Answer
> 0 votes
# Perl 6, 12 bytes

```
{.Set+1==$_}

```

Try it online!

Convert to Set, test if the number of elements is less by one.

# Answer
> 0 votes
# , 40 bytes

```
sum(outer(x<-scan(),x,"=="))==2+sum(x|1)

```

Try it online!

Approach is different from the other `R` solution \- and not as golfy...

# Answer
> 0 votes
# 12-basic, 31 bytes

```
FUNC S(L)?LEN(L|L)==LEN(L)-1END

```

The `|` (union) operator returns an array containing elements that are in both of the input arrays. As a side effect, it removes duplicates.

# Answer
> 0 votes
# Pari/GP, 16 bytes

```
a->#a==#Set(a)+1

```

Try it online!

# Answer
> 0 votes
# , 38 bytes

Not quite as golfed as another R answer, but a different approach.

```
length(a<-scan())-length(unique(a))==1

```

Try it online!

# Answer
> 0 votes
## F#, 49 bytes

```
let s c=Seq.distinct c|>Seq.length=Seq.length c-1

```

Try it online!

`Seq.distinct` creates a sequence of all the unique elements in the collection. If the number of distinct elements is one less than the original collection, there are soulmates.

# Answer
> 0 votes
# Javascript,96 bytes

```
for(i=0;i<a.length;i++)for(j=0;j<a.length;j++)(a[i]==a[j]&& i!=j)?count++:0 console.log(count==2)

```

And a better readable format

```
for(i=0;i<a.length;i++){
  for(j=0;j<a.length;j++){
   (a[i]==a[j]&& i!=j)?count++:0
  }
}
 console.log(count==2)

```

# Answer
> 0 votes
# GolfScript, 7 bytes

```
.,\.&,-

```

Try it online!

```
.,\.&,- # Stack will be show as [], with L being our list.
.       # Duplicate array [L L]
 ,      # Size of top element [L N]
  \     # Swap the positions of the top two elements [N L]
   .&   # Listwise OR (remove duplicates) [N L&]
     ,  # Size of top elements (should be 1 lesser) [N N-1?]
      - # Difference

Output is 1 if TRUE. Any other result is FALSE.

```

# Answer
> 0 votes
# Factor, 25 bytes

```
[ duplicates length 1 = ]

```

Try it online!

## Explanation

It's a quotation (anonymous function) that takes a sequence as input and leaves a boolean as output. Assuming `{ 1 6 3 4 4 7 9 }` is on top of the data stack when this quotation is called...

* `duplicates` Obtain a list of duplicate values. **Stack:** `{ 4 }`
* `length` Get the length. **Stack:** `1`
* `1` Push `1` to the stack. **Stack:** `1 1`
* `=` Return `t` if the top two objects on the data stack are equal, otherwise return `f`. **Stack:** `t`

---
Tags: code-golf, array, decision-problem
---