Is it a pangram?

43

2

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.

Arcturus

Posted 2015-12-10T02:25:53.257

Reputation: 6 537

3Plus points if your code can check if input is a Pungram. – timmyRS – 2016-05-17T16:43:08.570

6Question name request: Did the quick brown fox jump over the lazy dog? – None – 2016-08-04T11:59:32.633

Answers

26

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.

lirtosiast

Posted 2015-12-10T02:25:53.257

Reputation: 20 331

I think the shortest way to fix this for newlines in the input is to make a function: L!-Grb0. !-Grs.z0 would also work but is longer. – FryAmTheEggman – 2015-12-10T16:13:07.353

Oh, I didn't see the question updated to include \n in the string. Thanks. – lirtosiast – 2015-12-10T22:30:41.320

@Maltysen While there is a (weak) consensus on allowing strings from input to be delimited by quotes, I'm not sure about this as it goes further in requiring Python string syntax.

– lirtosiast – 2015-12-11T16:04:13.147

I never would have thought an alphabet built-in would be useful... – Cyoce – 2015-12-12T08:43:30.593

17

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.

Brad Gilbert b2gills

Posted 2015-12-10T02:25:53.257

Reputation: 12 713

12

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.

Dennis

Posted 2015-12-10T02:25:53.257

Reputation: 196 637

quick block m2 (\xe9) saves 2 bytes. – Mitch Schwartz – 2015-12-10T05:24:47.907

@MitchSchwartz Oh, so that's how you use those. Thanks! – Dennis – 2015-12-10T05:29:58.067

11

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>

edc65

Posted 2015-12-10T02:25:53.257

Reputation: 31 086

Would a.replace(/[^A-Z]|[^a-z]/g,'') or a.replace(/[^A-Z]/gi,'') work? – ev3commander – 2015-12-11T01:12:41.547

2@ev3commander no. A and a must become the same character, else the set will keep them as distinct and the size will be > 26 – edc65 – 2015-12-11T06:21:31.923

What if you use the spread operator with [...a.toUpperCase().replace(/[^A-Z]/g,'')].length>25 ? – Scott – 2015-12-11T16:55:15.793

@ScottKaye obviously no. Try it with 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' – edc65 – 2015-12-11T17:35:52.510

Wouldn't match(/[A-Z]/g) work just as good as replace? – user81655 – 2015-12-12T01:47:05.837

This post clearly needs en explanation... @user81655: no, lowercase letters would be lost. As it's 3am here now, I'll try to add an explanation tomorrow. – edc65 – 2015-12-12T02:02:38.320

a=>new Set(a.toUpperCase().match(/[A-Z]/g)).size>25 seems to work for me. 51 bytes. toUpperCase() means there are no lower-case letters in the string being matched. Feel free to implement it tomorrow though. xD – user81655 – 2015-12-12T02:13:44.977

1@user81655 right, it works, great. Thanks. I should not answer comments while asleep – edc65 – 2015-12-12T11:07:33.253

9

R 50 ,46 39 bytes

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

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

mnel

Posted 2015-12-10T02:25:53.257

Reputation: 826

Not too familiar with R, but shouldn't ignore.case=TRUE (T) be included in the count as well then? – Ruslan – 2015-12-11T13:30:19.827

2@Ruslan It is! It is the Tas the end, thanks to argument placement matching there is no need to actually specify the name of the argument (and T is the default alias for TRUE). The code written here performs the needed action as is, without any need to add anything. – plannapus – 2015-12-11T14:29:02.833

9

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

a spaghetto

Posted 2015-12-10T02:25:53.257

Reputation: 10 647

7

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()))

Mitch Schwartz

Posted 2015-12-10T02:25:53.257

Reputation: 4 899

1If I'm not mistaken, the last expression is the same as lambda s:set(range(65,91))<=set(map(ord,s.upper())), also for 51. – xnor – 2015-12-10T05:06:01.870

Python 3.5 can save bytes here: p=lambda s:{*range(65,91)}<={*map(ord,s.upper())}. By the way, I can't seem to find any rules on whether a lambda needs to be assigned (as in your first case) or not (as in your later ones). Help? – Tim Pederick – 2015-12-11T16:30:15.750

