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 isogramfalse
or any falsy value otherwise
This is code-golf so shortest code in bytes in each language wins.
3Suggested test case:
sad2
– Adám – 2018-04-17T18:43:22.2131Your 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.5403@MuhammadSalman This is very sloppy, please remove ". Any" from the end of you quote and give some more examples (
sad2das
would fail even without the2
so it doesn't show anything). – Asone Tuhid – 2018-04-17T19:18:40.2104The "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
, andm
. – 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