Sort by

recency

|

1930 Discussions

|

  • + 0 comments

    python3 1 line solution:

    def pangrams(s):
        return "pangram" if len(list(set((s.replace(" ","").lower())))) == 26 else "not pangram"
    
  • + 0 comments

    Here is my c++ solution, you can watch the explanation here : https://youtu.be/-8w6U6qPNrA

    #include <bits/stdc++.h>
    
    using namespace std;
    
    int main()
    {
        string s;
        getline(cin, s);
        vector<int> c(26, 0);
        for(int i = 0; i < s.size(); i++){
            if(s[i] != ' ')
            c[tolower(s[i]) - 'a']++;
        }
        string r = "pangram";
        for(int i = 0; i < c.size(); i++){
            if(c[i] == 0){
                r = "not " + r;
                break;
            }
        }
        cout << r ;
        return 0;
    }
    
  • + 0 comments

    s=input().lower() import string for i in string.ascii_lowercase: if i not in s: print('not pangram') break else: print('pangram')

  • + 0 comments

    Perl:

    sub pangrams {
        my $s = shift;
        
        my %h;
        $s =~ s/\s+//gm;
        $s = lc($s);
        my @arr = split("", $s);
        %h = map {$_ => 1} grep {$_} @arr;
        return ((keys %h) == 26) ? "pangram" : "not pangram";
    }
    
  • + 0 comments

    My answer in Typescript, simple, not minimized

    function pangrams(s: string): string {
        /**
         * idea is simple
         * 1. create a set of unique character in [s]
         * 2. counting that set
         *      if count == 26 return 'pangram'
         *      if count != 26 return 'not pangram'
         * 
         * note: 26 is number of letter in alphabet (in same case lower/upper)
         */
    
        let _s = new Set<string>()
    
        for (let i = 0; i < s.length; i++) {
            if (s[i] == ' ') continue // i'm not counting spaces
            _s.add(s[i].toLowerCase())
        }
    
        return _s.size == 26 ? 'pangram' : 'not pangram'
    }