summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjetil Orbekk <kj@orbekk.com>2021-11-21 16:35:18 -0500
committerKjetil Orbekk <kj@orbekk.com>2021-11-21 16:35:18 -0500
commit64791ecab78a00cde43e1ed788dc68b8c4cbba8e (patch)
tree86dc26355dccfb8106656285c5e99a6d7aadd40b
parentb2ea7ebefce50179f51913aae736670658190db6 (diff)
hamming skeleton
-rw-r--r--exercism/emacs-lisp/hamming/.exercism/config.json24
-rw-r--r--exercism/emacs-lisp/hamming/.exercism/metadata.json1
-rw-r--r--exercism/emacs-lisp/hamming/HELP.md41
-rw-r--r--exercism/emacs-lisp/hamming/README.md43
-rw-r--r--exercism/emacs-lisp/hamming/hamming-test.el55
-rw-r--r--exercism/emacs-lisp/hamming/hamming.el9
6 files changed, 173 insertions, 0 deletions
diff --git a/exercism/emacs-lisp/hamming/.exercism/config.json b/exercism/emacs-lisp/hamming/.exercism/config.json
new file mode 100644
index 0000000..e9e8fec
--- /dev/null
+++ b/exercism/emacs-lisp/hamming/.exercism/config.json
@@ -0,0 +1,24 @@
+{
+ "blurb": "Calculate the Hamming difference between two DNA strands.",
+ "authors": [
+ "PurityControl"
+ ],
+ "contributors": [
+ "benreyn",
+ "vermiculus",
+ "yurrriq"
+ ],
+ "files": {
+ "solution": [
+ "hamming.el"
+ ],
+ "test": [
+ "hamming-test.el"
+ ],
+ "example": [
+ ".meta/example.el"
+ ]
+ },
+ "source": "The Calculating Point Mutations problem at Rosalind",
+ "source_url": "http://rosalind.info/problems/hamm/"
+}
diff --git a/exercism/emacs-lisp/hamming/.exercism/metadata.json b/exercism/emacs-lisp/hamming/.exercism/metadata.json
new file mode 100644
index 0000000..d09f163
--- /dev/null
+++ b/exercism/emacs-lisp/hamming/.exercism/metadata.json
@@ -0,0 +1 @@
+{"track":"emacs-lisp","exercise":"hamming","id":"624eaf66e39045fa9a3d06fe33a02193","url":"https://exercism.org/tracks/emacs-lisp/exercises/hamming","handle":"orbekk","is_requester":true,"auto_approve":false} \ No newline at end of file
diff --git a/exercism/emacs-lisp/hamming/HELP.md b/exercism/emacs-lisp/hamming/HELP.md
new file mode 100644
index 0000000..3e407e9
--- /dev/null
+++ b/exercism/emacs-lisp/hamming/HELP.md
@@ -0,0 +1,41 @@
+# Help
+
+## Running the tests
+
+Tests can be run several ways:
+
+1. Interactively and individually, with `M-x ert RET test-name RET`
+2. Interactively and all at once, with `M-x ert RET t RET`
+3. From the terminal, in batch mode, with `emacs -batch -l ert -l my-test.el -f ert-run-tests-batch-and-exit`
+4. Other options can be found in the docs, `C-h i m ert RET`
+
+## Submitting your solution
+
+You can submit your solution using the `exercism submit hamming.el` command.
+This command will upload your solution to the Exercism website and print the solution page's URL.
+
+It's possible to submit an incomplete solution which allows you to:
+
+- See how others have completed the exercise
+- Request help from a mentor
+
+## Need to get help?
+
+If you'd like help solving the exercise, check the following pages:
+
+- The [Emacs Lisp track's documentation](https://exercism.org/docs/tracks/emacs-lisp)
+- [Exercism's support channel on gitter](https://gitter.im/exercism/support)
+- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs)
+
+Should those resources not suffice, you could submit your (incomplete) solution to request mentoring.
+
+To get help if you're having trouble, you can use one of the following resources:
+
+- [The Emacs Wiki](http://emacswiki.org/) is invaluable. Spend lots of time here.
+- [The Emacs Editor](http://www.gnu.org/software/emacs/manual/html_node/emacs/index.html) is the official manual for GNU Emacs.
+- IRC - there are [freenode](https://freenode.net/) channels for `#emacs`, `#prelude`, and many Emacs
+ packages, and many helpful folks around. And with emacs, IRC is as close as
+ `M-x erc`.
+- [Exercism Support](https://gitter.im/exercism/support) Gitter chat is also a good place to get help from the
+ exercism community.
+- [StackOverflow](http://stackoverflow.com/questions/tagged/elisp) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions. \ No newline at end of file
diff --git a/exercism/emacs-lisp/hamming/README.md b/exercism/emacs-lisp/hamming/README.md
new file mode 100644
index 0000000..d99ed82
--- /dev/null
+++ b/exercism/emacs-lisp/hamming/README.md
@@ -0,0 +1,43 @@
+# Hamming
+
+Welcome to Hamming on Exercism's Emacs Lisp Track.
+If you need help running the tests or submitting your code, check out `HELP.md`.
+
+## Instructions
+
+Calculate the Hamming Distance between two DNA strands.
+
+Your body is made up of cells that contain DNA. Those cells regularly wear out and need replacing, which they achieve by dividing into daughter cells. In fact, the average human body experiences about 10 quadrillion cell divisions in a lifetime!
+
+When cells divide, their DNA replicates too. Sometimes during this process mistakes happen and single pieces of DNA get encoded with the incorrect information. If we compare two strands of DNA and count the differences between them we can see how many mistakes occurred. This is known as the "Hamming Distance".
+
+We read DNA using the letters C,A,G and T. Two strands might look like this:
+
+ GAGCCTACTAACGGGAT
+ CATCGTAATGACGGCCT
+ ^ ^ ^ ^ ^ ^^
+
+They have 7 differences, and therefore the Hamming Distance is 7.
+
+The Hamming Distance is useful for lots of things in science, not just biology, so it's a nice phrase to be familiar with :)
+
+The Hamming distance is only defined for sequences of equal length, so
+an attempt to calculate it between sequences of different lengths should
+not work. The general handling of this situation (e.g., raising an
+exception vs returning a special value) may differ between languages.
+
+## Source
+
+### Created by
+
+- @PurityControl
+
+### Contributed to by
+
+- @benreyn
+- @vermiculus
+- @yurrriq
+
+### Based on
+
+The Calculating Point Mutations problem at Rosalind - http://rosalind.info/problems/hamm/ \ No newline at end of file
diff --git a/exercism/emacs-lisp/hamming/hamming-test.el b/exercism/emacs-lisp/hamming/hamming-test.el
new file mode 100644
index 0000000..fb9be46
--- /dev/null
+++ b/exercism/emacs-lisp/hamming/hamming-test.el
@@ -0,0 +1,55 @@
+;;; hamming-test.el --- Tests for hamming (exercism)
+
+;;; Commentary:
+;; Common test data version: 2.0.1 f79dfd7
+
+;;; Code:
+
+(load-file "hamming.el")
+
+(declare-function hamming-distance "hamming.el")
+
+(ert-deftest empty-strands ()
+ (should (= 0 (hamming-distance "" ""))))
+
+(ert-deftest identical-strands ()
+ (should (= 0 (hamming-distance "A" "A"))))
+
+(ert-deftest long-identical-strands ()
+ (should (= 0 (hamming-distance "GGACTGA" "GGACTGA"))))
+
+(ert-deftest complete-distance-in-single-nucleotide-strands ()
+ (should (= 1 (hamming-distance "A" "G"))))
+
+(ert-deftest complete-distance-in-small-strands ()
+ (should (= 2 (hamming-distance "AG" "CT"))))
+
+(ert-deftest small-distance-in-small-strands ()
+ (should (= 1 (hamming-distance "AT" "CT"))))
+
+(ert-deftest small-distance ()
+ (should (= 1 (hamming-distance "GGACG" "GGTCG"))))
+
+(ert-deftest small-distance-in-long-strands ()
+ (should (= 2 (hamming-distance "ACCAGGG" "ACTATGG"))))
+
+(ert-deftest non-unique-character-in-first-strand ()
+ (should (= 1 (hamming-distance "AAA" "AAG"))))
+
+(ert-deftest same-nucleotides-in-different-positions ()
+ (should (= 2 (hamming-distance "TAG" "GAT"))))
+
+(ert-deftest large-distance ()
+ (should (= 4 (hamming-distance "GATACA" "GCATAA"))))
+
+(ert-deftest large-distance-in-off-by-one-strand ()
+ (should (= 9 (hamming-distance "GGACGGATTCTG" "AGGACGGATTCT"))))
+
+(ert-deftest disallow-first-strand-longer ()
+ (should-error (hamming-distance "AATG" "AAA")))
+
+(ert-deftest disallow-second-strand-longer ()
+ (should-error (hamming-distance "ATA" "AGTG")))
+
+(provide 'hamming-test)
+;;; hamming-test.el ends here
diff --git a/exercism/emacs-lisp/hamming/hamming.el b/exercism/emacs-lisp/hamming/hamming.el
new file mode 100644
index 0000000..1ef5eeb
--- /dev/null
+++ b/exercism/emacs-lisp/hamming/hamming.el
@@ -0,0 +1,9 @@
+;;; hamming.el --- Hamming (exercism)
+
+;;; Commentary:
+
+;;; Code:
+
+
+(provide 'hamming)
+;;; hamming.el ends here