Sort by

recency

|

1929 Discussions

|

  • + 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'
    }
    
  • + 0 comments
    public static String pangrams(String s) {
      boolean[] alphabet = new boolean[26];
    
      for (int i = 0; i < s.length(); i++) {
        if (s.charAt(i) >= 'a' && s.charAt(i) <= 'z') {
          System.out.println(s.charAt(i) - 'a');
          alphabet[(s.charAt(i) - 'a')] = true;
        } else if (s.charAt(i) >= 'A' && s.charAt(i) <= 'Z') {
          alphabet[s.charAt(i) - 'A'] = true;
        }
      }
      for (int i = 0; i < alphabet.length; i++) {
        if (!alphabet[i]) {
          return "not pangram";
        }
      }
      return "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;
    }