@TimPederick Naming the lambda is unnecessary unless you need to use the function elsewhere, like in the first recursive solution. – FryAmTheEggman – 2015-12-11T16:57:33.830

@TimPederick Thanks for pointing that out. I renamed my answer as Python 2 instead of just Python. You have my blessing to post that as a new answer if you want, which I think would be ok by community norms although I'm not sure. – Mitch Schwartz – 2015-12-11T17:33:14.607

@FryAmTheEggman: Thanks for clarifying. That distinction hadn't occurred to me! I've also found a meta post explaining the rule. There goes two bytes from a few things I've written...

– Tim Pederick – 2015-12-12T13:51:16.877

6

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).

Glen O

Posted 2015-12-10T02:25:53.257

Reputation: 2 548

5

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.

Martin Ender

Posted 2015-12-10T02:25:53.257

Reputation: 184 808

5

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

Alexis Andersen

Posted 2015-12-10T02:25:53.257

Reputation: 591

2You can save 8 bytes by making your regex to ignorecase. – Vasu Adari – 2015-12-11T07:49:54.067

4

Brachylog, 4 bytes

ḷo⊇Ạ

Try it online!

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

Unrelated String

Posted 2015-12-10T02:25:53.257

Reputation: 5 300

4

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.

xnor

Posted 2015-12-10T02:25:53.257

Reputation: 115 687

4

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.

Tom Carpenter

Posted 2015-12-10T02:25:53.257

Reputation: 3 990

Great answer! Mine was 10 bytes longer – Luis Mendo – 2015-12-10T23:37:21.280

4

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.

El'endia Starman

Posted 2015-12-10T02:25:53.257

Reputation: 14 504

4

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

plannapus

Posted 2015-12-10T02:25:53.257

Reputation: 8 610

4

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!

Tim Pederick

Posted 2015-12-10T02:25:53.257

Reputation: 1 411

4

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.

Laikoni

Posted 2015-12-10T02:25:53.257

Reputation: 23 676

4

05AB1E, 4 bytes (Probably Non-competing)

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.

Magic Octopus Urn

Posted 2015-12-10T02:25:53.257

Reputation: 19 422

3

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

voidhawk

Posted 2015-12-10T02:25:53.257

Reputation: 1 796

3

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.

SuperJedi224

Posted 2015-12-10T02:25:53.257

Reputation: 11 342

Would b=0 work for b=[]? – ev3commander – 2015-12-11T01:13:39.087

Not with this approach. But I may be able to make that work. – SuperJedi224 – 2015-12-11T01:32:21.983

I don't know Javascript, but can you do for(i=65;i++<91;)b+=!~a.indexOf(String.fromCharCode(i));alert(!b)? – lirtosiast – 2015-12-11T01:40:02.747

Wow. That's even shorter than what I just did. – SuperJedi224 – 2015-12-11T01:50:21.417

3

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

ETHproductions

Posted 2015-12-10T02:25:53.257

Reputation: 47 880

3

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.

Reto Koradi

Posted 2015-12-10T02:25:53.257

Reputation: 4 870

3

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 -splits 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 .Counted to see if it's -equal to 26, and prints True or False accordingly
  • Requires PowerShell v3 or newer for the sls alias

AdmBorkBork

Posted 2015-12-10T02:25:53.257

Reputation: 41 581

It's a lot easier to pinch someone else's effort and try and shorten it a bit, than to read the questions from scratch - and more fun to compete within PowerShell than to go directly up against CJam and friends. But I can stop chasing your answers if it's annoying, sorry. – TessellatingHeckler – 2015-12-15T16:58:58.007

@TessellatingHeckler Not annoying! :D I'm just trying to give you more encouragement! – AdmBorkBork – 2015-12-15T18:00:06.847

3

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?

driima

Posted 2015-12-10T02:25:53.257

Reputation: 451

2

J, 23 bytes

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

Try it online!

FrownyFrog

Posted 2015-12-10T02:25:53.257

Reputation: 3 112

2

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

maxb

Posted 2015-12-10T02:25:53.257

Reputation: 5 754

2

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)

Sara J

Posted 2015-12-10T02:25:53.257

Reputation: 2 576

2

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.

