ðŸŽ‰ Exercism Research is now launched. Help Exercism, help science and have some fun at research.exercism.io ðŸŽ‰

# JaeHyoLee's solution

## to Isogram in the Lua Track

Published at Jul 13 2018 · 0 comments
Instructions
Test suite
Solution

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.

## Running the tests

To run the tests, run the command `busted` from within the exercise directory.

## Further information

For more detailed information about the Lua track, including how to get help if you're having trouble, please visit the exercism.io Lua language page.

## Submitting Incomplete Solutions

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

### isogram_spec.lua

``````local is_isogram = require 'isogram'

describe('isogram', function()
it('should identify simple isograms', function()
assert.is_true(is_isogram('duplicates'))
assert.is_true(is_isogram('subdermatoglyphic'))
end)

it('should identify words with repeated letters as non-isograms', function()
assert.is_false(is_isogram('eleven'))
end)

it('should be case insensitive', function()
assert.is_false(is_isogram('Alphabet'))
end)

it('should allow punctuations in isograms', function()
assert.is_true(is_isogram('thumbscrew-japingly'))
end)

it('should allow repeated punctuation in isograms', function()
assert.is_true(is_isogram('Hjelmqvist-Gryb-Zock-Pfund-Wax'))
end)

it('should identify non-isogram sentences', function()
assert.is_false(is_isogram('the quick brown fox'))
end)

it('should identify isogram sentences', function()
assert.is_true(is_isogram('Emily Jung Schwartzkopf'))
end)
end)``````
``````return function(s)
local n = s:gsub('%A',''):lower()
local t = table.pack(n:byte(1, #n))
table.sort(t)

for k = 2, #t do
if t[k - 1] == t[k] then return false end
end
return true
end``````