Skip to content

Commit 09954ab

Browse files
authored
Merge pull request #29 from exercism/v0.1.79
Refactorings for v0.1.79
2 parents f731bf2 + 69b5183 commit 09954ab

File tree

185 files changed

+772
-382
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

185 files changed

+772
-382
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ defaults:
1212
jobs:
1313
test:
1414
runs-on: ubuntu-latest
15-
container: ingy/exercism-yamlscript-test-runner:0.1.76
15+
container: ingy/exercism-yamlscript-test-runner:0.1.79
1616

1717
steps:
1818
- name: Checkout repository

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ROOT := $(shell pwd)
44

55
BIN := bin
66

7-
YS_VERSION := 0.1.76
7+
YS_VERSION := 0.1.79
88

99
YS_LOCAL := .local
1010
YS_LOCAL_PREFIX := $(YS_LOCAL)/v$(YS_VERSION)

common/gnumakefile.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SHELL := bash
22

33
BASE := $(shell pwd)
44

5-
export YS_VERSION := 0.1.76
5+
export YS_VERSION := 0.1.79
66

77
YS_LOCAL_PREFIX := ../../../.local/v$(YS_VERSION)
88
ifeq (,$(shell [[ -d "$(YS_LOCAL_PREFIX)" ]] && echo ok))

common/meta-makefile.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SHELL := bash
22

33
BASE := $(shell pwd)
44

5-
export YS_VERSION := 0.1.76
5+
export YS_VERSION := 0.1.79
66

77
YS_LOCAL_PREFIX := ../../../../.local/v$(YS_VERSION)
88

