Pangrams

  • + 0 comments

    Scala

    def pangrams(s: String): String = {
            val cleansedString = s.toLowerCase().trim().distinct
            val cleansedAsciiArray = cleansedString.map(_.toInt).toArray
            
            val asciiArray = ('a'.toInt to 'z'.toInt).toArray
            
            val isPangram = asciiArray.intersect(cleansedAsciiArray).length == 26
            if(isPangram) "pangram" else "not pangram"
        }