Regex (Perl 5 / PCRE / Boost / Python 3), 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)

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):

Try it online! (Python 3) (24 bytes) - anchor is implied

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

Try it on regex101 (PCRE1)
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), 23, 24, 32, or 33 bytes

The same progression of speed applies:

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

ECMAScript lacks atomic groups, so they must be emulated using lookahead+capture+backref:

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


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.

Deadcode

Posted 2015-12-10T02:25:53.257

Reputation: 3 022

You can save a byte by using positive lookahead instead of negative. This matches the last of each letter rather than the first, but the overall result is the same, excecpt of course that it works in less powerful regex engines such as ES6. – Neil – 2019-12-29T11:25:26.057

Try it online! – Neil – 2019-12-29T11:25:38.623

@Neil Oops! How embarrassing. Thanks for letting me know. (A shame, since I thought this problem was even better than Do you make me up? for illustrating the differences between engines.) I guess I'm guilty here of "When you have a hammer, every problem looks like a nail." I'll try to avoid that pitfall in the future.

– Deadcode – 2019-12-30T03:33:23.587

2

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:

JavaScript ES6, 37 bytes

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

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

PHP, 49 or 51 bytes

PHP imposes a strict backtracking limit (or time limit?) on its regexes, so the version that would be 48 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}/i',$argn); (49 bytes) - Try it online!

The 49 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}/i',$argn); (51 bytes) - Try it online!
<?=preg_match('/^(?>.*?(\pL)(?!.*\1)){26}/i',$argn); (52 bytes) - Try it online!

These versions print 0 for false and 1 for true.

Perl 5 -p, 27 bytes

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

Perl 5, 33 bytes

Ties with the non-regex answer.

say<>=~/(.*(\pL)(?!.*\2)){26}/i+0 (33 bytes, always slow) - Try it online!
say<>=~/(.*?(\pL)(?!.*\2)){26}/i+0 (34 bytes, slow for non-matches) - Try it online!
say<>=~/(?>.*?(\pL)(?!.*\1)){26}/i+0 (36 bytes, fairly reasonable speed) - Try it online!
say<>=~/^(?>.*?(\pL)(?!.*\1)){26}/i+0 (37 bytes, very reasonable speed) - Try it online!

Ruby -n, 29 bytes

Prints nil for false and 0 for true. If printing 0 or 1 is desired, replace ~ with !! (+1 byte).

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

For comparison, the 33 byte Ruby answer turns into a 28 byte answer when using -n instead of a lambda (and prints false or true):

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

Ruby, 34 bytes

Curiously, this is only 1 byte longer than the mixed code/regex answer:

->s{s[/(.*([A-Z])(?!.*\2)){26}/i]} (34 bytes) - Try it online!
->s{s[/(.*?([A-Z])(?!.*\2)){26}/i]} (35 bytes) - Try it online!
->s{s[/(?>.*?([A-Z])(?!.*\1)){26}/i]} (37 bytes) - Try it online!
->s{s[/^(?>.*?([A-Z])(?!.*\1)){26}/i]} (38 bytes) - Try it online!

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

Deadcode

Posted 2015-12-10T02:25:53.257

Reputation: 3 022

2

Kotlin, 47 bytes

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

Try it online!

adrian.nastase

Posted 2015-12-10T02:25:53.257

Reputation: 31

It seems that both this answer and the other one operate on an existing variable, when the challenge requires that a function be built. – Post Rock Garf Hunter – 2020-01-23T14:09:02.550

@PostRockGarfHunter Thanks for letting me know. I've updated the answer by adding a Try it online! link so that the solution can be tested. I hope it's OK like this, as I've seen this approach used by others. – adrian.nastase – 2020-01-23T20:28:09.820

1@JoKing Thanks, I'll keep that in mind! I've updated my answer. I hope it's OK now. – adrian.nastase – 2020-01-27T05:19:10.833

2

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:")));

Conor O'Brien

Posted 2015-12-10T02:25:53.257

Reputation: 36 228

@apsillers I think I found the problem. Please test it again (my browser does not support ES6 atm) – Conor O'Brien – 2015-12-10T19:21:21.130

Yep, looks good now! – apsillers – 2015-12-10T19:30:52.070

2

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
)

