This repository has been archived by the owner on May 30, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
f4527a8
commit 747a087
Showing
8 changed files
with
126 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,17 @@ | ||
# Instructions | ||
|
||
Convert a phrase to its acronym. | ||
|
||
Techies love their TLA (Three Letter Acronyms)! | ||
|
||
Help generate some jargon by writing a program that converts a long name like Portable Network Graphics to its acronym (PNG). | ||
|
||
Punctuation is handled as follows: hyphens are word separators (like whitespace); all other punctuation can be removed from the input. | ||
|
||
For example: | ||
|
||
|Input|Output| | ||
|-|-| | ||
|As Soon As Possible|ASAP| | ||
|Liquid-crystal display|LCD| | ||
|Thank George It's Friday!|TGIF| |
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": [ | ||
"ErikSchierboom" | ||
], | ||
"files": { | ||
"solution": [ | ||
"src/acronym.cljs" | ||
], | ||
"test": [ | ||
"test/acronym_test.cljs" | ||
], | ||
"example": [ | ||
".meta/src/example.cljs" | ||
] | ||
}, | ||
"blurb": "Convert a long phrase to its acronym.", | ||
"source": "Julien Vanier", | ||
"source_url": "https://github.com/monkbroc" | ||
} |
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 @@ | ||
(ns acronym | ||
(:require [clojure.string :as str])) | ||
|
||
(defn acronym [text] | ||
(->> (re-seq #"[A-Z]+[a-z]*|[a-z]+" text) | ||
(map first) | ||
(apply str) | ||
str/upper-case)) |
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,30 @@ | ||
# This is an auto-generated file. Regular comments will be removed when this | ||
# file is regenerated. Regenerating will not touch any manually added keys, | ||
# so comments can be added in a "comment" key. | ||
|
||
[1e22cceb-c5e4-4562-9afe-aef07ad1eaf4] | ||
description = "basic" | ||
|
||
[79ae3889-a5c0-4b01-baf0-232d31180c08] | ||
description = "lowercase words" | ||
|
||
[ec7000a7-3931-4a17-890e-33ca2073a548] | ||
description = "punctuation" | ||
|
||
[32dd261c-0c92-469a-9c5c-b192e94a63b0] | ||
description = "all caps word" | ||
|
||
[ae2ac9fa-a606-4d05-8244-3bcc4659c1d4] | ||
description = "punctuation without whitespace" | ||
|
||
[0e4b1e7c-1a6d-48fb-81a7-bf65eb9e69f9] | ||
description = "very long abbreviation" | ||
|
||
[6a078f49-c68d-4b7b-89af-33a1a98c28cc] | ||
description = "consecutive delimiters" | ||
|
||
[5118b4b1-4572-434c-8d57-5b762e57973e] | ||
description = "apostrophes" | ||
|
||
[adc12eab-ec2d-414f-b48c-66a4fc06cdef] | ||
description = "underscore emphasis" |
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,10 @@ | ||
{:deps | ||
{org.clojure/clojure {:mvn/version "1.10.1"} | ||
org.clojure/clojurescript {:mvn/version "1.10.773"}} | ||
|
||
:aliases | ||
{:test | ||
{:extra-paths ["test"] | ||
:extra-deps | ||
{olical/cljs-test-runner {:mvn/version "3.8.0"}} | ||
:main-opts ["-m" "cljs-test-runner.main"]}}} |
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 @@ | ||
(ns acronym) | ||
|
||
(defn acronym [] ;; <- arglist goes here | ||
;; your code goes here | ||
) |
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,24 @@ | ||
(ns acronym-test | ||
(:require [clojure.test :refer [deftest is]] | ||
acronym)) | ||
|
||
(deftest test-acronym-empty-string | ||
(is (= "" (acronym/acronym "")))) | ||
|
||
(deftest test-acronym-png | ||
(is (= "PNG" (acronym/acronym "Portable Network Graphics")))) | ||
|
||
(deftest test-acronym-ror | ||
(is (= "ROR" (acronym/acronym "Ruby on Rails")))) | ||
|
||
(deftest test-acronym-html | ||
(is (= "HTML" (acronym/acronym "HyperText Markup Language")))) | ||
|
||
(deftest test-acronym-fifo | ||
(is (= "FIFO" (acronym/acronym "First In, First Out")))) | ||
|
||
(deftest test-acronym-php | ||
(is (= "PHP" (acronym/acronym "PHP: Hypertext Preprocessor")))) | ||
|
||
(deftest test-acronym-cmos | ||
(is (= "CMOS" (acronym/acronym "Complementary metal-oxide semiconductor")))) |