config.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@
7676
"prerequisites": [],
7777
"difficulty": 1
7878
},
79+
{
80+
"slug": "resistor-color-duo",
81+
"name": "Resistor Color Duo",
82+
"uuid": "8a49347f-461f-415c-b203-bb491ac98fac",
83+
"practices": [],
84+
"prerequisites": [],
85+
"difficulty": 1
86+
},
7987
{
8088
"slug": "reverse-string",
8189
"name": "Reverse String",

config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ exercises:
7878
prerequisites: []
7979
difficulty: 1
8080

81+
- slug: resistor-color-duo
82+
name: Resistor Color Duo
83+
uuid: 8a49347f-461f-415c-b203-bb491ac98fac
84+
practices: []
85+
prerequisites: []
86+
difficulty: 1
87+
8188
- slug: reverse-string
8289
name: Reverse String
8390
uuid: 89681570-5734-4f20-b68f-de8b176accdc

exercises/practice/acronym/.meta/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SHELL := bash
22

33
BASE := $(shell pwd)
44

5-
export YS_VERSION := 0.1.76
5+
export YS_VERSION := 0.1.79
66

77
YS_LOCAL_PREFIX := ../../../../.local/v$(YS_VERSION)
88

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
!yamlscript/v0
22

33
defn abbreviate(phrase):
4-
uc(phrase).re-seq(/[A-Z']+/).map(first).str(*)
4+
uc(phrase):
5+
.re-seq(/[A-Z']+/)
6+
.map(first):join

exercises/practice/acronym/GNUmakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SHELL := bash
22

33
BASE := $(shell pwd)
44

5-
export YS_VERSION := 0.1.76
5+
export YS_VERSION := 0.1.79
66

77
YS_LOCAL_PREFIX := ../../../.local/v$(YS_VERSION)
88
ifeq (,$(shell [[ -d "$(YS_LOCAL_PREFIX)" ]] && echo ok))

exercises/practice/all-your-base/.meta/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SHELL := bash
22

33
BASE := $(shell pwd)
44

5-
export YS_VERSION := 0.1.76
5+
export YS_VERSION := 0.1.79
66

77
YS_LOCAL_PREFIX := ../../../../.local/v$(YS_VERSION)
88

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
!yamlscript/v0
22

33
defn rebase(input-base digits output-base):
4-
:: Converts a sequence of digits given in input-base into a sequence of
5-
digits in the desired output-base.
4+
:: Converts a sequence of digits given in input-base
5+
into a sequence of digits in the desired output-base.
66

77
cond:
8-
input-base < 2: die('input base must be >= 2')
8+
input-base < 2: die('input base must be >= 2')
99
output-base < 2: die('output base must be >= 2')
10-
digits.some(neg?) || digits.some(\(_ >= input-base)):
10+
digits.some(neg?) || digits.some(ge(input-base)):
1111
die: 'all digits must satisfy 0 <= d < input base'
1212

13-
digits.every?(zero?) || digits.! :: [0]
13+
digits.every?(zero?) || count(digits).eq(0) :: [0]
1414

1515
else: digits
1616
.digits-to-decimal(input-base)
1717
.decimal-to-digits(output-base)
1818

1919
defn digits-to-decimal(digits input-base):
20-
reduce \((%1 * input-base) + %2): 0 digits
20+
reduce \(%2 + (%1 * input-base)): digits
2121

2222
defn decimal-to-digits(number output-base):
2323
loop digits nil, num number:
2424
if num > 0:
2525
recur:
26-
conj: digits (num % output-base)
26+
conj digits: num % output-base
2727
quot: num output-base
2828
else: digits

exercises/practice/all-your-base/GNUmakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SHELL := bash
22

33
BASE := $(shell pwd)
44

5-
export YS_VERSION := 0.1.76
5+
export YS_VERSION := 0.1.79
66

77
YS_LOCAL_PREFIX := ../../../.local/v$(YS_VERSION)
88
ifeq (,$(shell [[ -d "$(YS_LOCAL_PREFIX)" ]] && echo ok))

exercises/practice/allergies/.meta/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SHELL := bash
22

33
BASE := $(shell pwd)
44

5-
export YS_VERSION := 0.1.76
5+
export YS_VERSION := 0.1.79
66

77
YS_LOCAL_PREFIX := ../../../../.local/v$(YS_VERSION)
88

exercises/practice/allergies/GNUmakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SHELL := bash
22

33
BASE := $(shell pwd)
44

5-
export YS_VERSION := 0.1.76
5+
export YS_VERSION := 0.1.79
66

77
YS_LOCAL_PREFIX := ../../../.local/v$(YS_VERSION)
88
ifeq (,$(shell [[ -d "$(YS_LOCAL_PREFIX)" ]] && echo ok))

exercises/practice/allergies/allergies.ys

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,5 @@
11
!yamlscript/v0
22

3-
defn allergic-to(item score):
4-
# Implement the 'allergic-to' function.
5-
6-
defn allergic-to(item score):
7-
# Implement the 'allergic-to' function.
8-
9-
defn allergic-to(item score):
10-
# Implement the 'allergic-to' function.
11-
12-
defn allergic-to(item score):
13-
# Implement the 'allergic-to' function.
14-
15-
defn allergic-to(item score):
16-
# Implement the 'allergic-to' function.
17-
18-
defn allergic-to(item score):
19-
# Implement the 'allergic-to' function.
20-
21-
defn allergic-to(item score):
22-
# Implement the 'allergic-to' function.
23-
243
defn allergic-to(item score):
254
# Implement the 'allergic-to' function.
265

exercises/practice/anagram/.meta/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SHELL := bash
22

33
BASE := $(shell pwd)
44

5-
export YS_VERSION := 0.1.76
5+
export YS_VERSION := 0.1.79
66

77
YS_LOCAL_PREFIX := ../../../../.local/v$(YS_VERSION)
88

exercises/practice/anagram/.meta/anagram.ys

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
defn find-anagrams(subject candidates):
44
filter _ candidates:
55
partial _ subject:
6-
fn(*):
7-
-[word1 word2] =: _.map(lc)
8-
word1 != word2 &&: sort(word1) == sort(word2)
6+
fn(*words):
7+
word1 word2 =: words.map(lc)
8+
word1 != word2 &&:
9+
sort(word1) == sort(word2)

exercises/practice/anagram/GNUmakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SHELL := bash
22

33
BASE := $(shell pwd)
44

5-
export YS_VERSION := 0.1.76
5+
export YS_VERSION := 0.1.79
66

77
YS_LOCAL_PREFIX := ../../../.local/v$(YS_VERSION)
88
ifeq (,$(shell [[ -d "$(YS_LOCAL_PREFIX)" ]] && echo ok))

exercises/practice/armstrong-numbers/.meta/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SHELL := bash
22

33
BASE := $(shell pwd)
44

5-
export YS_VERSION := 0.1.76
5+
export YS_VERSION := 0.1.79
66

77
YS_LOCAL_PREFIX := ../../../../.local/v$(YS_VERSION)
88

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
!yamlscript/v0
22

33
defn is-armstrong-number(number):
4-
number ==: map(\(_ ** str(number).#) digits(number)).sum()
4+
ds =: digits(number)
5+
number ==: ds.map(\(_ ** ds.#)):sum

exercises/practice/armstrong-numbers/GNUmakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SHELL := bash
22

33
BASE := $(shell pwd)
44

5-
export YS_VERSION := 0.1.76
5+
export YS_VERSION := 0.1.79
66

77
YS_LOCAL_PREFIX := ../../../.local/v$(YS_VERSION)
88
ifeq (,$(shell [[ -d "$(YS_LOCAL_PREFIX)" ]] && echo ok))

exercises/practice/atbash-cipher/.meta/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SHELL := bash
22

33
BASE := $(shell pwd)
44

5-
export YS_VERSION := 0.1.76
5+
export YS_VERSION := 0.1.79
66

77
YS_LOCAL_PREFIX := ../../../../.local/v$(YS_VERSION)
88

exercises/practice/atbash-cipher/.meta/atbash-cipher.ys

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ dict =:
44
zipmap (\\a .. \\z): \\z .. \\a
55

66
defn encode(phrase):
7-
lc(phrase).replace(/[^a-z0-9]/ '').str/escape(dict)
8-
.partition(5 5 '').map(join).join(' ')
7+
lc(phrase):
8+
.replace(/[^a-z0-9]/).escape(dict)
9+
.partition(5 5 '').map(join):joins
910

1011
defn decode(phrase):
11-
phrase.replace(' ' '').str/escape(dict)
12+
phrase.replace(' ').escape(dict)

exercises/practice/atbash-cipher/GNUmakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SHELL := bash
22

33
BASE := $(shell pwd)
44

5-
export YS_VERSION := 0.1.76
5+
export YS_VERSION := 0.1.79
66

77
YS_LOCAL_PREFIX := ../../../.local/v$(YS_VERSION)
88
ifeq (,$(shell [[ -d "$(YS_LOCAL_PREFIX)" ]] && echo ok))

exercises/practice/bank-account/.meta/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SHELL := bash
22

33
BASE := $(shell pwd)
44

5-
export YS_VERSION := 0.1.76
5+
export YS_VERSION := 0.1.79
66

77
YS_LOCAL_PREFIX := ../../../../.local/v$(YS_VERSION)
88

exercises/practice/bank-account/.meta/bank-account.ys

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ defn- do-balance(op):
3232
defn- do-deposit(op):
3333
when-not deref(account):
3434
die: 'account not open'
35-
swap! account +: op.get-amount()
35+
swap! account +: op:get-amount
3636

3737
defn- do-withdraw(op):
3838
balance =: deref(account)
3939
when-not balance:
4040
die: 'account not open'
41-
amount =: op.get-amount()
41+
amount =: op:get-amount
4242
when amount > balance:
4343
die: 'amount must be less than balance'
4444
swap! account -: amount
4545

4646
defn- get-amount(op):
4747
amount =: op.amount
48-
if amount <= 0:
48+
if amount < 0:
4949
die: 'amount must be greater than 0'
5050
else: amount

exercises/practice/bank-account/GNUmakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SHELL := bash
22

33
BASE := $(shell pwd)
44

5-
export YS_VERSION := 0.1.76
5+
export YS_VERSION := 0.1.79
66

77
YS_LOCAL_PREFIX := ../../../.local/v$(YS_VERSION)
88
ifeq (,$(shell [[ -d "$(YS_LOCAL_PREFIX)" ]] && echo ok))

exercises/practice/binary-search/.meta/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SHELL := bash
22

33
BASE := $(shell pwd)
44

5-
export YS_VERSION := 0.1.76
5+
export YS_VERSION := 0.1.79
66

77
YS_LOCAL_PREFIX := ../../../../.local/v$(YS_VERSION)
88

exercises/practice/binary-search/.meta/binary-search.ys

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
!yamlscript/v0
22

33
defn find(array value):
4-
loop low 0, high array.#--:
4+
loop low 0, high array.--:
55
when low > high:
66
die: 'value not in array'
7-
mid =: quot((high + low) 2)
7+
mid =: (high + low).quot(2)
88
item =: array.$mid
9+
910
cond:
1011
value == item : mid
1112
value < item : recur(low mid.--)

exercises/practice/binary-search/GNUmakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SHELL := bash
22

33
BASE := $(shell pwd)
44

5-
export YS_VERSION := 0.1.76
5+
export YS_VERSION := 0.1.79
66

77
YS_LOCAL_PREFIX := ../../../.local/v$(YS_VERSION)
88
ifeq (,$(shell [[ -d "$(YS_LOCAL_PREFIX)" ]] && echo ok))

exercises/practice/bob/.meta/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SHELL := bash
22

33
BASE := $(shell pwd)
44

5-
export YS_VERSION := 0.1.76
5+
export YS_VERSION := 0.1.79
66

77
YS_LOCAL_PREFIX := ../../../../.local/v$(YS_VERSION)
88

exercises/practice/bob/.meta/bob.ys

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
!yamlscript/v0
22

33
defn response(hey-bob):
4-
condp re-matches hey-bob.trim():
4+
condp re-matches hey-bob:trim:
55
/\s*/ : 'Fine. Be that way!'
66
/[^a-zA-Z]+\?/ : 'Sure.'
77
/[^a-z]+\?/ : "Calm down, I know what I'm doing!"

exercises/practice/bob/GNUmakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SHELL := bash
22

33
BASE := $(shell pwd)
44

5-
export YS_VERSION := 0.1.76
5+
export YS_VERSION := 0.1.79
66

77
YS_LOCAL_PREFIX := ../../../.local/v$(YS_VERSION)
88
ifeq (,$(shell [[ -d "$(YS_LOCAL_PREFIX)" ]] && echo ok))

exercises/practice/bottle-song/.meta/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SHELL := bash
22

33
BASE := $(shell pwd)
44

5-
export YS_VERSION := 0.1.76
5+
export YS_VERSION := 0.1.79
66

77
YS_LOCAL_PREFIX := ../../../../.local/v$(YS_VERSION)
88

0 commit comments

Comments
 (0)