-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7073f22
commit a288c97
Showing
13 changed files
with
3,552 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
~~~~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"authors": [ | ||
"keiravillekode" | ||
], | ||
"files": { | ||
"solution": [ | ||
"pangram.s" | ||
], | ||
"test": [ | ||
"pangram_test.c" | ||
], | ||
"example": [ | ||
".meta/example.s" | ||
] | ||
}, | ||
"blurb": "Determine if a sentence is a pangram.", | ||
"source": "Wikipedia", | ||
"source_url": "https://en.wikipedia.org/wiki/Pangram" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.text | ||
.globl is_pangram | ||
|
||
/* extern int is_pangram(const char *sentence); */ | ||
is_pangram: | ||
mov x1, x0 | ||
mov x0, #0 /* bitset of letters */ | ||
mov x2, #1 | ||
|
||
.loop: | ||
ldrb w3, [x1], #1 /* load byte, with post-increment */ | ||
cbz x3, .return | ||
|
||
orr x3, x3, #32 /* force lower-case */ | ||
sub x3, x3, #97 | ||
cmp x3, #26 | ||
bhs .loop /* unsigned >= */ | ||
|
||
lsl x3, x2, x3 /* 1 << (letter - 'a') */ | ||
orr x0, x0, x3 | ||
b .loop | ||
|
||
.return: | ||
add x0, x0, #1 /* 2**26 iff sentence contains all letters */ | ||
lsr x0, x0, #26 | ||
ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
AS = aarch64-linux-gnu-as | ||
CC = aarch64-linux-gnu-gcc | ||
|
||
CFLAGS = -g -Wall -Wextra -pedantic -Werror | ||
LDFLAGS = | ||
|
||
ALL_LDFLAGS = -pie -Wl,--fatal-warnings | ||
|
||
ALL_CFLAGS = -std=c99 -fPIE $(CFLAGS) | ||
ALL_LDFLAGS += $(LDFLAGS) | ||
|
||
C_OBJS = $(patsubst %.c,%.o,$(wildcard *.c)) | ||
AS_OBJS = $(patsubst %.s,%.o,$(wildcard *.s)) | ||
ALL_OBJS = $(filter-out example.o,$(C_OBJS) $(AS_OBJS) vendor/unity.o) | ||
|
||
CC_CMD = $(CC) $(ALL_CFLAGS) -c -o $@ $< | ||
|
||
all: tests | ||
qemu-aarch64 -L /usr/aarch64-linux-gnu ./$< | ||
|
||
tests: $(ALL_OBJS) | ||
@$(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) -o $@ $(ALL_OBJS) | ||
|
||
%.o: %.s | ||
@$(AS) -o $@ $< | ||
|
||
%.o: %.c | ||
@$(CC_CMD) | ||
|
||
vendor/unity.o: vendor/unity.c vendor/unity.h vendor/unity_internals.h | ||
@$(CC_CMD) | ||
|
||
clean: | ||
@rm -f *.o vendor/*.o tests | ||
|
||
.PHONY: all clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.text | ||
.globl is_pangram | ||
|
||
is_pangram: | ||
ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include "vendor/unity.h" | ||
|
||
extern int is_pangram(const char *sentence); | ||
|
||
void setUp(void) { | ||
} | ||
|
||
void tearDown(void) { | ||
} | ||
|
||
void test_empty_sentence(void) { | ||
TEST_ASSERT_FALSE(is_pangram("")); | ||
} | ||
|
||
void test_perfect_lower_case(void) { | ||
TEST_IGNORE(); | ||
TEST_ASSERT_TRUE(is_pangram("abcdefghijklmnopqrstuvwxyz")); | ||
} | ||
|
||
void test_only_lower_case(void) { | ||
TEST_IGNORE(); | ||
TEST_ASSERT_TRUE(is_pangram("the quick brown fox jumps over the lazy dog")); | ||
} | ||
|
||
void test_missing_the_letter_x(void) { | ||
TEST_IGNORE(); | ||
TEST_ASSERT_FALSE(is_pangram("a quick movement of the enemy will jeopardize five gunboats")); | ||
} | ||
|
||
void test_missing_the_letter_h(void) { | ||
TEST_IGNORE(); | ||
TEST_ASSERT_FALSE(is_pangram("five boxing wizards jump quickly at it")); | ||
} | ||
|
||
void test_with_underscores(void) { | ||
TEST_IGNORE(); | ||
TEST_ASSERT_TRUE(is_pangram("the_quick_brown_fox_jumps_over_the_lazy_dog")); | ||
} | ||
|
||
void test_with_numbers(void) { | ||
TEST_IGNORE(); | ||
TEST_ASSERT_TRUE(is_pangram("the 1 quick brown fox jumps over the 2 lazy dogs")); | ||
} | ||
|
||
void test_missing_letters_replaced_by_numbers(void) { | ||
TEST_IGNORE(); | ||
TEST_ASSERT_FALSE(is_pangram("7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog")); | ||
} | ||
|
||
void test_mixed_case_and_punctuation(void) { | ||
TEST_IGNORE(); | ||
TEST_ASSERT_TRUE(is_pangram("\"Five quacking Zephyrs jolt my wax bed.\"")); | ||
} | ||
|
||
void test_am_and_am_are_26_different_characters_but_not_a_pangram(void) { | ||
TEST_IGNORE(); | ||
TEST_ASSERT_FALSE(is_pangram("abcdefghijklm ABCDEFGHIJKLM")); | ||
} | ||
|
||
int main(void) { | ||
UNITY_BEGIN(); | ||
RUN_TEST(test_empty_sentence); | ||
RUN_TEST(test_perfect_lower_case); | ||
RUN_TEST(test_only_lower_case); | ||
RUN_TEST(test_missing_the_letter_x); | ||
RUN_TEST(test_missing_the_letter_h); | ||
RUN_TEST(test_with_underscores); | ||
RUN_TEST(test_with_numbers); | ||
RUN_TEST(test_missing_letters_replaced_by_numbers); | ||
RUN_TEST(test_mixed_case_and_punctuation); | ||
RUN_TEST(test_am_and_am_are_26_different_characters_but_not_a_pangram); | ||
return UNITY_END(); | ||
} |
Oops, something went wrong.