WeixiangYan/CodeTransOcean huggingface dataset:
Task: Pangram checker


C++: #include <algorithm>
#include <cctype>
#include <string>
#include <iostream>

const std::string alphabet("abcdefghijklmnopqrstuvwxyz");

bool is_pangram(std::string s)
{
    std::transform(s.begin(), s.end(), s.begin(), ::tolower);
    std::sort(s.begin(), s.end());
    return std::includes(s.begin(), s.end(), alphabet.begin(), alphabet.end());
}

int main()
{
    const auto examples = {"The quick brown fox jumps over the lazy dog",
                           "The quick white cat jumps over the lazy dog"};

    std::cout.setf(std::ios::boolalpha);
    for (auto& text : examples) {
        std::cout << "Is \"" << text << "\" a pangram? - " << is_pangram(text) << std::endl;
    }
}









Fortran: module pangram

  implicit none
  private
  public :: is_pangram
  character (*), parameter :: lower_case = 'abcdefghijklmnopqrstuvwxyz'
  character (*), parameter :: upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

contains

  function to_lower_case (input) result (output)

    implicit none
    character (*), intent (in) :: input
    character (len (input)) :: output
    integer :: i
    integer :: j

    output = input
    do i = 1, len (output)
      j = index (upper_case, output (i : i))
      if (j /= 0) then
        output (i : i) = lower_case (j : j)
      end if
    end do

  end function to_lower_case

  function is_pangram (input) result (output)

    implicit none
    character (*), intent (in) :: input
    character (len (input)) :: lower_case_input
    logical :: output
    integer :: i

    lower_case_input = to_lower_case (input)
    output = .true.
    do i = 1, len (lower_case)
      if (index (lower_case_input, lower_case (i : i)) == 0) then
        output = .false.
        exit
      end if
    end do

  end function is_pangram

end module pangram
Task: Pangram checker

C: #include <stdio.h>

int is_pangram(const char *s)
{
	const char *alpha = ""
		"abcdefghjiklmnopqrstuvwxyz"
		"ABCDEFGHIJKLMNOPQRSTUVWXYZ";

	char ch, wasused[26] = {0};
	int total = 0;

	while ((ch = *s++) != '\0') {
		const char *p;
		int idx;

		if ((p = strchr(alpha, ch)) == NULL)
			continue;

		idx = (p - alpha) % 26;

		total += !wasused[idx];
		wasused[idx] = 1;
		if (total == 26)
			return 1;
	}
	return 0;
}

int main(void)
{
	int i;
	const char *tests[] = {
		"The quick brown fox jumps over the lazy dog.",
		"The qu1ck brown fox jumps over the lazy d0g."
	};

	for (i = 0; i < 2; i++)
		printf("\"%s\" is %sa pangram\n",
			tests[i], is_pangram(tests[i])?"":"not ");
	return 0;
}










Fortran: module pangram

  implicit none
  private
  public :: is_pangram
  character (*), parameter :: lower_case = 'abcdefghijklmnopqrstuvwxyz'
  character (*), parameter :: upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

contains

  function to_lower_case (input) result (output)

    implicit none
    character (*), intent (in) :: input
    character (len (input)) :: output
    integer :: i
    integer :: j

    output = input
    do i = 1, len (output)
      j = index (upper_case, output (i : i))
      if (j /= 0) then
        output (i : i) = lower_case (j : j)
      end if
    end do

  end function to_lower_case

  function is_pangram (input) result (output)

    implicit none
    character (*), intent (in) :: input
    character (len (input)) :: lower_case_input
    logical :: output
    integer :: i

    lower_case_input = to_lower_case (input)
    output = .true.
    do i = 1, len (lower_case)
      if (index (lower_case_input, lower_case (i : i)) == 0) then
        output = .false.
        exit
      end if
    end do

  end function is_pangram

end module pangram
Task: Pangram checker





