Skip to content

Commit

Permalink
Add Pangram exercise
Browse files Browse the repository at this point in the history
  • Loading branch information
eNascimento178 committed Apr 11, 2024
1 parent f951dca commit e183f6b
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 0 deletions.
8 changes: 8 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@
"practices": [],
"prerequisites": [],
"difficulty": 6
},
{
"slug": "pangram",
"name": "Pangram",
"uuid": "daffe95d-fce2-4199-bd43-f95d91fd16ee",
"practices": [],
"prerequisites": [],
"difficulty": 2
}
]
},
Expand Down
8 changes: 8 additions & 0 deletions exercises/practice/pangram/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Instructions

Your task is to figure out if a sentence is a pangram.

A pangram is a sentence using every letter of the alphabet at least once.
It is case insensitive, so it doesn't matter if a letter is lower-case (e.g. `k`) or upper-case (e.g. `K`).

For this exercise, a sentence is a pangram if it contains each of the 26 letters in the English alphabet.
16 changes: 16 additions & 0 deletions exercises/practice/pangram/.docs/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Introduction

You work for a company that sells fonts through their website.
They'd like to show a different sentence each time someone views a font on their website.
To give a comprehensive sense of the font, the random sentences should use **all** the letters in the English alphabet.

They're running a competition to get suggestions for sentences that they can use.
You're in charge of checking the submissions to see if they are valid.

