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

cedricvaneer's solution

to Pangram in the CFML Track

Published at Jan 20 2020 · 0 comments
Test suite

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
box task run TestRunner --:watcher

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:



Wikipedia https://en.wikipedia.org/wiki/Pangram

Submitting Incomplete Solutions

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


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();




component extends="PangramTest" {

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

component {
	 public boolean function isPangram ( required string sentence ) {

		var letterMap = { 'A':0, 'B':0, 'C':0, 'D':0, 'E':0, 'F':0, 'G':0, 'H':0, 'I':0, 'J':0, 'K':0, 'L':0, 'M':0, 
											'N':0, 'O':0, 'P':0, 'Q':0, 'R':0, 'S':0, 'T':0, 'U':0, 'V':0, 'W':0, 'X':0, 'Y':0, 'Z':0 };

		for (var character in listToArray(arguments.sentence, "")) {
			if (structKeyExists(letterMap, uCase(character))) {
				letterMap[uCase(character)] += 1;

		for (var key in letterMap) {
			if (letterMap[key] == 0) {
				return false;

		return true;


Community comments

Find this solution interesting? Ask the author a question to learn more.

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?
  • Are there new concepts here that you could read more about to improve your understanding?