Java: public class Pangram {
    public static boolean isPangram(String test){
        for (char a = 'A'; a <= 'Z'; a++)
            if ((test.indexOf(a) < 0) && (test.indexOf((char)(a + 32)) < 0))
                return false;
        return true;
    }

    public static void main(String[] args){
        System.out.println(isPangram("the quick brown fox jumps over the lazy dog"));
        System.out.println(isPangram("the quick brown fox jumped over the lazy dog"));
        System.out.println(isPangram("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
        System.out.println(isPangram("ABCDEFGHIJKLMNOPQSTUVWXYZ"));
        System.out.println(isPangram("ABCDEFGHIJKL.NOPQRSTUVWXYZ"));
        System.out.println(isPangram("ABC.D.E.FGHI*J/KL-M+NO*PQ R\nSTUVWXYZ"));
        System.out.println(isPangram(""));
    }
}






Fortran: module pangram

  implicit none
  private
  public :: is_pangram
  character (*), parameter :: lower_case = 'abcdefghijklmnopqrstuvwxyz'
  character (*), parameter :: upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

contains

  function to_lower_case (input) result (output)

    implicit none
    character (*), intent (in) :: input
    character (len (input)) :: output
    integer :: i
    integer :: j

    output = input
    do i = 1, len (output)
      j = index (upper_case, output (i : i))
      if (j /= 0) then
        output (i : i) = lower_case (j : j)
      end if
    end do

  end function to_lower_case

  function is_pangram (input) result (output)

    implicit none
    character (*), intent (in) :: input
    character (len (input)) :: lower_case_input
    logical :: output
    integer :: i

    lower_case_input = to_lower_case (input)
    output = .true.
    do i = 1, len (lower_case)
      if (index (lower_case_input, lower_case (i : i)) == 0) then
        output = .false.
        exit
      end if
    end do

  end function is_pangram

end module pangram
Task: Pangram checker







Python: import string, sys
if sys.version_info[0] < 3:
    input = raw_input

def ispangram(sentence, alphabet=string.ascii_lowercase):
    alphaset = set(alphabet)
    return alphaset <= set(sentence.lower())

print ( ispangram(input('Sentence: ')) )




Fortran: module pangram

  implicit none
  private
  public :: is_pangram
  character (*), parameter :: lower_case = 'abcdefghijklmnopqrstuvwxyz'
  character (*), parameter :: upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

contains

  function to_lower_case (input) result (output)

    implicit none
    character (*), intent (in) :: input
    character (len (input)) :: output
    integer :: i
    integer :: j

    output = input
    do i = 1, len (output)
      j = index (upper_case, output (i : i))
      if (j /= 0) then
        output (i : i) = lower_case (j : j)
      end if
    end do

  end function to_lower_case

  function is_pangram (input) result (output)

    implicit none
    character (*), intent (in) :: input
    character (len (input)) :: lower_case_input
    logical :: output
    integer :: i

    lower_case_input = to_lower_case (input)
    output = .true.
    do i = 1, len (lower_case)
      if (index (lower_case_input, lower_case (i : i)) == 0) then
        output = .false.
        exit
      end if
    end do

  end function is_pangram

end module pangram
Task: Pangram checker








VB: Function pangram2(s As String) As Boolean
    Const sKey As String = "abcdefghijklmnopqrstuvwxyz"
    Dim sLow As String
    Dim i As Integer

    sLow = LCase(s)
    For i = 1 To 26
      If InStr(sLow, Mid(sKey, i, 1)) = 0 Then
        pangram2 = False
        Exit Function
      End If
    Next
    pangram2 = True
End Function



Fortran: module pangram

  implicit none
  private
  public :: is_pangram
  character (*), parameter :: lower_case = 'abcdefghijklmnopqrstuvwxyz'
  character (*), parameter :: upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

contains

  function to_lower_case (input) result (output)

    implicit none
    character (*), intent (in) :: input
    character (len (input)) :: output
    integer :: i
    integer :: j

    output = input
    do i = 1, len (output)
      j = index (upper_case, output (i : i))
      if (j /= 0) then
        output (i : i) = lower_case (j : j)
      end if
    end do

  end function to_lower_case

  function is_pangram (input) result (output)

    implicit none
    character (*), intent (in) :: input
    character (len (input)) :: lower_case_input
    logical :: output
    integer :: i

    lower_case_input = to_lower_case (input)
    output = .true.
    do i = 1, len (lower_case)
      if (index (lower_case_input, lower_case (i : i)) == 0) then
        output = .false.
        exit
      end if
    end do

  end function is_pangram

end module pangram
Task: Pangram checker






PHP: function isPangram($text) {
    foreach (str_split($text) as $c) {
        if ($c >= 'a' && $c <= 'z')
            $bitset |= (1 << (ord($c) - ord('a')));
        else if ($c >= 'A' && $c <= 'Z')
            $bitset |= (1 << (ord($c) - ord('A')));
    }
    return $bitset == 0x3ffffff;
}

$test = array(
    "the quick brown fox jumps over the lazy dog",
    "the quick brown fox jumped over the lazy dog",
    "ABCDEFGHIJKLMNOPQSTUVWXYZ",
    "ABCDEFGHIJKL.NOPQRSTUVWXYZ",
    "ABC.D.E.FGHI*J/KL-M+NO*PQ R\nSTUVWXYZ"
);

foreach ($test as $str)
    echo "$str : ", isPangram($str) ? 'T' : 'F', '</br>';





Fortran: module pangram

  implicit none
  private
  public :: is_pangram
  character (*), parameter :: lower_case = 'abcdefghijklmnopqrstuvwxyz'
  character (*), parameter :: upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

contains

  function to_lower_case (input) result (output)

    implicit none
    character (*), intent (in) :: input
    character (len (input)) :: output
    integer :: i
    integer :: j

    output = input
    do i = 1, len (output)
      j = index (upper_case, output (i : i))
      if (j /= 0) then
        output (i : i) = lower_case (j : j)
      end if
    end do

  end function to_lower_case

  function is_pangram (input) result (output)

    implicit none
    character (*), intent (in) :: input
    character (len (input)) :: lower_case_input
    logical :: output
    integer :: i

    lower_case_input = to_lower_case (input)
    output = .true.
    do i = 1, len (lower_case)
      if (index (lower_case_input, lower_case (i : i)) == 0) then
        output = .false.
        exit
      end if
    end do

  end function is_pangram

end module pangram
Task: Pangram checker

C: #include <stdio.h>

int is_pangram(const char *s)
{
	const char *alpha = ""
		"abcdefghjiklmnopqrstuvwxyz"
		"ABCDEFGHIJKLMNOPQRSTUVWXYZ";

	char ch, wasused[26] = {0};
	int total = 0;

	while ((ch = *s++) != '\0') {
		const char *p;
		int idx;

		if ((p = strchr(alpha, ch)) == NULL)
			continue;

		idx = (p - alpha) % 26;

		total += !wasused[idx];
		wasused[idx] = 1;
		if (total == 26)
			return 1;
	}
	return 0;
}

int main(void)
{
	int i;
	const char *tests[] = {
		"The quick brown fox jumps over the lazy dog.",
		"The qu1ck brown fox jumps over the lazy d0g."
	};

	for (i = 0; i < 2; i++)
		printf("\"%s\" is %sa pangram\n",
			tests[i], is_pangram(tests[i])?"":"not ");
	return 0;
}









COBOL:        identification division.
       program-id. pan-test.
       data division.
       working-storage section.
       1 text-string pic x(80).
       1 len binary pic 9(4).
       1 trailing-spaces binary pic 9(4).
       1 pangram-flag pic x value "n".
        88 is-not-pangram value "n".
        88 is-pangram value "y".
       procedure division.
       begin.
           display "Enter text string:"
           accept text-string
           set is-not-pangram to true
           initialize trailing-spaces len
           inspect function reverse (text-string)
           tallying trailing-spaces for leading space
               len for characters after space
           call "pangram" using pangram-flag len text-string
           cancel "pangram"
           if is-pangram
               display "is a pangram"
           else
               display "is not a pangram"
           end-if
           stop run
           .
       end program pan-test.

       identification division.
       program-id. pangram.
       data division.
       1 lc-alphabet pic x(26) value "abcdefghijklmnopqrstuvwxyz".
       linkage section.
       1 pangram-flag pic x.
        88 is-not-pangram value "n".
        88 is-pangram value "y".
       1 len binary pic 9(4).
       1 text-string pic x(80).
       procedure division using pangram-flag len text-string.
       begin.
           inspect lc-alphabet converting
               function lower-case (text-string (1:len))
               to space
           if lc-alphabet = space
               set is-pangram to true
           end-if
           exit program
           .
       end program pangram.
Task: Pangram checker



C#: using System;
using System.Linq;

static class Program
{
    static bool IsPangram(this string text, string alphabet = "abcdefghijklmnopqrstuvwxyz")
    {
        return alphabet.All(text.ToLower().Contains);
    }

    static void Main(string[] arguments)
    {
        Console.WriteLine(arguments.Any() && arguments.First().IsPangram());
    }
}







COBOL:        identification division.
       program-id. pan-test.
       data division.
       working-storage section.
       1 text-string pic x(80).
       1 len binary pic 9(4).
       1 trailing-spaces binary pic 9(4).
       1 pangram-flag pic x value "n".
        88 is-not-pangram value "n".
        88 is-pangram value "y".
       procedure division.
       begin.
           display "Enter text string:"
           accept text-string
           set is-not-pangram to true
           initialize trailing-spaces len
           inspect function reverse (text-string)
           tallying trailing-spaces for leading space
               len for characters after space
           call "pangram" using pangram-flag len text-string
           cancel "pangram"
           if is-pangram
               display "is a pangram"
           else
               display "is not a pangram"
           end-if
           stop run
           .
       end program pan-test.

       identification division.
       program-id. pangram.
       data division.
       1 lc-alphabet pic x(26) value "abcdefghijklmnopqrstuvwxyz".
       linkage section.
       1 pangram-flag pic x.
        88 is-not-pangram value "n".
        88 is-pangram value "y".
       1 len binary pic 9(4).
       1 text-string pic x(80).
       procedure division using pangram-flag len text-string.
       begin.
           inspect lc-alphabet converting
               function lower-case (text-string (1:len))
               to space
           if lc-alphabet = space
               set is-pangram to true
           end-if
           exit program
           .
       end program pangram.
Task: Pangram checker


C++: #include <algorithm>
#include <cctype>
#include <string>
#include <iostream>

const std::string alphabet("abcdefghijklmnopqrstuvwxyz");

bool is_pangram(std::string s)
{
    std::transform(s.begin(), s.end(), s.begin(), ::tolower);
    std::sort(s.begin(), s.end());
    return std::includes(s.begin(), s.end(), alphabet.begin(), alphabet.end());
}

int main()
{
    const auto examples = {"The quick brown fox jumps over the lazy dog",
                           "The quick white cat jumps over the lazy dog"};

    std::cout.setf(std::ios::boolalpha);
    for (auto& text : examples) {
        std::cout << "Is \"" << text << "\" a pangram? - " << is_pangram(text) << std::endl;
    }
}








COBOL:        identification division.
       program-id. pan-test.
       data division.
       working-storage section.
       1 text-string pic x(80).
       1 len binary pic 9(4).
       1 trailing-spaces binary pic 9(4).
       1 pangram-flag pic x value "n".
        88 is-not-pangram value "n".
        88 is-pangram value "y".
       procedure division.
       begin.
           display "Enter text string:"
           accept text-string
           set is-not-pangram to true
           initialize trailing-spaces len
           inspect function reverse (text-string)
           tallying trailing-spaces for leading space
               len for characters after space
           call "pangram" using pangram-flag len text-string
           cancel "pangram"
           if is-pangram
               display "is a pangram"
           else
               display "is not a pangram"
           end-if
           stop run
           .
       end program pan-test.

       identification division.
       program-id. pangram.
       data division.
       1 lc-alphabet pic x(26) value "abcdefghijklmnopqrstuvwxyz".
       linkage section.
       1 pangram-flag pic x.
        88 is-not-pangram value "n".
        88 is-pangram value "y".
       1 len binary pic 9(4).
       1 text-string pic x(80).
       procedure division using pangram-flag len text-string.
       begin.
           inspect lc-alphabet converting
               function lower-case (text-string (1:len))
               to space
           if lc-alphabet = space
               set is-pangram to true
           end-if
           exit program
           .
       end program pangram.
Task: Pangram checker





Java: public class Pangram {
    public static boolean isPangram(String test){
        for (char a = 'A'; a <= 'Z'; a++)
            if ((test.indexOf(a) < 0) && (test.indexOf((char)(a + 32)) < 0))
                return false;
        return true;
    }

    public static void main(String[] args){
        System.out.println(isPangram("the quick brown fox jumps over the lazy dog"));
        System.out.println(isPangram("the quick brown fox jumped over the lazy dog"));
        System.out.println(isPangram("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
        System.out.println(isPangram("ABCDEFGHIJKLMNOPQSTUVWXYZ"));
        System.out.println(isPangram("ABCDEFGHIJKL.NOPQRSTUVWXYZ"));
        System.out.println(isPangram("ABC.D.E.FGHI*J/KL-M+NO*PQ R\nSTUVWXYZ"));
        System.out.println(isPangram(""));
    }
}





COBOL:        identification division.
       program-id. pan-test.
       data division.
       working-storage section.
       1 text-string pic x(80).
       1 len binary pic 9(4).
       1 trailing-spaces binary pic 9(4).
       1 pangram-flag pic x value "n".
        88 is-not-pangram value "n".
        88 is-pangram value "y".
       procedure division.
       begin.
           display "Enter text string:"
           accept text-string
           set is-not-pangram to true
           initialize trailing-spaces len
           inspect function reverse (text-string)
           tallying trailing-spaces for leading space
               len for characters after space
           call "pangram" using pangram-flag len text-string
           cancel "pangram"
           if is-pangram
               display "is a pangram"
           else
               display "is not a pangram"
           end-if
           stop run
           .
       end program pan-test.

       identification division.
       program-id. pangram.
       data division.
       1 lc-alphabet pic x(26) value "abcdefghijklmnopqrstuvwxyz".
       linkage section.
       1 pangram-flag pic x.
        88 is-not-pangram value "n".
        88 is-pangram value "y".
       1 len binary pic 9(4).
       1 text-string pic x(80).
       procedure division using pangram-flag len text-string.
       begin.
           inspect lc-alphabet converting
               function lower-case (text-string (1:len))
               to space
           if lc-alphabet = space
               set is-pangram to true
           end-if
           exit program
           .
       end program pangram.
Task: Pangram checker







Python: import string, sys
if sys.version_info[0] < 3:
    input = raw_input

def ispangram(sentence, alphabet=string.ascii_lowercase):
    alphaset = set(alphabet)
    return alphaset <= set(sentence.lower())

print ( ispangram(input('Sentence: ')) )



COBOL:        identification division.
       program-id. pan-test.
       data division.
       working-storage section.
       1 text-string pic x(80).
       1 len binary pic 9(4).
       1 trailing-spaces binary pic 9(4).
       1 pangram-flag pic x value "n".
        88 is-not-pangram value "n".
        88 is-pangram value "y".
       procedure division.
       begin.
           display "Enter text string:"
           accept text-string
           set is-not-pangram to true
           initialize trailing-spaces len
           inspect function reverse (text-string)
           tallying trailing-spaces for leading space
               len for characters after space
           call "pangram" using pangram-flag len text-string
           cancel "pangram"
           if is-pangram
               display "is a pangram"
           else
               display "is not a pangram"
           end-if
           stop run
           .
       end program pan-test.

       identification division.
       program-id. pangram.
       data division.
       1 lc-alphabet pic x(26) value "abcdefghijklmnopqrstuvwxyz".
       linkage section.
       1 pangram-flag pic x.
        88 is-not-pangram value "n".
        88 is-pangram value "y".
       1 len binary pic 9(4).
       1 text-string pic x(80).
       procedure division using pangram-flag len text-string.
       begin.
           inspect lc-alphabet converting
               function lower-case (text-string (1:len))
               to space
           if lc-alphabet = space
               set is-pangram to true
           end-if
           exit program
           .
       end program pangram.
Task: Pangram checker








VB: Function pangram2(s As String) As Boolean
    Const sKey As String = "abcdefghijklmnopqrstuvwxyz"
    Dim sLow As String
    Dim i As Integer

    sLow = LCase(s)
    For i = 1 To 26
      If InStr(sLow, Mid(sKey, i, 1)) = 0 Then
        pangram2 = False
        Exit Function
      End If
    Next
    pangram2 = True
End Function


COBOL:        identification division.
       program-id. pan-test.
       data division.
       working-storage section.
       1 text-string pic x(80).
       1 len binary pic 9(4).
       1 trailing-spaces binary pic 9(4).
       1 pangram-flag pic x value "n".
        88 is-not-pangram value "n".
        88 is-pangram value "y".
       procedure division.
       begin.
           display "Enter text string:"
           accept text-string
           set is-not-pangram to true
           initialize trailing-spaces len
           inspect function reverse (text-string)
           tallying trailing-spaces for leading space
               len for characters after space
           call "pangram" using pangram-flag len text-string
           cancel "pangram"
           if is-pangram
               display "is a pangram"
           else
               display "is not a pangram"
           end-if
           stop run
           .
       end program pan-test.

       identification division.
       program-id. pangram.
       data division.
       1 lc-alphabet pic x(26) value "abcdefghijklmnopqrstuvwxyz".
       linkage section.
       1 pangram-flag pic x.
        88 is-not-pangram value "n".
        88 is-pangram value "y".
       1 len binary pic 9(4).
       1 text-string pic x(80).
       procedure division using pangram-flag len text-string.
       begin.
           inspect lc-alphabet converting
               function lower-case (text-string (1:len))
               to space
           if lc-alphabet = space
               set is-pangram to true
           end-if
           exit program
           .
       end program pangram.