How to resolve the algorithm Pangram checker step by step in the FutureBasic programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Pangram checker step by step in the FutureBasic programming language

Table of Contents

Problem Statement

A pangram is a sentence that contains all the letters of the English alphabet at least once. For example:   The quick brown fox jumps over the lazy dog.

Write a function or method to check a sentence to see if it is a   pangram   (or not)   and show its use.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Pangram checker step by step in the FutureBasic programming language

Source code in the futurebasic programming language

include "NSLog.incl"

local fn IsPangram( pangramString as CFStringRef ) as BOOL
  NSUInteger  i, count
  BOOL        result
  
  CFStringRef   lcPanStr = fn StringLowerCaseString( pangramString )
  CFMutableSetRef mutSet = fn MutableSetWithCapacity( 0 )
  
  count = len(lcPanStr)
  for i = 0 to count - 1
    if ( fn CharacterSetCharacterIsMember( fn CharacterSetLowercaseLetterSet, fn StringCharacterAtIndex( lcPanStr, i ) ) )
      MutableSetAddObject( mutSet, fn StringWithFormat( @"%c", fn StringCharacterAtIndex( lcPanStr, i ) ) )
    end if
  next
  if fn SetCount( mutSet ) >= 26 then result = YES else result = NO
end fn = result


CFStringRef testStr, trueStr, falseStr
CFArrayRef  array

trueStr  = @"Is a pangram"
falseStr = @"Not a pangram"

array = @[¬
@"My dog has fleas.",¬
@"The quick brown fox jumps over the lazy do.",¬
@"The quick brown fox jumped over the lazy dog.",¬
@"The quick brown fox jumps over the lazy dog.",¬
@"Jackdaws love my big sphinx of quartz.",¬
@"What's a jackdaw?",¬
@"Watch \"Jeopardy!\", Alex Trebek's fun TV quiz game.",¬
@"Pack my box with five dozen liquor jugs.",¬
@"This definitely is not a pangram.",¬
@"This is a random long sentence just for testing purposes."]

for testStr in array
  if ( fn IsPangram( testStr ) )
    NSLog( @"%13s : %@", fn StringUTF8String( trueStr ), testStr ) else NSLog( @"%s : %@", fn StringUTF8String( falseStr ), testStr )
  end if
next

HandleEvents

  

You may also check:How to resolve the algorithm Longest string challenge step by step in the Haskell programming language
You may also check:How to resolve the algorithm Camel case and snake case step by step in the XPL0 programming language
You may also check:How to resolve the algorithm Compare a list of strings step by step in the 360 Assembly programming language
You may also check:How to resolve the algorithm Seven-sided dice from five-sided dice step by step in the Lua programming language
You may also check:How to resolve the algorithm Index finite lists of positive integers step by step in the Raku programming language