-
-
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
a288c97
commit 9648119
Showing
13 changed files
with
3,580 additions
and
1 deletion.
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,14 @@ | ||
# Instructions | ||
|
||
Determine if a word or phrase is an isogram. | ||
|
||
An isogram (also known as a "non-pattern 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. |
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": [ | ||
"isogram.s" | ||
], | ||
"test": [ | ||
"isogram_test.c" | ||
], | ||
"example": [ | ||
".meta/example.s" | ||
] | ||
}, | ||
"blurb": "Determine if a word or phrase is an isogram.", | ||
"source": "Wikipedia", | ||
"source_url": "https://en.wikipedia.org/wiki/Isogram" | ||
} |
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,32 @@ | ||
.text | ||
.globl is_isogram | ||
|
||
/* extern int is_isogram(const char *phrase); */ | ||
is_isogram: | ||
mov x1, x0 | ||
mov x0, #0 /* bitset of letters */ | ||
mov x2, #1 | ||
|
||
.loop: | ||
ldrb w3, [x1], #1 /* load byte, with post-increment */ | ||
cbz x3, .accept | ||
|
||
orr x3, x3, #32 /* force lower-case */ | ||
sub x3, x3, #97 | ||
cmp x3, #26 | ||
bhs .loop /* unsigned >= */ | ||
|
||
lsl x3, x2, x3 /* 1 << (letter - 'a') */ | ||
tst x0, x3 | ||
bne .reject | ||
|
||
orr x0, x0, x3 | ||
b .loop | ||
|
||
.accept: | ||
mov x0, #1 | ||
ret | ||
|
||
.reject: | ||
mov x0, #0 | ||
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,52 @@ | ||
# 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. | ||
|
||
[a0e97d2d-669e-47c7-8134-518a1e2c4555] | ||
description = "empty string" | ||
|
||
[9a001b50-f194-4143-bc29-2af5ec1ef652] | ||
description = "isogram with only lower case characters" | ||
|
||
[8ddb0ca3-276e-4f8b-89da-d95d5bae78a4] | ||
description = "word with one duplicated character" | ||
|
||
[6450b333-cbc2-4b24-a723-0b459b34fe18] | ||
description = "word with one duplicated character from the end of the alphabet" | ||
|
||
[a15ff557-dd04-4764-99e7-02cc1a385863] | ||
description = "longest reported english isogram" | ||
|
||
[f1a7f6c7-a42f-4915-91d7-35b2ea11c92e] | ||
description = "word with duplicated character in mixed case" | ||
|
||
[14a4f3c1-3b47-4695-b645-53d328298942] | ||
description = "word with duplicated character in mixed case, lowercase first" | ||
|
||
[423b850c-7090-4a8a-b057-97f1cadd7c42] | ||
description = "hypothetical isogrammic word with hyphen" | ||
|
||
[93dbeaa0-3c5a-45c2-8b25-428b8eacd4f2] | ||
description = "hypothetical word with duplicated character following hyphen" | ||
|
||
[36b30e5c-173f-49c6-a515-93a3e825553f] | ||
description = "isogram with duplicated hyphen" | ||
|
||
[cdabafa0-c9f4-4c1f-b142-689c6ee17d93] | ||
description = "made-up name that is an isogram" | ||
|
||
[5fc61048-d74e-48fd-bc34-abfc21552d4d] | ||
description = "duplicated character in the middle" | ||
|
||
[310ac53d-8932-47bc-bbb4-b2b94f25a83e] | ||
description = "same first and last characters" | ||
|
||
[0d0b8644-0a1e-4a31-a432-2b3ee270d847] | ||
description = "word with duplicated character and with two hyphens" |
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_isogram | ||
|
||
is_isogram: | ||
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,97 @@ | ||
#include "vendor/unity.h" | ||
|
||
extern int is_isogram(const char *phrase); | ||
|
||
void setUp(void) { | ||
} | ||
|
||
void tearDown(void) { | ||
} | ||
|
||
void test_empty_string(void) { | ||
TEST_ASSERT_TRUE(is_isogram("")); | ||
} | ||
|
||
void test_isogram_with_only_lower_case_characters(void) { | ||
TEST_IGNORE(); | ||
TEST_ASSERT_TRUE(is_isogram("isogram")); | ||
} | ||
|
||
void test_word_with_one_duplicated_character(void) { | ||
TEST_IGNORE(); | ||
TEST_ASSERT_FALSE(is_isogram("eleven")); | ||
} | ||
|
||
void test_word_with_one_duplicated_character_from_the_end_of_the_alphabet(void) { | ||
TEST_IGNORE(); | ||
TEST_ASSERT_FALSE(is_isogram("zzyzx")); | ||
} | ||
|
||
void test_longest_reported_english_isogram(void) { | ||
TEST_IGNORE(); | ||
TEST_ASSERT_TRUE(is_isogram("subdermatoglyphic")); | ||
} | ||
|
||
void test_word_with_duplicated_character_in_mixed_case(void) { | ||
TEST_IGNORE(); | ||
TEST_ASSERT_FALSE(is_isogram("Alphabet")); | ||
} | ||
|
||
void test_word_with_duplicated_character_in_mixed_case_lowercase_first(void) { | ||
TEST_IGNORE(); | ||
TEST_ASSERT_FALSE(is_isogram("alphAbet")); | ||
} | ||
|
||
void test_hypothetical_isogrammic_word_with_hyphen(void) { | ||
TEST_IGNORE(); | ||
TEST_ASSERT_TRUE(is_isogram("thumbscrew-japingly")); | ||
} | ||
|
||
void test_hypothetical_word_with_duplicated_character_following_hyphen(void) { | ||
TEST_IGNORE(); | ||
TEST_ASSERT_FALSE(is_isogram("thumbscrew-jappingly")); | ||
} | ||
|
||
void test_isogram_with_duplicated_hyphen(void) { | ||
TEST_IGNORE(); | ||
TEST_ASSERT_TRUE(is_isogram("six-year-old")); | ||
} | ||
|
||
void test_madeup_name_that_is_an_isogram(void) { | ||
TEST_IGNORE(); | ||
TEST_ASSERT_TRUE(is_isogram("Emily Jung Schwartzkopf")); | ||
} | ||
|
||
void test_duplicated_character_in_the_middle(void) { | ||
TEST_IGNORE(); | ||
TEST_ASSERT_FALSE(is_isogram("accentor")); | ||
} | ||
|
||
void test_same_first_and_last_characters(void) { | ||
TEST_IGNORE(); | ||
TEST_ASSERT_FALSE(is_isogram("angola")); | ||
} | ||
|
||
void test_word_with_duplicated_character_and_with_two_hyphens(void) { | ||
TEST_IGNORE(); | ||
TEST_ASSERT_FALSE(is_isogram("up-to-date")); | ||
} | ||
|
||
int main(void) { | ||
UNITY_BEGIN(); | ||
RUN_TEST(test_empty_string); | ||
RUN_TEST(test_isogram_with_only_lower_case_characters); | ||
RUN_TEST(test_word_with_one_duplicated_character); | ||
RUN_TEST(test_word_with_one_duplicated_character_from_the_end_of_the_alphabet); | ||
RUN_TEST(test_longest_reported_english_isogram); | ||
RUN_TEST(test_word_with_duplicated_character_in_mixed_case); | ||
RUN_TEST(test_word_with_duplicated_character_in_mixed_case_lowercase_first); | ||
RUN_TEST(test_hypothetical_isogrammic_word_with_hyphen); | ||
RUN_TEST(test_hypothetical_word_with_duplicated_character_following_hyphen); | ||
RUN_TEST(test_isogram_with_duplicated_hyphen); | ||
RUN_TEST(test_madeup_name_that_is_an_isogram); | ||
RUN_TEST(test_duplicated_character_in_the_middle); | ||
RUN_TEST(test_same_first_and_last_characters); | ||
RUN_TEST(test_word_with_duplicated_character_and_with_two_hyphens); | ||
return UNITY_END(); | ||
} |
Oops, something went wrong.