🎉 Exercism Research is now launched. Help Exercism, help science and have some fun at research.exercism.io 🎉

# The-F00L's solution

## to Pangram in the CFML Track

Published at Apr 12 2021 · 0 comments
Instructions
Test suite
Solution

Determine if a sentence is a pangram. A pangram (Greek: παν γράμμα, pan gramma, "every letter") is a sentence using every letter of the alphabet at least once. The best known English pangram is:

The quick brown fox jumps over the lazy dog.

The alphabet used consists of ASCII letters `a` to `z`, inclusive, and is case insensitive. Input will not contain non-ASCII symbols.

To run the code in this exercise, you will only need to have CommandBox CLI installed. This binary runs CFML code from the command line.

To run the tests, `cd` into the exercise folder and run the following:

``````box task run TestRunner
# Or start up a test watcher that will rerun when files change
``````

The tests leverage a library called TestBox which supports xUnit and BDD style of testing. All test suites will be written in the BDD style which uses closures to define test specs. You won't need to worry about installing TestBox. The CLI test runner will take care of that for you. You just need to be connected to the internet the first time you run it. You can read more about it here:

https://testbox.ortusbooks.com/content/

## Submitting Incomplete Solutions

It's possible to submit an incomplete solution so you can see how others have completed the exercise.

### PangramTest.cfc

``````component extends="testbox.system.BaseSpec" {

function beforeAll(){
SUT = createObject( 'Pangram' );
}

function run(){

describe( "My Pangram class", function(){

describe( 'Check if the given string is an pangram', function(){

it( 'sentence empty', function(){
expect( SUT.isPangram( sentence='' ) ).toBeFalse();
});

it( 'recognizes a perfect lower case pangram', function(){
expect( SUT.isPangram( sentence='abcdefghijklmnopqrstuvwxyz' ) ).toBeTrue();
});

it( 'pangram with only lower case', function(){
expect( SUT.isPangram( sentence='the quick brown fox jumps over the lazy dog' ) ).toBeTrue();
});

it( 'missing character ''x''', function(){
expect( SUT.isPangram( sentence='a quick movement of the enemy will jeopardize five gunboats' ) ).toBeFalse();
});

it( 'another missing character, e.g. ''h''', function(){
expect( SUT.isPangram( sentence='five boxing wizards jump quickly at it' ) ).toBeFalse();
});

it( 'pangram with underscores', function(){
expect( SUT.isPangram( sentence='the_quick_brown_fox_jumps_over_the_lazy_dog' ) ).toBeTrue();
});

it( 'pangram with numbers', function(){
expect( SUT.isPangram( sentence='the 1 quick brown fox jumps over the 2 lazy dogs' ) ).toBeTrue();
});

it( 'missing letters replaced by numbers', function(){
expect( SUT.isPangram( sentence='7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog' ) ).toBeFalse();
});

it( 'pangram with mixed case and punctuation', function(){
expect( SUT.isPangram( sentence='"Five quacking Zephyrs jolt my wax bed."' ) ).toBeTrue();
});

it( 'upper and lower case versions of the same character should not be counted separately', function(){
expect( SUT.isPangram( sentence='the quick brown fox jumps over with lazy FX' ) ).toBeFalse();
});

});

});

}

}``````

### SolutionTest.cfc

``````component extends="PangramTest" {

function beforeAll(){
SUT = createObject( 'Solution' );
}

}``````
``````/**
* Your implmentation of the Pangram exercise
*/
component {

/**
* @returns
*/
function isPangram( sentence ) {
alph=listToArray("abcdefghijklmnopqrstuvwxyz",'');
senAlph="";
sentence=lCase(rereplace(sentence,"[^A-Za-z]","","all"));
for (az in alph) {
if (find(az,sentence)==0) {
return false;
}
}
return true;
}

}``````

### What can you learn from this solution?

A huge amount can be learned from reading other people’s code. This is why we wanted to give exercism users the option of making their solutions public.

Here are some questions to help you reflect on this solution and learn the most from it.

• What compromises have been made?