Exercism v3 launches on Sept 1st 2021. Learn more! 🚀🚀🚀
Avatar of maneeshgoel

maneeshgoel's solution

to Isogram in the Objective-C Track

Published at Jul 13 2018 · 0 comments
Test suite

Determine if a word or phrase is an isogram.

An isogram (also known as a "nonpattern word") is a word or phrase without a repeating letter, however spaces and hyphens are allowed to appear multiple times.

Examples of isograms:

  • lumberjacks
  • background
  • downstream
  • six-year-old

The word isograms, however, is not an isogram, because the s repeats.


There are two different methods of getting set up to run the tests with Objective-C:

  • Create an Xcode project with a test target which will run the tests.
  • Use the ruby gem objc as a test runner utility.

Both are described in more detail here: http://exercism.io/languages/objective-c

Submitting Exercises

When submitting an exercise, make sure your solution file is in the same directory as the test code.

The submit command will look something like:

exercism submit <path-to-exercism-workspace>/objective-c/isogram/Isogram.m

You can find the Exercism workspace by running exercism debug and looking for the line beginning with Workspace.


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

Submitting Incomplete Solutions

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


#import <XCTest/XCTest.h>

#if __has_include("IsogramExample.h")
# import "IsogramExample.h"
# else
# import "Isogram.h"

@interface IsogramTest : XCTestCase


@implementation IsogramTest

- (void)testEmptyString {
    XCTAssertTrue([Isogram isIsogram:@""]);

- (void)testIsogramWithOnlyLowerCaseCharacters {
    XCTAssertTrue([Isogram isIsogram:@"isogram"]);

- (void)testWordWithOneDuplicatedCharacter {
    XCTAssertFalse([Isogram isIsogram:@"eleven"]);

- (void)testLongestReportedEnglishIsogram {
    XCTAssertTrue([Isogram isIsogram:@"subdermatoglyphic"]);

- (void)testWordWithDuplicatedCharacterInMixedCase {
    XCTAssertFalse([Isogram isIsogram:@"Alphabet"]);

- (void)testHypotheticalIsogrammicWordWithHyphen {
    XCTAssertTrue([Isogram isIsogram:@"thumbscrew-japingly"]);

- (void)testIsogramWithDuplicatedNonLetterCharacter {
    XCTAssertTrue([Isogram isIsogram:@"Hjelmqvist-Gryb-Zock-Pfund-Wax"]);

- (void)testMadeUpNameThatIsAnIsogram {
    XCTAssertTrue([Isogram isIsogram:@"Emily Jung Schwartzkopf"]);



//  Isogram.h
//  IsogramTests
//  Created by Maneesh Goel on 3/15/18.
//  Copyright © 2018 Maneesh Goel. All rights reserved.

#import <Foundation/Foundation.h>

@interface Isogram : NSObject
+(BOOL)isIsogram:(NSString *)subject;


//  Isogram.m
//  IsogramTests
//  Created by Maneesh Goel on 3/15/18.
//  Copyright © 2018 Maneesh Goel. All rights reserved.

#import "Isogram.h"

@implementation Isogram
+(BOOL)isIsogram:(NSString *)subject {
    NSMutableSet *letters = [[NSMutableSet alloc] init];
    NSString *trimmedSubject = [[[subject lowercaseString] componentsSeparatedByCharactersInSet:[[NSCharacterSet letterCharacterSet] invertedSet]] componentsJoinedByString:@""];
    for (NSInteger i = 0; i < trimmedSubject.length; i++) {
        NSString *character = [trimmedSubject substringWithRange:NSMakeRange(i, 1)];
        if ([letters containsObject:character]) {
            return NO;
        else {
            [letters addObject:character];
    return YES;

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?