Downgoat

Posted 2015-12-10T02:25:53.257

Reputation: 27 116

1;-; I feel bad now. TBH I like TeaScript the most. – Conor O'Brien – 2015-12-10T19:24:48.520

2

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;}

RCB

Posted 2015-12-10T02:25:53.257

Reputation: 181

2

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.

Neil

Posted 2015-12-10T02:25:53.257

Reputation: 95 035

Maybe using a range of charcodes? – Cyoce – 2015-12-12T08:51:08.127

@Cyoce That got me thinking and I tried a range of base 36 digits but so far it still takes 70 bytes: s=>[...Array(x=9,26)].every(z=>RegExp((++x).toString(36),"i").test(s)) – Neil – 2015-12-13T00:29:07.463

2

Scala, 59 48 46 bytes

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

Ruslan

Posted 2015-12-10T02:25:53.257

Reputation: 280

Using 32| rather than _|32 will (yield a warning but) shave off one more byte – Jacob – 2016-05-17T14:48:05.403

2

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).

Toby Speight

Posted 2015-12-10T02:25:53.257

Reputation: 5 058

2

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.

ProgramFOX

Posted 2015-12-10T02:25:53.257

Reputation: 8 017

&& can be golfed to &, and bool p(string s)=> can be golfed to s=> – Kevin Cruijssen – 2018-02-22T14:28:07.787

You can save 8 bytes by removing redundant Where method and moving condition to Count method. – Jirka Picek – 2020-01-24T08:50:52.453

2

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!

Cyoce

Posted 2015-12-10T02:25:53.257

Reputation: 2 690

2

Perl 5, 33 bytes

$i=<>;map$=*=$i=~/$_/i,a..z;say$=

msh210

Posted 2015-12-10T02:25:53.257

Reputation: 3 094

For perl <5.10 -pl61e '$i=$_;map$\*=$i=~/$_/i,a..z}{'. – Denis Ibaev – 2016-05-17T08:52:17.050

2

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.)

Neil

Posted 2015-12-10T02:25:53.257

Reputation: 95 035

2

Pyke, 6 bytes

l1GR-!

Try it here!

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

Blue

Posted 2015-12-10T02:25:53.257

Reputation: 26 661

2

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.

Harald Korneliussen

Posted 2015-12-10T02:25:53.257

Reputation: 430

1

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.

Kevin Cruijssen

Posted 2015-12-10T02:25:53.257

Reputation: 67 575

1

Japt -!, 6 4 bytes

;CkU

Try it here

Shaggy

Posted 2015-12-10T02:25:53.257

Reputation: 24 623

Due to a quirk in how S.k() works, you actually don't need the v :-) – ETHproductions – 2018-02-23T20:27:20.950

1

Perl 5 -p, 30 28 bytes

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

Try it online!

Xcali

Posted 2015-12-10T02:25:53.257

Reputation: 7 671

1

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.

640KB

Posted 2015-12-10T02:25:53.257

Reputation: 7 149

1

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

Neil

Posted 2015-12-10T02:25:53.257

Reputation: 95 035

1

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

user85052

Posted 2015-12-10T02:25:53.257

Reputation:

1

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

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

Try it online!

Jirka Picek

Posted 2015-12-10T02:25:53.257

Reputation: 171

1

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

quintopia

Posted 2015-12-10T02:25:53.257

Reputation: 3 899

1

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).

apsillers

Posted 2015-12-10T02:25:53.257

Reputation: 3 632

I wanted to use .every but I couldn't figure out! :D Nice solution! – Conor O'Brien – 2015-12-10T19:26:13.073

1

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.

rgettman

Posted 2015-12-10T02:25:53.257

Reputation: 121

++a<=90; can be shortened by one byte to ++a<91;. – Kevin Cruijssen – 2016-05-17T14:11:40.783

@KevinCruijssen Thanks. I've updated my answer based on your suggestion. – rgettman – 2016-05-17T19:35:55.627

1

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

alephalpha

Posted 2015-12-10T02:25:53.257

Reputation: 23 988

1

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.

axiac

Posted 2015-12-10T02:25:53.257

Reputation: 749

1

