Discussion
· Mar 2, 2023

Code Golf: Isogram

It's time for a Code Golf round!

Isogram 

A word or phrase that has no repeating letters, consecutive or non-consecutive.


Implement a method that checks if the received string is an isogram or not.
Assume the empty string is an isogram. 
Ignore the letter case.

Allowed inputs: A-Z, a-z.

As usual, the shortest solution wins!Input

"pseudomythical"

Output

1

Note

Rules

  1. The signature of the contest entry MUST be:
Class codeGolf.Isogram
{ 

ClassMethod Check(word As %String) As %Boolean
{
  // Your solution here
}

}
  1. It is forbidden to modify class/signature, including but not limited to:
  • Adding inheritance
  • Setting default argument values
  • Adding class elements (Parameters, Methods, Includes, etc).
  1. It is forbidden to refer to non-system code from your entry. For example, this is not a valid entry:
ClassMethod Build(f As %Integer)
{
  W ##class(myPackage.myClass).test(a)
}
  1. The use of $ZWPACK and $ZWBPACK is also discouraged.
  2. You can use this test case:
    Class tests.codeGolf.unittests.TestIsogram Extends %UnitTest.TestCase
    {
    
    Method TestCheckIsIsogram()
    {
        Do $$$AssertTrue(##class(codeGolf.Isogram).Check("uncopyrightable"))
        Do $$$AssertTrue(##class(codeGolf.Isogram).Check("upholstering"))
        Do $$$AssertTrue(##class(codeGolf.Isogram).Check("shlockumentary"))
        Do $$$AssertTrue(##class(codeGolf.Isogram).Check("Isogram"))
        Do $$$AssertTrue(##class(codeGolf.Isogram).Check("rock"))
        Do $$$AssertTrue(##class(codeGolf.Isogram).Check("ambiDEXtrously"))
        Do $$$AssertTrue(##class(codeGolf.Isogram).Check("neurolymphatic"))
        Do $$$AssertTrue(##class(codeGolf.Isogram).Check(""), "an empty string is a valid isogram")
        Do $$$AssertNotTrue(##class(codeGolf.Isogram).Check("goose"))
        Do $$$AssertNotTrue(##class(codeGolf.Isogram).Check("goOse"))
        Do $$$AssertNotTrue(##class(codeGolf.Isogram).Check("Balboa"))
        Do $$$AssertNotTrue(##class(codeGolf.Isogram).Check("isIsogram"))
        Do $$$AssertNotTrue(##class(codeGolf.Isogram).Check("aba"))
        Do $$$AssertNotTrue(##class(codeGolf.Isogram).Check("Silmarillion"))
        Do $$$AssertNotTrue(##class(codeGolf.Isogram).Check("JohnRambo"))
    }
    
    }
Discussion (11)1
Log in or sign up to continue