Isogram checker

13

Challenge :

Given a word, check whether or not it is an isogram.


What :

An isogram is a word consisting only of letters with no duplicates (case insensitive). The empty string is an isogram.


Examples :

"Dermatoglyphics"     ---> true
"ab"                  ---> true
"aba"                 ---> false
"moOse"               ---> false
"abc1"                ---> false
""                    ---> true

Input :

You may accept input in any reasonable format

The input will only contain letters and/or numbers, no spaces ([a-zA-Z0-9])


Output :

  • true or any truthy value if the input is an isogram
  • false or any falsy value otherwise

This is so shortest code in bytes in each language wins.

Muhammad Salman

Posted 2018-04-17T18:22:50.690

Reputation: 2 361

3Suggested test case: sad2 – Adám – 2018-04-17T18:43:22.213

1Your definition of isogram includes two different contradictory statements. Which is it? – Post Rock Garf Hunter – 2018-04-17T18:46:28.023

@WhatWizard Neither. Wikipedia says nothing about digits. – Adám – 2018-04-17T18:46:57.387

@Adám Then why include the definition? I also don't see any other definition of the term used so what are we supposed to do? – Post Rock Garf Hunter – 2018-04-17T18:48:08.573

Suggested rewording of *entire* post: Given a word consisting of ASCII letters and digits ([0-9A-Za-z]+), determine whether it has any digits or case-insensitive duplicates. – Adám – 2018-04-17T18:49:00.163

@Adám : Hi. I am going to update the post. Wait one second. Thanks – Muhammad Salman – 2018-04-17T18:50:00.113

9

I would recommend that you start using the sandbox so that these issues can be caught prior to posting the challenge.

– fəˈnɛtɪk – 2018-04-17T19:04:15.540

