| Bytes | Lang | Time | Link |
|---|---|---|---|
| 035 | excel | 250409T122510Z | pneumann |
| 046 | Python 3 | 250409T040808Z | Mukundan |
| 057 | AWK | 250228T200809Z | xrs |
| 047 | Kotlin KotlinScript 47 Bytes | 240705T225229Z | colmmurp |
| 034 | Arturo | 240707T141620Z | chunes |
| 014 | Uiua | 231014T224343Z | chunes |
| 064 | Elixir | 240705T100205Z | aloisdg |
| 013 | K ngn/k | 231015T205919Z | coltim |
| nan | Fig | 220908T191948Z | naffetS |
| nan | 191230T060337Z | Deadcode | |
| 004 | Thunno 2 | 230607T080513Z | The Thon |
| 019 | Zsh nocaseglob | 220704T193706Z | pxeger |
| 057 | Prolog SWI | 220904T110348Z | Jo King |
| 004 | 05AB1E | 161101T115246Z | Magic Oc |
| 017 | K ngn/k | 220718T000724Z | oeuf |
| 010 | APL | 220718T022531Z | Vadim Tu |
| 005 | Vyxal r | 220706T125224Z | naffetS |
| 056 | Kotlin | 220713T140019Z | wartoshi |
| 005 | Vyxal | 220709T171730Z | Deadcode |
| 103 | Prolog SWI | 220707T041903Z | naffetS |
| 025 | Julia | 220704T190056Z | Czylabso |
| 004 | All of these regexes use their engines' respective case insensitivity flags | 191227T235807Z | Deadcode |
| 038 | JavaScript ES9 | 210402T045635Z | l4m2 |
| 026 | Vim | 210407T012015Z | Leo |
| nan | APL Dyalog Extended | 210329T032039Z | Andrew O |
| 064 | C | 210402T025839Z | Antonin |
| 145 | Scratch | 210330T191126Z | Bo_Tie |
| 006 | Jelly | 210330T112337Z | lyxal |
| nan | Pxem | 210330T084237Z | user1004 |
| 087 | C | 210329T080630Z | Toby Spe |
| 023 | Factor + math.unicode | 210329T004249Z | chunes |
| 005 | 05AB1E | 210329T020433Z | Makonede |
| 049 | BaCon | 210120T174128Z | Peter |
| 022 | Perl 5 MListUtil=uniq p0 | 210119T164117Z | Xcali |
| 005 | Stax | 210119T122649Z | Razetime |
| 009 | Husk | 201006T115328Z | Razetime |
| 047 | Kotlin | 200123T132218Z | adrian.n |
| 048 | C# Visual C# Interactive Compiler | 200124T085718Z | Jirka Pi |
| 016 | Burlesque | 200123T112934Z | DeathInc |
| 013 | Dyalog APL | 200123T103822Z | Popov |
| 018 | GolfScript | 200123T052021Z | user8505 |
| 006 | Charcoal | 191229T113955Z | Neil |
| 028 | Perl 5 p | 190312T150901Z | Xcali |
| 044 | APLNARS | 190316T082459Z | user5898 |
| 5956 | PHP | 190312T173533Z | 640KB |
| 020 | Retina | 190319T020259Z | Sara J |
| 007 | MathGolf | 190314T143551Z | maxb |
| 043 | Haskell | 190316T155911Z | xnor |
| 044 | Smalltalk | 190316T101619Z | Leandro |
| 051 | Haskell | 160804T153208Z | Laikoni |
| 004 | Japt ! | 180222T150835Z | Shaggy |
| 006 | APL Dyalog Extended | 190310T190949Z | voidhawk |
| 004 | Brachylog | 190310T110542Z | Unrelate |
| 033 | MATLAB / Octave | 151210T042315Z | Tom Carp |
| 012 | K4 | 180222T200756Z | mkst |
| 023 | J | 180222T151055Z | FrownyFr |
| 172 | PHP | 180222T144254Z | Agnius V |
| 069 | Java 8 | 180222T142846Z | Kevin Cr |
| 092 | R | 160805T085517Z | Rudier |
| 005 | 2sable | 161101T102023Z | driima |
| 064 | Rust | 161101T133748Z | user6126 |
| 045 | R | 151210T083605Z | plannapu |
| 083 | Javascript using external library Enumerable | 160804T154200Z | applejac |
| nan | Batch | 160517T095337Z | Neil |
| 052 | PowerShell v3+ | 151210T194122Z | AdmBorkB |
| 009 | GS2 | 151210T044128Z | Dennis |
| 027 | 32bit x86 machine code | 160717T193641Z | meden |
| 121 | C++ | 160717T010300Z | bacchusb |
| 096 | Java | 151210T232639Z | rgettman |
| 006 | Pyke | 160517T192522Z | Blue |
| 092 | PHP | 160517T153221Z | axiac |
| 014 | PlatyPar | 151215T031601Z | Cyoce |
| 093 | Javascript | 151210T024052Z | SuperJed |
| 048 | Bash 4+ | 151210T195000Z | SnoringF |
| 057 | Groovy | 151216T193924Z | J Atkin |
| 077 | R | 151215T224628Z | syntonic |
| nan | 151214T165243Z | ProgramF | |
| 042 | Bash | 151214T162406Z | Toby Spe |
| 097 | C | 151211T133313Z | Stefano |
| 033 | Ruby | 151210T230045Z | MegaTom |
| 033 | Ruby | 151210T173107Z | Alexis A |
| 047 | Python 3.5 | 151212T135642Z | Tim Pede |
| 044 | Mathematica | 151212T131958Z | alephalp |
| 051 | JavaScript ES6 | 151210T092044Z | edc65 |
| 011 | O | 151212T014259Z | a spaghe |
| 051 | Python 2 | 151210T041621Z | Mitch Sc |
| 086 | Mumps | 151211T155119Z | zmerch |
| 107 | SpecBAS | 151211T152849Z | Brian |
| 039 | R | 151211T000555Z | mnel |
| 046 | Scala | 151211T042315Z | Ruslan |
| 068 | ES6 | 151211T004238Z | Neil |
| 007 | Pyth | 151210T023042Z | lirtosia |
| 107 | C | 151210T215539Z | RCB |
| 113 | JavaScript ES6 | 151210T024006Z | Conor O& |
| 080 | JavaScript ES6 | 151210T185223Z | apsiller |
| 022 | Retina | 151210T160744Z | Martin E |
| 012 | Seriously | 151210T061649Z | quintopi |
| 012 | TeaScript | 151210T055840Z | Downgoat |
| 020 | Perl 6 | 151210T054834Z | Brad Gil |
| 018 | Minkolang 0.14 | 151210T051035Z | El'e |
| 011 | CJam | 151210T045353Z | Reto Kor |
| 014 | Japt | 151210T044704Z | ETHprodu |
| 038 | Julia | 151210T034747Z | Glen O |
excel, 35 bytes
=AND(SEARCH(CHAR(ROW(65:90)),A1)>0)
this returns 'TRUE' if true, or '#VALUE!' if false. if you want the output to only be 'TRUE' or 'FALSE', the below 43 byte solution should work.
excel, 43 bytes
=AND(ISNUMBER(SEARCH(CHAR(ROW(65:90)),A1)))
there are probably much shorter solutions on excel but i have no idea because i barely know how to use it.
AWK, 57 bytes
{for(;++i<27&&toupper($0)~sprintf("%c",i+64););}1,$0=i~27
{for(;++i<27 # each letter
&&toupper($0) # convert input to upper
~sprintf("%c",i+64););} # see if char is present
1,$0=i~27 # print if all were there
Kotlin (KotlinScript) 53 47 Bytes
Saved 6 Bytes by converting to an anonymous function, thanks to emanresu A
{s:String->('A'..'Z').all{it in s.uppercase()}}
Arturo, 34 bytes
$=>[[]=--@`a`..`z`to[:char]lower&]
Explanation
$=>[] ; a function where input is assigned to &
lower& ; input lowercased
to[:char] ; convert to list of characters
-- ; remove this from
@`a`..`z` ; list of characters from a to z
[]= ; is it empty?
Uiua, 17 14 bytes
/↧/↥∊⊞+"aA"⇡26
-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
Elixir, 96 95 94 65 64 bytes
&Enum.all?(?A..?Z, & &1 in String.to_charlist(String.upcase(s)))
&(&1|>String.upcase|>String.to_charlist|>Enum.filter(& &1 in ?A..?Z)|>Enum.uniq|>Enum.count>25)
The function is the Elixir shorthand syntax. It upcases everything, then keeps the letters, then remove duplicate and finally check the size of the output.
- -1 byte because
&(&1>64&&91>&1)can be written& &1>64&&91>&1 - -1 byte because
& &1>64&&91>&1can be written& &1 in ?A..?Z - -33% with another algorithm
Thanks Pul from exercism.org
K (ngn/k), 13 bytes
~#(!26)^97!_:
_:lowercase the (implicit) input97!mod the ASCII character codes by 97 (soabecomes0,f6,z25, etc. etc.)(!26)^remove the character codes that are present from0..25~#do any character codes corresponding to letters remain?
An alternative 14-byte answer is:
~26-/~"a{"'?_:
?_:get the distinct lowercased characters in the input~"a{"'identify which characters in the input are letters (1in the resulting bitmask) and which are not letters (these become0s)~26-/notthe result of a minus-reduce seeded with26(if all letters are present in the input, this will return1, and otherwise0)
Fig, \$9\log_{256}(96)\approx\$ 7.408 bytes
lca+//KUa
Returns -1 for falsy, and a non-negative integer for truthy.
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('',<>).
Thunno 2, 4 bytes
LḳẠƇ
Explanation
LḳẠƇ # Implicit input
L # Convert to lowercase
ḳ # Sort and uniquify
Ƈ # Does this string contain...
Ạ # ...the lowercase alphabet?
# Implicit output
Zsh --nocaseglob, 19 bytes
>_${1//\/}<*{a..z}*
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}*
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.
Prolog (SWI), 57 bytes
\O:- \+ (between(97,122,Z),\+sub_atom_icasechk(O,_,[Z])).
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.
05AB1E, 4 bytes
lêAå
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.
K (ngn/k), 36 19 17 bytes
{~#(97+!26)^0+_x}
-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
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
Vyxal r, 5 bytes
⇩kaF¬
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.
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.
Vyxal, 6 5 bytes
ɽǍkaƈ
ɽ # Convert input to lowercase.
Ǎ # Remove non-alphabetical characters.
ka # Push the lowercase alphabet.
ƈ # Are the set of characters in the two strings the same?
Prolog (SWI), 103 bytes
_^[].
S^[H|T]:-member(H,S),S^T.
\B:-string_lower(B,O),string_codes(O,C),C^`abcdefghijklmnopqrstuvwxyz`.
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 / Pythonregex), 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.
JavaScript (ES9), 38 bytes
a=>a.match(/$|([A-Z])(?!.*\1)/igs)[25]
$| just to not crash if there's no letter. Worth mentioned competitor
Vim, 30 26 bytes
:%s/\A*/\r/g
:sor ui
26Dr1
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 sorts the lines ignoring 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.
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.
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'withwhile(*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.
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.
Jelly, 7 6 bytes
ŒlØaḟṆ
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.
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
- Escaped:
- Content: empty.
Usage
- Input from stdin
Yto 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
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");
}
}
Factor + math.unicode, 34 23 bytes
[ >lower ALPHABET ⊃ ]
-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.
>lowerConvert a string to lowercase.ALPHABETPush a string containing the lowercase alphabet to the data stack.⊃Is the input a superset of the alphabet?
05AB1E, 5 bytes
lAیP
lAیP # full program
P # product of...
€ # each letter of...
A # "abcdefghijklmnopqrstuvwxyz"...
å # in...
# implicit input...
l # in lowercase
# implicit output
BaCon, 49 bytes
?IIF(AMOUNT(UNIQ$(EXPLODE$(LCASE$(s$))))>25,1,0)
Husk, 9 bytes
¦m_⁰…'a'z
Explanation
¦m_⁰…'a'z
…'a'z inclusive range from a to z
m_⁰ convert input to lowercase
¦ are all alphabets present in it?
C# (Visual C# Interactive Compiler), 48 bytes
x=>x.ToUpper().Distinct().Count(c=>c>64&c<91)>25
Burlesque, 16 bytes
zzXX@azr@Jx/IN=s
[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
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
GolfScript, 18 bytes
Port of the GS2 answer.
{32|}%[123,97>]\-!
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
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
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
PHP, 59 56 bytes
<?=!array_diff(range(a,z),str_split(strtolower($argn)));
Alt version 67 bytes
<?=array_intersect($a=range(a,z),str_split(strtolower($argn)))==$a;
Call with php -nF input is from STDIN.
Retina, 20 bytes
T`L`l
D`.
C`[a-z]
26
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)
MathGolf, 11 7 bytes
!▀_▄+▀=
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
Haskell, 43 bytes
f s=until(all(`notElem`s))(succ<$>)"Aa">"["
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.
Smalltalk, 44 bytes
(($ato:$z)intersection:s asLowercase)size=26
Haskell, 59 56 53 51 bytes
p s=and[any(`elem`map toEnum[a,a+32])s|a<-[65..90]]
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.
APL (Dyalog Extended), 6 bytes
∧/⎕A∊⌈
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
Brachylog, 4 bytes
ḷo⊇Ạ
The input
ḷ lowercased
o sorted
⊇ is a superlist of
Ạ the lowercase alphabet.
MATLAB / Octave, 35 33 bytes
@(x)~nnz(setdiff(65:90,upper(x)))
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.
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
PHP, 172 bytes
function is_pangram ($s) {
return preg_match("#^".implode(
array_map(function ($x) {return "(?=.*{$x})" ;} ,
str_split("ABCDEFGHIJKLMNOPQRSTUVWXYZ")))."#uis", $s);
}
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
Similar to @ProgramFOX' C# 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 !
2sable, 6 5 bytes
6 byte version:
AIl-g_
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å
Explanation:
l Push lowercase input
Ù{ Push sorted uniquified input
A Push alphabet
å Is alphabet in sorted, uniquified input?
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.
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
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
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.)
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
slsforSelect-Stringwhich 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 printsTrueorFalseaccordingly - Requires PowerShell v3 or newer for the
slsalias
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.
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
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;}
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.
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.
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...
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.
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
}
Groovy, 57 bytes
u={print it.toLowerCase().toList().containsAll('a'..'z')}
Will groovy ever win?
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
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.
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).
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]));
}
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}}
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
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!
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
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>
O, 11 bytes
GQ_s{n-}dS=
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
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()))
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.
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.
R 50 ,46 39 bytes
all(sapply(letters,grepl,readline(),T))
Edit drops the need for tolower by adding ignore.case=TRUE (T)
Scala, 59 48 46 bytes
print(('a'to'z'diff(readLine.map(_|32)))==Nil)
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.
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.
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;}
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:")));
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).
Retina, 22 bytes
Msi`([a-z])(?!.*\1)
26
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.
Seriously, 14 13 12 bytes
,ûOk"A["Ox-Y
Hex Dump:
2c964f6b22415b224f782d59
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
TeaScript, 12 bytes
Sz.e»xL.I(l©
First TeaScript post since I killed TeaScript :p
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
)
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.
Minkolang 0.14, 18 bytes
$o7$ZsrlZ'26'$ZN.
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.
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.
Japt, 14 bytes
#ao#{ e@Uv fXd
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
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).
