Skip to content

Commit

Permalink
WIP updating binary
Browse files Browse the repository at this point in the history
  • Loading branch information
BNAndras committed Jun 23, 2024
1 parent f91c2dd commit 5ae469f
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 46 deletions.
2 changes: 1 addition & 1 deletion exercises/practice/binary/.meta/example.lfe
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defmodule binary-string
(defmodule binary
(export (to-decimal 1)))

(defun to-decimal (string)
Expand Down
21 changes: 0 additions & 21 deletions exercises/practice/binary/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,3 @@ description = "binary 11010 is decimal 26"

[1c6822a4-8584-438b-8dd4-40f0f0b66371]
description = "binary 10001101000 is decimal 1128"

[91ffe632-8374-4016-b1d1-d8400d9f940d]
description = "binary ignores leading zeros"

[44f7d8b1-ddc3-4751-8be3-700a538b421c]
description = "2 is not a valid binary digit"

[c263a24d-6870-420f-b783-628feefd7b6e]
description = "a number containing a non-binary digit is invalid"

[8d81305b-0502-4a07-bfba-051c5526d7f2]
description = "a number with trailing non-binary characters is invalid"

[a7f79b6b-039a-4d42-99b4-fcee56679f03]
description = "a number with leading non-binary characters is invalid"

[9e0ece9d-b8aa-46a0-a22b-3bed2e3f741e]
description = "a number with internal non-binary characters is invalid"

[46c8dd65-0c32-4273-bb0d-f2b111bccfbd]
description = "a number and a word whitespace separated is invalid"
Empty file.
4 changes: 4 additions & 0 deletions exercises/practice/binary/src/binary.lfe
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(defmodule binary
(export (to-decimal 1)))

; please implement the to-decimal function
24 changes: 0 additions & 24 deletions exercises/practice/binary/test/binary-string-tests.lfe

This file was deleted.

29 changes: 29 additions & 0 deletions exercises/practice/binary/test/binary-tests.lfe
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
(defmodule binary-tests
(behaviour ltest-unit)
(export all))

(include-lib "ltest/include/ltest-macros.lfe")

(deftest binary-0-is-decimal-0
(is-equal 0 (binary:to-decimal "0")))

(deftest binary-1-is-decimal-1
(is-equal 1 (binary:to-decimal "1")))

(deftest binary-10-is-decimal-2
(is-equal 2 (binary:to-decimal "10")))

(deftest binary-11-is-decimal-3
(is-equal 3 (binary:to-decimal "11")))

(deftest binary-100-is-decimal-4
(is-equal 4 (binary:to-decimal "100")))

(deftest binary-1001-is-decimal-9
(is-equal 9 (binary:to-decimal "1001")))

(deftest binary-11010-is-decimal-26
(is-equal 26 (binary:to-decimal "11010")))

(deftest binary-10001101000-is-decimal-1128
(is-equal 1128 (binary:to-decimal "10001101000")))

0 comments on commit 5ae469f

Please sign in to comment.