3@MuhammadSalman This is very sloppy, please remove ". Any" from the end of you quote and give some more examples (sad2das would fail even without the 2 so it doesn't show anything). – Asone Tuhid – 2018-04-17T19:18:40.210

4The "What" and the "Notes" seem to contradict one another: "Implement a function that determines whether a string that contains only letters is an isogram" (emphasis added) and "There may be numbers and those will and must return false" say opposite things. I have voted to close as unclear for the moment, but will happily retract it once that is cleared up! – Giuseppe – 2018-04-17T19:23:59.967

Do output truthy and falsy values need to be consistent, or can they be different depending on the input? – Luis Mendo – 2018-04-17T19:40:30.583

@LuisMendo : I would rather prefer if they were consistent , though second one also works. – Muhammad Salman – 2018-04-18T05:08:15.743

@Giuseppe : I updated both. Take a look – Muhammad Salman – 2018-04-18T05:08:54.527

@AsoneTuhid : updated. Thanks , is this better? – Muhammad Salman – 2018-04-18T05:09:21.863

@MuhammadSalman You should probably decide on a single way to handle digits, I suggest "return false if the word contains any digits" as that's what most of the answers assume. Please use the sandbox next time. – Asone Tuhid – 2018-04-18T05:16:02.743

@AsoneTuhid : Oh well. I guess that works too. Updated – Muhammad Salman – 2018-04-18T05:17:30.243

@AsoneTuhid : Added – Muhammad Salman – 2018-04-18T05:30:29.643

@MuhammadSalman Can you add a test for mixed case in there too, where the repeated letters have different case, e.g. "Aab" - my initial solutions didn't cope with this and returned true instead of false. – Phil H – 2018-04-19T20:08:43.757

Trivia: The Google Universal Analytics script contains a minified function whose seven parameters are named i, s, o, g, r, a, and m. – Neil – 2018-04-25T11:34:34.480

@Neil : I am quite well aware of that and its purpose as well. – Muhammad Salman – 2018-04-25T16:28:06.580

@Neil : Although thanks – Muhammad Salman – 2018-04-25T16:28:19.973

Sorry, I had no idea until I stumbled across it earlier today. – Neil – 2018-04-25T18:12:22.690

Answers

9

Python 2/3, 36 52 48 bytes

lambda s:len(s)==len({*s.lower()}-{*str(56**7)})

Try it online!

I take advantage of the fact that set contains only unique elements. By invoking the __len__ method of each, I can determine whether s also contains only unique elements (ignoring case).

EDIT: Updated to satisfy the previously-overlooked requirement to return False for numeric inputs. The set of all digits is encoded as set(str(56**7)).

EDIT 2: Following this user suggestion, I now take advantage of unpacking the arguments to set comprehension. This formally breaks compatibility with Python 2.

Scott Norton

Posted 2018-04-17T18:22:50.690

Reputation: 101

3welcome to PPCG! This also is supposed to return false when s contains a digit character. – Giuseppe – 2018-04-17T19:24:12.763

is using \56**7`` (as in the other python answer) instead of str() shorter? I'm not familiar with python but that seems to be the main difference between your two answers. – Giuseppe – 2018-04-17T19:34:18.560

@Giuseppe python3 don't have \``, a python2-only version would save 4 bytes (3 on this + 1 on division instead equals) – Rod – 2018-04-17T19:42:46.793

@Rod exactly right. Funnily enough, the 56**7 was inspired by your own encoding of the digits 0-9 below, but saves on yours by 1 byte. – Scott Norton – 2018-04-17T20:14:12.687

Perhaps you can add a Python 2 version? 46 Bytes: lambda s:len(s)==len(set(s.lower())-{\56**7`})` – Sunny Patel – 2018-04-17T20:25:55.720

@SunnyPatel That does not actually work, unfortunately; you actually need to call set on \56**7``. – Scott Norton – 2018-04-17T21:17:52.063

Well I be damned. I didn't check the test case with a number. xD – Sunny Patel – 2018-04-18T14:10:14.447

5

05AB1E, 5 bytes

lDáÙQ

Try it online!

Explanation

l        # convert input to lower-case
 D       # duplicate
  á      # keep only letters
   Ù      # remove duplicates
    Q     # compare for equality

Emigna

Posted 2018-04-17T18:22:50.690

Reputation: 50 798

4

R, 41 bytes

!grepl("(.).*\\1|\\d",tolower(scan(,"")))

Try it online!

Regex approach. !grepl(regex,scan(,""),F) didn't work so I guess capturing doesn't match case-insensitively in R? I'm bad at regex in general, though, so I won't be surprised if I'm just doing it wrong...

R, 58 bytes

!anyDuplicated(c(el(strsplit(tolower(scan(,"")),"")),0:9))

Try it online!

Appends the digits 0:9 to the (lowercased) list of characters and tests if there are any duplicates.

Giuseppe

Posted 2018-04-17T18:22:50.690

Reputation: 21 077

3

Ruby, 25 23 21 bytes

-2 bytes on both thanks to Giuseppe

->s{/(.).*\1|\d/i!~s}

Try it online!


-2 bytes thanks to Kirill L.

Ruby -n, 21 19 18 16 bytes

p !/(.).*\1|\d/i

Try it online!

Asone Tuhid

Posted 2018-04-17T18:22:50.690

Reputation: 1 944

@Giuseppe I didn't think that would work, thanks – Asone Tuhid – 2018-04-17T19:21:43.830

1

I think, in the second version, you don't even need $_ - just throwing in a regex without anything else implicitly matches it against $_: 16 bytes

– Kirill L. – 2018-04-18T12:23:12.377

@KirillL. thanks, I never saw !/.../ before, can't even find it on ruby-doc.org

– Asone Tuhid – 2018-04-18T12:30:44.677

Not surprising, I also learned about it here after getting advice from some Perl guy :) – Kirill L. – 2018-04-18T13:39:31.007

@KirillL. not surprising either, ruby weirdness is generally inherited from perl – Asone Tuhid – 2018-04-18T14:04:32.590

3

Brachylog, 4 bytes

ḷo⊆Ạ

Try it online!

The predicate will succeed if the input is an isogram and fail if it is not, outputting the lowercase Latin alphabet if it does succeed. Since Brachylog's built-in predicate doesn't exactly match the ordinary relationship between a subset and superset, I had to spend a byte on sorting the lowercased input, but saved a byte on not having to explicitly check for duplicates in it. (If it didn't need to fail with numbers, we could just use ḷ≠.)

Unrelated String

Posted 2018-04-17T18:22:50.690

Reputation: 5 300

2

JavaScript (Node.js), 29 25 bytes

s=>!/(.).*\1|\d/i.test(s)

Try it online!

Thanks for the update on answer to @BMO , @l4m2 , @KevinCruijssen

-4 bytes thanks to @KevinCruijssen

user79855

Posted 2018-04-17T18:22:50.690

Reputation:

s=>!/(.).*\1|[^a-z]/i.test(s)? – l4m2 – 2018-04-18T10:23:16.350

@KevinCruijssen : I didn't see the updated version – None – 2018-04-18T13:03:56.900

I'm pretty sure [^a-z] can be replaced with \d – Kevin Cruijssen – 2018-04-18T14:52:21.337

@KevinCruijssen : Thanks. updated – None – 2018-04-18T15:52:11.557

2

Husk, 6 bytes

§=f√ü_

Try it online!

Explanation

§=f√ü_  -- takes a string as argument, eg: "sAad2"
§       -- fork the argument..
  f√    -- | filter out non-letters: "sad"
    ü_  -- | deduplicate by lower-case: "sAd2"
 =      -- ..and compare: 0

ბიმო

Posted 2018-04-17T18:22:50.690

Reputation: 15 345

2

Japt 2.0, 12 11 bytes

-1 byte thanks to Nit

v
f\l â eUq

Test it online!

Oliver

Posted 2018-04-17T18:22:50.690

Reputation: 7 160

Uh, why did you change the version to a longer one? Also, I think the last version of Japt is 1.4.4... – Erik the Outgolfer – 2018-04-17T19:03:25.037

@EriktheOutgolfer The original didn't account for numbers automatically returning false. – Oliver – 2018-04-17T19:04:19.357

Ah, so you used an alpha version because it's actually shorter. – Erik the Outgolfer – 2018-04-17T19:05:00.490

@EriktheOutgolfer Right. The regex would've cost +2 in vanilla Japt. https://ethproductions.github.io/japt/?v=1.4.5&code=diBmIiVsIiDiIMqlVWw=&input=ImExIg==

– Oliver – 2018-04-17T19:07:25.093

Matched with vanilla Japt, not using regex makes it equal length: https://codegolf.stackexchange.com/a/162672/16484

– Nit – 2018-04-18T07:53:20.417

1@Nit Thanks! Good use of e – Oliver – 2018-04-18T13:41:45.390

2

Retina, 16 bytes

Ci`(.).*\1|\d
^0

Returns 1 as Truthy and 0 as Falsey values.
Thanks @Neil for discovering and fixing a bug in my initial code.

Try it online.

Explanation:

C             Check if the input matches part of the following regex:
 i`            Case insensitivity enabled
               Check if part of the input matches either:
  (.)           A character `C`
     .*         followed by zero or more characters
       \1       followed by the same character `C` again
         |     Or
          \d    A digit
^0             Invert Truthy/Falsey, basically replacing every 0 with a 1,
               and every other value with a 1

Kevin Cruijssen

Posted 2018-04-17T18:22:50.690

Reputation: 67 575

Why is yours opposite ? – Muhammad Salman – 2018-04-18T07:35:55.057

@MuhammadSalman Two reasons: reversing the matches would cost more bytes. And I'm not too skilled with Retina so I'm not sure how to reverse the matches to begin with.. xD – Kevin Cruijssen – 2018-04-18T07:37:52.913

reason 1). Ah ok. reason 2). LOL – Muhammad Salman – 2018-04-18T07:40:53.867

2

Japt, 12 bytes

;v
oC ‰ eUq

Explanation:

;v
;         // Set alternative default vars, where C is the lowercase alphabet
 v        // Make the implicit input lowercase and reassign it
oC ‰ eUq
oC        // Remove all items from the input that are not in the alphabet
   ‰     // Split into chars and select unique array items
      eUq // Check if the result is equal to the input split into chars

Try it here.

Nit

Posted 2018-04-17T18:22:50.690

Reputation: 2 667

2

MATL, 9 bytes

kt2Y2X&X=

Try it online!

k   % Lowercase implicit input
t   % Duplicate that
2Y2 % Push lowercase alphabet
X&  % Intersection of alphabet and duplicate lowercase input
X=  % Check for exact equality.

Sanchises

Posted 2018-04-17T18:22:50.690

Reputation: 8 530

2

Python 3, 46 bytes

lambda s:s.isalpha()*len(s)==len({*s.lower()})

Try it online!

musicman523

Posted 2018-04-17T18:22:50.690

Reputation: 4 472

1

PowerShell, 91 bytes

param($b)($a=[char[]]$b.ToUpper()|group|sort c*)[0].Count-eq$a[-1].count-and$b-notmatch'\d'

Try it online!

Naive solution, but I can't come up with a better algorithm. Takes input $b, converts it ToUppercase, casts it as a char-array. Pipes that array into Group-Object which constructs a object that has name/count pairs for each input letter. We then sort that based on the count and take the 0th one thereof. We check that its .Count is -equal to the .Count of the last [-1] pair. If so, then the counts are all equal, otherwise we have a different amount of letters.

We then -and that with checking whether the input -notmatches against \d to rule out any digits in the input. That Boolean result is left on the pipeline and output is implicit.

AdmBorkBork

Posted 2018-04-17T18:22:50.690

Reputation: 41 581

1

Jelly, 8 bytes

ŒufØA⁼QƲ

Try it online!

Erik the Outgolfer

Posted 2018-04-17T18:22:50.690

Reputation: 38 134

1

Python 2, 57 56 bytes

x=input().lower()
print len(set(x)-set(`763**4`))/len(x)

Try it online!

First it turn then input into a set, removing the duplicates, then remove the digits (encoded in `763**4`), then check if the length is the same as the original input

Rod

Posted 2018-04-17T18:22:50.690

Reputation: 17 588

1

Java 8, 61 39 bytes

s->!s.matches("(?i).*((.).*\\2|\\d).*")

Explanation:

Try it online.

s->  // Method with String parameter and boolean return-type
  !s.matches("(?i).*((.).*\\2|\\d).*")
     //  Return whether the input does not match the regex

Regex explanation:

String#matches implicitly adds ^...$.

^(?i).*((.).*\2|\d).*$
 (?i)                      Enable case insensitivity
^    .*                    Zero or more leading characters
       (       |  )        Followed by either:
        (.)                 Any character `C`
           .*               with zero or more characters in between
             \2             followed by that same character `C` again
               |           Or:
                \d          Any digit
                   .*$     Followed by zero or more trailing characters

Kevin Cruijssen

Posted 2018-04-17T18:22:50.690

Reputation: 67 575

1

Visual Basic for Applications (32 bit), 102 bytes

s=LCase(InputBox(u)):j=1:For i=1To Len(s):k=Mid(s,i,1):j=j*0^Instr(i+1,s,k)*(k Like"[a-z]"):Next:?j<>0

Used the fact that in VBA 0^x yields 1 if x is zero and 0 otherwise. Run in immediate (debug) window.

Edit: as pointed out by Taylor in the comments this only works in 32 bit installs of MS Office.

dnep

Posted 2018-04-17T18:22:50.690

Reputation: 301

If you restrict your language to Excel VBA, then you can swap this over to s=LCase([A1]):j=1:For i=1To Len(s):k=Mid(s,i,1):j=j*0^InStr(i+1,s,k)*(k Like"[a-z]"):Next:?j<>0 for 95 bytes by taking input from [A1]. Also, it is worth noting that because Exponentiation in VBA is weird that this solution is restricted to 32 bit installs of office.

– Taylor Scott – 2018-04-20T16:38:38.440

Also, you can make your answer look better and more readable by using proper capitalization (see above) and adding a <!-- language-all: lang-vb --> flag to your answer to add syntax highlighting – Taylor Scott – 2018-04-20T16:40:42.133

1@TaylorScott thanks! Added syntax highlighting and noted de 32 bit restriction. About the Excel input, I'd rather keep the solution application-invariant whenever possible. – dnep – 2018-04-26T20:56:13.793

1

APL (Dyalog Unicode), 12 bytes

Anonymous tacit function.

(∪≡~∘⎕D)819⌶

Try it online!

819⌶ lowercase

() apply the following tacit function on that:

~∘⎕D remove Digits from the argument

∪≡ are the unique elements of the argument identical to that?

Adám

Posted 2018-04-17T18:22:50.690

Reputation: 37 779

1

Perl 6, 22 bytes

{!(.uc~~/(.).*$0|\d/)}

Try it online!

No matches for some character then later the same character. Implicit function as a code block, match implicitly on $_, invert book with !. Added |\d (ta Adam) but also needed .uc~~, which needed parentheses...

Alternative with Bags, 23 bytes

{.uc.ords.Bag⊆65..97}

Try it online!

This one normalises case then makes a bag (set with incidence counts). Subset or equal only true if all members are members of the comparison Bag, and all incidence counts are less than or equal to those in the comparison Bag. So any repeats or digits would make the comparison false.

Phil H

Posted 2018-04-17T18:22:50.690

Reputation: 1 376

Fails on abc1. – Adám – 2018-04-19T13:26:02.373

Ah, wrote this answer before the numbers spec was added. – Phil H – 2018-04-19T16:45:50.490

Can;t you just add |\d? – Adám – 2018-04-19T18:11:05.933

@Adám: Sort of. Realised it also didn't detect repeated letters if the cases of those letters was different, so needed to normalise case and add parens as well. – Phil H – 2018-04-19T20:07:19.360

Can't you use (?i) to make the regex case insensitive? – Adám – 2018-04-19T20:15:07.300

Seem to have hit a bug in that regard: https://github.com/rakudo/rakudo/issues/1749

– Phil H – 2018-04-19T20:23:48.580

119 bytes – Jo King – 2018-12-18T21:55:48.560

1

C (gcc), 87 85 83 bytes

f(s,p,b,P)char*s,*p;{for(b=s;*s;++s)for(p=b*=*s>64;b&&p<s;b=(*s^*p++)&95?b:0);s=b;}

Try it online!

Jonathan Frech

Posted 2018-04-17T18:22:50.690

Reputation: 6 681

@ceilingcat Fine suggestion, thanks. – Jonathan Frech – 2018-06-25T21:38:45.247

@ceilingcat Thank you. – Jonathan Frech – 2018-12-18T21:21:35.580

1

Swift, 81 bytes

let s=readLine()!.lowercased().characters;print(s.count<1||Set(s).count==s.count)

Try it online!

Tamás Sengel

Posted 2018-04-17T18:22:50.690

Reputation: 211

Nice! 25 bytes shorter than mine. – onnoweb – 2019-03-25T19:08:14.770

1

05AB1E, 4 bytes

lDÔQ

Try it online!

Explanation

l      # convert input to lowercase
 D     # duplicate and push to stack
  Ô    # uniquify the list of characters
   Q   # check for equality

LordColus

Posted 2018-04-17T18:22:50.690

Reputation: 229

This fails if the input contains non-letter characters. – Shaggy – 2018-06-26T15:43:56.963

This works – LordColus – 2018-06-26T15:46:08.743

The input will only contain letters and/or numbers, no spaces ([a-zA-Z0-9]) – LordColus – 2018-06-26T15:47:41.227

"*An isogram is a word consisting only of letters with no duplicates*" - i.e., "words" containing numbers should return a falsey value. See the 5th test case for an example. – Shaggy – 2018-06-26T15:50:11.447

My bad. See @Enigma's answer for the correct 05AB1E code. – LordColus – 2018-06-26T15:55:32.767

0

K (ngn/k), 18 bytes

{(a^,/$!10)~?a:_x}

Try it online!

ngn

Posted 2018-04-17T18:22:50.690

Reputation: 11 449

0

APL (Dyalog Unicode), 25 20 22 bytes

''≡'(.).*\1|\d'⎕S'&'⍠1

Try it online!

Returns 1 for true, else 0.

Saved 5 bytes thanks to @H.PWiz

Fixed, and saved another byte thanks to @Adám

How?

''≡'(.).*\1|\d'⎕S'&'⍠1 ⍝ Tacit fn
                    ⍠1 ⍝ Ignore case
               ⎕S'&'   ⍝ Search and return the match(es)
   '(.).*\1|\d'        ⍝ For this regex
''≡                    ⍝ And compare to the empty string

J. Sallé

Posted 2018-04-17T18:22:50.690

Reputation: 3 233

Fails on abc1. – Adám – 2018-04-18T20:46:38.887

Isn't \w. valid? – Adám – 2018-04-19T13:23:52.633

If you mean (.).*\1, no. It also fails for abc1 :/ – J. Sallé – 2018-04-19T13:25:40.007

I don't understand. What do you mean by "it also fails"? – Adám – 2018-04-19T13:27:09.087

If you Try it Online! you can see it returns 1 for abc1, when it should return 0.

– J. Sallé – 2018-04-19T13:29:46.673

Let us continue this discussion in chat.

– Adám – 2018-04-19T13:35:05.650

0

CJam, 11 bytes

qelA,s+_L|=

Try it online!

Explanation

The basic idea is to append each digit then check for duplicates. Since the append ensures that each digit is already present once, any further presence of digits will be a duplicate, causing it to return false.

q      e# read the input:            | "MOoSE1"
el     e# convert to lowercase:      | "moose1"
A      e# push 10:                   | "moose1" 10
,      e# range [0,N):               | "moose1" [0 1 2 3 4 5 6 7 8 9]
s      e# string representation:     | "moose1" "0123456789"
+      e# concatenate:               | "moose10123456789"
_      e# duplicate:                 | "moose10123456789" "moose10123456789"
L|     e# union with the empty list: | "moose10123456789" "mose1023456789"
       e# (this gets rid of duplicates)
=      e# Equal to original:         | 0

Esolanging Fruit

Posted 2018-04-17T18:22:50.690

Reputation: 13 542

0

Red, 76 bytes

func[s][a: charset[#"a"-#"z"#"A"-#"Z"]parse s[any[copy c a ahead not to c]]]

Try it online!

Galen Ivanov

Posted 2018-04-17T18:22:50.690

Reputation: 13 815

0

C#, 82 bytes

bool f(string s)=>!!(s.GroupBy(c=>c).Any(c=>c.Count()>1|(!Char.IsLetter(c.Key))));

edit: added test for char

edit: using GroupBy to shorten it by 5 byte

Raymond Osterbrink

Posted 2018-04-17T18:22:50.690

Reputation: 101

1Welcome to PPCG! I think you're missing the requirement that you also need to check that the input contains no digits. – Martin Ender – 2018-04-18T15:07:06.627

0

Smalltalk, 57 bytes

Method to be defined in class String:

s^(self select:#isLetter)asUppercase asSet size=self size

This is most likely self-explanatory.

Hans-Martin Mosner

Posted 2018-04-17T18:22:50.690

Reputation: 131

0

Tcl, 114 bytes

proc I w {lmap c [set L [split $w ""]] {if {[regexp -all -nocase $c $w]>1|![string is alp $c]} {return 0}}
expr 1}

Try it online!

Tcl, 121 bytes

proc I w {lmap c [set L [split $w ""]] {if {[llength [lsearch -al -noc $L $c]]>1|![string is alp $c]} {return 0}}
expr 1}

Try it online!

Still too long for my taste!

sergiol

Posted 2018-04-17T18:22:50.690

Reputation: 3 055

0

Pyth, 17 bytes

.Am&!t/rz0d}dGrz0

Test suite

Explanation:
.Am&!t/rz0d}dGrz0 # Code
  m           rz0 # Map the following over the lowercase input:
      /rz0d       #  Count occurrences of d in lowercase input
     t            #   minus 1
    !             #    inverted (0 -> True)
   &              #     and
           }dG    #      d is in the lowercase alphabet
.A                # Print whether all values are truthy
Python 3 translation:
z=input()
print(all(map(lambda d:not z.lower().count(d)-1and d in "abcdefghijklmnopqrstuvwxyz",z.lower())))

hakr14

Posted 2018-04-17T18:22:50.690

Reputation: 1 295

0

Excel VBA, 82 bytes

An Anonymous VBE immediate window function that takes input from range [A1] and outputs to the VBE immediate window.

[B1:B26]="=Len(A$1)-Len(Substitute(Lower(A$1),Char(Row()+95),""""))":?[Max(B:B)]<2

Taylor Scott

Posted 2018-04-17T18:22:50.690

Reputation: 6 709

0

PHP, 137 Bytes

Try it online!

Code, using ctype_alpha

function f($s){if(ctype_alpha($s)){echo(count(array_unique(count_chars
(strtolower($s))))>2)?0:1;}
else{echo(strlen($s))?0:1;}}

Explanation

(I am absolutely sure this can be shortened)

function f($s){
 if(ctype_alpha($s)){     #ctype_alpha check if the string contains only letters
  echo
   (array_values(array_unique(count_chars(strtolower($s))))!= 
      [0,1])?0:1;
   #count_chars, retuns an array with the times each letter is appear in the string
   #array_unique, returns an array with only the unique values
   #the array values will be [0,1] if no letter repeated
 }else{
    #here the empty string gets controlled, and if the string contained numbers
  echo(strlen($s))?0:1;
 }
}

Yes, i will try to reduce the bytes count :D

Francisco Hahn

Posted 2018-04-17T18:22:50.690

Reputation: 591

0

Perl 5 -p, 20 bytes

$_=!/\d/*!/(.).*\1/i

Try it online!

Xcali

Posted 2018-04-17T18:22:50.690

Reputation: 7 671

0

Julia 0.6, 29 bytes

s->!ismatch(r"\d|(.).*\1"i,s)

Try it online!

sundar - Reinstate Monica

Posted 2018-04-17T18:22:50.690

Reputation: 5 296

0

Perl 5 with -n -M5.010, 17 bytes

say!/\d|(.).*\1/i

Try it online!

Perl 5 port of my Julia answer.

sundar - Reinstate Monica

Posted 2018-04-17T18:22:50.690

Reputation: 5 296

0

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

s=>s.ToDictionary(c=>c<65?c/0:c<97?c:c-32)

Try it online!

Tests for success by presence or absence of an exception.

When a character is a number, a divide-by-zero exception is thrown. Uppercase and lowercase letters are converted to uppercase and used to construct a dictionary. A duplicate key exception will be thrown if the same character is used more than once.

dana

Posted 2018-04-17T18:22:50.690

Reputation: 2 541

0

C# (.NET Core), 112 bytes

Here's my (super long) take on this:

c=>{var k=c.ToLower().ToCharArray();return!Enumerable.SequenceEqual(k.Distinct(),k)|!c.Any(m=>char.IsDigit(m));}

It checks if the distinct version of the string is the same as the regular version, and if it is so, return false. Also return false if there is a digit in the string

Try it online!

Embodiment of Ignorance

Posted 2018-04-17T18:22:50.690

Reputation: 7 014

0

Python 2, 43 bytes

t=input().lower()
print len(set(t))==len(t)

Try it online!

Expects a quote-delimited string from STDIN as input.

Converts the input to lowercase to make comparisons case-insensitive, then compares the number of unique values to the total number of

Triggernometry

Posted 2018-04-17T18:22:50.690

Reputation: 765

0

Powershell, 32 bytes

param($s)$s-notmatch'\d|(.).*\1'

mazzy

Posted 2018-04-17T18:22:50.690

Reputation: 4 832

0

C (gcc) -Do=1<<*s%32, 53+12 47+12 = 59 bytes

i;f(char*s){for(i=o;i&o&&*s/58;i^=o)s++;s=!*s;}

Try it online!


Uses the bits of i to store whether a letter has been encountered.

#define o 1<<*s%32  //byte corresponding to letter *s
i;f(char*s){
    for(i=o;        //mark first character
        i&o&&*s/58; //until character duplicate (i&o) or end of string or number (*s/58)
        i^=o)       //toggle the character
        s++;        //step through string
    s=!*s;          //return
}

attinat

Posted 2018-04-17T18:22:50.690

Reputation: 3 495

0

MBASIC, 202 bytes

1 DIM A(26):INPUT S$:FOR I=1 TO LEN(S$):P=ASC(MID$(S$,I,1))
2 IF P>96 THEN P=P-96
3 IF P>64 THEN P=P-64
4 IF P>26 THEN 7
5 A(P)=A(P)+1:NEXT:FOR I=1 TO 26:IF A(I)>1 THEN 7
6 NEXT:PRINT"true":END
7 PRINT"false"

It's ugly but it works. Merry Christmas!

wooshinyobject

Posted 2018-04-17T18:22:50.690

Reputation: 171

0

Swift, 106 bytes

func j(s:String){var a:Set<Character>=[];for c in s{if c<"0"||c>"9"{a.insert(c)}};print(s.count==a.count)}

Try it online!

onnoweb

Posted 2018-04-17T18:22:50.690

Reputation: 211