You actually don't need the array_keys(array_count_values()) at all, and can get the score down to 63. https://tio.run/##K8go@G9jX5BRoJBaVJRfFF@UWpBfVJKZl65hoGn9PzU5I18xsagosTI@JTMtTUMl0bYoMS89VSNRp0pTp7ikKL64ICezRAPIKsnPyS9PLQIqKUovizaM1dQE6v//3zHJOcU1zT3DM8s7xzfPvyCwKLgktCy8IrIKAA Otherwise your answer is virtually the same as the second one I just posted for this! :)

– 640KB – 2019-03-12T17:53:16.537

Indeed, sometimes I am not seeing the simplest solution and I tend to find complicated ways to solve the problems. – axiac – 2019-03-13T10:39:47.857

1

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 !

Frédéric

Posted 2015-12-10T02:25:53.257

Reputation: 2 059

if you were defining a as strsplit(s,"")[[1]] you wouldn't have to repeat a[[1]] twice and thus save 5 bytes. – plannapus – 2016-11-01T08:06:50.130

0

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

streetster

Posted 2015-12-10T02:25:53.257

Reputation: 3 635

0

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

RosLuP

Posted 2015-12-10T02:25:53.257

Reputation: 3 036

0

Smalltalk, 44 bytes

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

Leandro Caniglia

Posted 2015-12-10T02:25:53.257

Reputation: 181

0

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

Popov

Posted 2015-12-10T02:25:53.257

Reputation: 101

0

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

DeathIncarnate

Posted 2015-12-10T02:25:53.257

Reputation: 916

0

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
}

SnoringFrog

Posted 2015-12-10T02:25:53.257

Reputation: 1 709

1

The exit code works as valid truthy/falsy output, since an exit code is a valid way of outputting an integer.

– a spaghetto – 2015-12-10T19:56:51.940

1>

  • do and done can be replaced with { and }. 2. [[ ... ]]||exit 1 is shorter than if...fi. 3. I don't think the tr command is required at all; ${1,,} =~ $x should work just fine.
  • < – Dennis – 2015-12-12T13:58:29.813

    @Dennis I think my tr command got leftover from when I was doing the search more as "is each character of the input in {a..z}" and it just never occurred to me to remove it when I changed that. Wouldn't have caught the other stuff, still getting the hang of this golfing thing – SnoringFrog – 2015-12-28T16:20:32.253

    0

    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}}
    

    MegaTom

    Posted 2015-12-10T02:25:53.257

    Reputation: 3 787

    2It only works for lowercase letters. – Vasu Adari – 2015-12-11T07:45:37.257

    More love for ruby! ->s{(?a..?z).all?{|x|s[/#{x}/i]}} is 33 bytes. – blutorange – 2015-12-13T20:22:26.423

    0

    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]));
    }
    

    Stefano Sanfilippo

    Posted 2015-12-10T02:25:53.257

    Reputation: 1 059

    0

    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.

    Brian

    Posted 2015-12-10T02:25:53.257

    Reputation: 1 209

    0

    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.

    zmerch

    Posted 2015-12-10T02:25:53.257

    Reputation: 541

    0

    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
    

    syntonicC

    Posted 2015-12-10T02:25:53.257

    Reputation: 329

    You don't need the curly braces here since there is only one statement, thus saving 2 bytes – plannapus – 2016-11-01T08:19:33.570

    0

    Groovy, 57 bytes

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

    Will groovy ever win?

    J Atkin

    Posted 2015-12-10T02:25:53.257

    Reputation: 4 846

    0

    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;}
    

    bacchusbeale

    Posted 2015-12-10T02:25:53.257

    Reputation: 1 235

    0

    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           
    

    meden

    Posted 2015-12-10T02:25:53.257

    Reputation: 711

    0

    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

    enter image description here

    applejacks01

    Posted 2015-12-10T02:25:53.257

    Reputation: 989

    -1

    PHP, 172 bytes

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

    Agnius Vasiliauskas

    Posted 2015-12-10T02:25:53.257

    Reputation: 125

    3I don't know PHP but it looks like there's a lot of whitespace that can be removed here, and using a shorter function name than is_pangram will help -- remember that the point of code golf is to solve the problem in as few bytes as possible! – Giuseppe – 2018-02-22T14:48:23.743