~~~~exercism/note
Pangram comes from Greek, παν γράμμα, pan gramma, which means "every letter".
The best known English pangram is:
> The quick brown fox jumps over the lazy dog.
~~~~
17 changes: 17 additions & 0 deletions exercises/practice/pangram/.meta/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"authors": [],
"files": {
"solution": [
"pangram.ijs"
],
"test": [
"test.ijs"
],
"example": [
".meta/example.ijs"
]
},
"blurb": "Determine if a sentence is a pangram.",
"source": "Wikipedia",
"source_url": "https://en.wikipedia.org/wiki/Pangram"
}
1 change: 1 addition & 0 deletions exercises/practice/pangram/.meta/example.ijs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
isPangram=: (a. {~ 97+i.26) ([: *./ e.) 0&(3!:12)
45 changes: 45 additions & 0 deletions exercises/practice/pangram/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This is an auto-generated file.
#
# Regenerating this file via `configlet sync` will:
# - Recreate every `description` key/value pair
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
# - Preserve any other key/value pair
#
# As user-added comments (using the # character) will be removed when this file
# is regenerated, comments can be added via a `comment` key.

[64f61791-508e-4f5c-83ab-05de042b0149]
description = "empty sentence"

[74858f80-4a4d-478b-8a5e-c6477e4e4e84]
description = "perfect lower case"

[61288860-35ca-4abe-ba08-f5df76ecbdcd]
description = "only lower case"

[6564267d-8ac5-4d29-baf2-e7d2e304a743]
description = "missing the letter 'x'"

[c79af1be-d715-4cdb-a5f2-b2fa3e7e0de0]
description = "missing the letter 'h'"

[d835ec38-bc8f-48e4-9e36-eb232427b1df]
description = "with underscores"

[8cc1e080-a178-4494-b4b3-06982c9be2a8]
description = "with numbers"

[bed96b1c-ff95-45b8-9731-fdbdcb6ede9a]
description = "missing letters replaced by numbers"

[938bd5d8-ade5-40e2-a2d9-55a338a01030]
description = "mixed case and punctuation"

[2577bf54-83c8-402d-a64b-a2c0f7bb213a]
description = "case insensitive"
include = false

[7138e389-83e4-4c6e-8413-1e40a0076951]
description = "a-m and A-M are 26 different characters but not a pangram"
reimplements = "2577bf54-83c8-402d-a64b-a2c0f7bb213a"
3 changes: 3 additions & 0 deletions exercises/practice/pangram/pangram.ijs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require 'general/unittest'

isPangram=: 'You need to implement this verb.'13!:8 (55)
110 changes: 110 additions & 0 deletions exercises/practice/pangram/test.ijs
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
load 'pangram.ijs'


before_all=: monad define
(]Description =: (3 : 'descriptions=: i.0')`(3 : 'descriptions=: descriptions , < y'))@.0 ''
(]Order =: (3 : 'order=: i.0')`(3 : 'order=: order , < y'))@.0 ''
(]Task =: (3 : 'tasks=: i.0')`(3 : 'tasks=: tasks , < y'))@.0 ''
)


pangram_test_01_ignore=: 0
test_pangram_test_01 =: monad define
Description@.1 ('empty sentence')
Order@.1 (1)

NB. sentence=. ''
NB. expected=. 0
assert 0 -: isPangram ''
)

pangram_test_02_ignore=: 1 NB. Change this value to 0 to run this test
test_pangram_test_02 =: monad define
Description@.1 ('perfect lower case')
Order@.1 (2)

NB. sentence=. 'abcdefghijklmnopqrstuvwxyz'
NB. expected=. 1
assert 1 -: isPangram 'abcdefghijklmnopqrstuvwxyz'
)

pangram_test_03_ignore=: 1 NB. Change this value to 0 to run this test
test_pangram_test_03 =: monad define
Description@.1 ('only lower case')
Order@.1 (3)

NB. sentence=. 'the quick brown fox jumps over the lazy dog'
NB. expected=. 1
assert 1 -: isPangram 'the quick brown fox jumps over the lazy dog'
)

pangram_test_04_ignore=: 1 NB. Change this value to 0 to run this test
test_pangram_test_04 =: monad define
Description@.1 ('missing the letter ''x''')
Order@.1 (4)

NB. sentence=. 'a quick movement of the enemy will jeopardize five gunboats'
NB. expected=. 0
assert 0 -: isPangram 'a quick movement of the enemy will jeopardize five gunboats'
)

pangram_test_05_ignore=: 1 NB. Change this value to 0 to run this test
test_pangram_test_05 =: monad define
Description@.1 ('missing the letter ''h''')
Order@.1 (5)

NB. sentence=. 'five boxing wizards jump quickly at it'
NB. expected=. 0
assert 0 -: isPangram 'five boxing wizards jump quickly at it'
)

pangram_test_06_ignore=: 1 NB. Change this value to 0 to run this test
test_pangram_test_06 =: monad define
Description@.1 ('with underscores')
Order@.1 (6)

NB. sentence=. 'the_quick_brown_fox_jumps_over_the_lazy_dog'
NB. expected=. 1
assert 1 -: isPangram 'the_quick_brown_fox_jumps_over_the_lazy_dog'
)

pangram_test_07_ignore=: 1 NB. Change this value to 0 to run this test
test_pangram_test_07 =: monad define
Description@.1 ('with numbers')
Order@.1 (7)

NB. sentence=. 'the 1 quick brown fox jumps over the 2 lazy dogs'
NB. expected=. 1
assert 1 -: isPangram 'the 1 quick brown fox jumps over the 2 lazy dogs'
)

pangram_test_08_ignore=: 1 NB. Change this value to 0 to run this test
test_pangram_test_08 =: monad define
Description@.1 ('missing letters replaced by numbers')
Order@.1 (8)

NB. sentence=. '7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog'
NB. expected=. 0
assert 0 -: isPangram '7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog'
)

pangram_test_09_ignore=: 1 NB. Change this value to 0 to run this test
test_pangram_test_09 =: monad define
Description@.1 ('mixed case and punctuation')
Order@.1 (9)

NB. sentence=. '"Five quacking Zephyrs jolt my wax bed."'
NB. expected=. 1
assert 1 -:isPangram '"Five quacking Zephyrs jolt my wax bed."'
)

pangram_test_10_ignore=: 1 NB. Change this value to 0 to run this test
test_pangram_test_10 =: monad define
Description@.1 ('a-m and A-M are 26 different characters but not a pangram')
Order@.1 (10)

NB. sentence=. 'abcdefghijklm ABCDEFGHIJKLM'
NB. expected=. 0
assert 0 -: isPangram 'abcdefghijklm ABCDEFGHIJKLM'
)

0 comments on commit e183f6b

Please sign in to comment.