Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
af8b486
[Sync Iteration] yamlscript/acronym/1
exercism-solutions-syncer[bot] Apr 23, 2026
74046dd
[Sync Iteration] yamlscript/allergies/1
exercism-solutions-syncer[bot] Apr 23, 2026
dec231e
[Sync Iteration] yamlscript/all-your-base/1
exercism-solutions-syncer[bot] Apr 23, 2026
6844c35
[Sync Iteration] yamlscript/anagram/1
exercism-solutions-syncer[bot] Apr 23, 2026
56b6dec
[Sync Iteration] yamlscript/atbash-cipher/1
exercism-solutions-syncer[bot] Apr 23, 2026
ccb6411
[Sync Iteration] yamlscript/bank-account/1
exercism-solutions-syncer[bot] Apr 23, 2026
9c23956
[Sync Iteration] yamlscript/binary-search/1
exercism-solutions-syncer[bot] Apr 23, 2026
c807447
[Sync Iteration] yamlscript/bob/1
exercism-solutions-syncer[bot] Apr 23, 2026
164fd12
[Sync Iteration] yamlscript/bottle-song/1
exercism-solutions-syncer[bot] Apr 23, 2026
740b029
[Sync Iteration] yamlscript/darts/1
exercism-solutions-syncer[bot] Apr 23, 2026
e72cd77
[Sync Iteration] yamlscript/difference-of-squares/1
exercism-solutions-syncer[bot] Apr 23, 2026
8603141
[Sync Iteration] yamlscript/etl/1
exercism-solutions-syncer[bot] Apr 23, 2026
b3d9031
[Sync Iteration] yamlscript/hamming/1
exercism-solutions-syncer[bot] Apr 23, 2026
2fee2a1
[Sync Iteration] yamlscript/hello-world/1
exercism-solutions-syncer[bot] Apr 23, 2026
6e4b7e2
[Sync Iteration] yamlscript/isogram/1
exercism-solutions-syncer[bot] Apr 23, 2026
db1f9af
[Sync Iteration] yamlscript/largest-series-product/1
exercism-solutions-syncer[bot] Apr 23, 2026
c4d9fe5
[Sync Iteration] yamlscript/leap/1
exercism-solutions-syncer[bot] Apr 23, 2026
c509316
[Sync Iteration] yamlscript/luhn/1
exercism-solutions-syncer[bot] Apr 23, 2026
240efa6
[Sync Iteration] yamlscript/matching-brackets/1
exercism-solutions-syncer[bot] Apr 23, 2026
7a31698
[Sync Iteration] yamlscript/minesweeper/1
exercism-solutions-syncer[bot] Apr 23, 2026
6126131
[Sync Iteration] yamlscript/nth-prime/1
exercism-solutions-syncer[bot] Apr 23, 2026
fa28c64
[Sync Iteration] yamlscript/nucleotide-count/1
exercism-solutions-syncer[bot] Apr 23, 2026
2b4ed6c
[Sync Iteration] yamlscript/pangram/1
exercism-solutions-syncer[bot] Apr 23, 2026
39a5c8f
[Sync Iteration] yamlscript/perfect-numbers/1
exercism-solutions-syncer[bot] Apr 23, 2026
0ace890
[Sync Iteration] yamlscript/phone-number/1
exercism-solutions-syncer[bot] Apr 23, 2026
b4ddd19
[Sync Iteration] yamlscript/protein-translation/1
exercism-solutions-syncer[bot] Apr 23, 2026
3fa437f
[Sync Iteration] yamlscript/queen-attack/1
exercism-solutions-syncer[bot] Apr 23, 2026
7b22e36
[Sync Iteration] yamlscript/raindrops/1
exercism-solutions-syncer[bot] Apr 23, 2026
2123622
[Sync Iteration] yamlscript/reverse-string/1
exercism-solutions-syncer[bot] Apr 23, 2026
5d793e3
[Sync Iteration] yamlscript/robot-simulator/1
exercism-solutions-syncer[bot] Apr 23, 2026
a3bcefd
[Sync Iteration] yamlscript/roman-numerals/1
exercism-solutions-syncer[bot] Apr 23, 2026
d03d5b0
[Sync Iteration] yamlscript/rotational-cipher/1
exercism-solutions-syncer[bot] Apr 23, 2026
ef2c6e0
[Sync Iteration] yamlscript/rna-transcription/1
exercism-solutions-syncer[bot] Apr 23, 2026
5e15e7c
[Sync Iteration] yamlscript/run-length-encoding/1
exercism-solutions-syncer[bot] Apr 23, 2026
c3e40ad
[Sync Iteration] yamlscript/scrabble-score/1
exercism-solutions-syncer[bot] Apr 23, 2026
01d100a
[Sync Iteration] yamlscript/secret-handshake/1
exercism-solutions-syncer[bot] Apr 23, 2026
aaf8145
[Sync Iteration] yamlscript/space-age/1
exercism-solutions-syncer[bot] Apr 23, 2026
181027d
[Sync Iteration] yamlscript/sum-of-multiples/1
exercism-solutions-syncer[bot] Apr 23, 2026
e514bf1
[Sync Iteration] yamlscript/triangle/1
exercism-solutions-syncer[bot] Apr 23, 2026
2a950fd
[Sync Iteration] yamlscript/word-count/1
exercism-solutions-syncer[bot] Apr 23, 2026
262d918
[Sync Iteration] yamlscript/yacht/1
exercism-solutions-syncer[bot] Apr 23, 2026
fc66d6e
[Sync Iteration] yamlscript/armstrong-numbers/1
exercism-solutions-syncer[bot] Apr 23, 2026
3a92e36
[Sync Iteration] yamlscript/diamond/1
exercism-solutions-syncer[bot] Apr 23, 2026
4f3b63f
[Sync Iteration] yamlscript/collatz-conjecture/1
exercism-solutions-syncer[bot] Apr 23, 2026
c696cc0
[Sync Iteration] yamlscript/eliuds-eggs/1
exercism-solutions-syncer[bot] Apr 23, 2026
0d59ce7
[Sync Iteration] yamlscript/grains/1
exercism-solutions-syncer[bot] Apr 23, 2026
5b5018a
[Sync Iteration] yamlscript/sieve/1
exercism-solutions-syncer[bot] Apr 23, 2026
544983a
[Sync Iteration] yamlscript/list-ops/1
exercism-solutions-syncer[bot] Apr 23, 2026
44c44bf
[Sync Iteration] yamlscript/resistor-color/1
exercism-solutions-syncer[bot] Apr 23, 2026
4a0a380
[Sync Iteration] yamlscript/two-bucket/1
exercism-solutions-syncer[bot] Apr 23, 2026
5bd15ac
[Sync Iteration] yamlscript/pig-latin/1
exercism-solutions-syncer[bot] Apr 23, 2026
ffd0780
[Sync Iteration] yamlscript/square-root/1
exercism-solutions-syncer[bot] Apr 23, 2026
104d96e
[Sync Iteration] yamlscript/pascals-triangle/1
exercism-solutions-syncer[bot] Apr 23, 2026
019731c
[Sync Iteration] yamlscript/resistor-color-duo/1
exercism-solutions-syncer[bot] Apr 23, 2026
acdda3b
[Sync Iteration] yamlscript/circular-buffer/1
exercism-solutions-syncer[bot] Apr 23, 2026
f8f40ff
[Sync Iteration] yamlscript/spiral-matrix/1
exercism-solutions-syncer[bot] Apr 23, 2026
51d21f2
[Sync Iteration] yamlscript/food-chain/1
exercism-solutions-syncer[bot] Apr 23, 2026
1dc57f9
[Sync Iteration] yamlscript/strain/1
exercism-solutions-syncer[bot] Apr 23, 2026
dbee347
[Sync Iteration] yamlscript/prime-factors/1
exercism-solutions-syncer[bot] Apr 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions solutions/yamlscript/acronym/1/acronym.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
!yamlscript/v0

defn abbreviate(phrase):
uc(phrase):
.re-seq(/[A-Z']+/)
.map(first):join
16 changes: 16 additions & 0 deletions solutions/yamlscript/all-your-base/1/all-your-base.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
!yamlscript/v0

defn rebase(input-base digits output-base):
when input-base < 2:
die('input base must be >= 2')

when output-base < 2:
die('output base must be >= 2')

when-not digits.every?(\(-1 < _ < input-base)):
die('all digits must satisfy 0 <= d < input base')

loop decimal reduce(\((_ * input-base) + %2) 0 digits), result []:
if decimal.?:
=>: recur(quot(decimal output-base) result.cons(decimal % output-base))
result |||: -[0]
20 changes: 20 additions & 0 deletions solutions/yamlscript/allergies/1/allergies.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
!yamlscript/v0

allergen-map =:
zipmap _ range()::
- eggs
- peanuts
- shellfish
- strawberries
- tomatoes
- chocolate
- pollen
- cats

defn allergic-to(item score):
bit-test score: allergen-map.$item

defn list-allergens(score):
keep _ allergen-map:
fn([allergen num]):
bit-test(score num) &&& allergen
9 changes: 9 additions & 0 deletions solutions/yamlscript/anagram/1/anagram.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
!yamlscript/v0

defn find-anagrams(subject candidates):
filter _ candidates:
partial _ subject:
fn(*words):
word1 word2 =: words.map(lc)
word1 != word2 &&:
sort(word1) == sort(word2)
5 changes: 5 additions & 0 deletions solutions/yamlscript/armstrong-numbers/1/armstrong-numbers.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
!yamlscript/v0

defn is-armstrong-number(number):
ds =: digits(number)
number ==: ds.map(\(_ ** ds.#)):sum
10 changes: 10 additions & 0 deletions solutions/yamlscript/atbash-cipher/1/atbash-cipher.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
!yamlscript/v0

defn encode(phrase):
lc(phrase):decode:
.replace(/[^a-z0-9]/)
.partition(5 5 '').map(join):joins

defn decode(phrase):
m =: (\\a .. \\z).zipmap(\\z .. \\a)
phrase: .replace(' ').escape(m)
61 changes: 61 additions & 0 deletions solutions/yamlscript/bank-account/1/bank-account.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
!yamlscript/v0

# Constants for error messages
ERROR-MESSAGES =::
account-closed: 'account not open'
account-open: 'account already open'
invalid-amount: 'amount must be greater than 0'
insufficient-funds: 'amount must be less than balance'

# Global account state
account =: atom(nil)

# Reset function for tests
defn reset-test-state():
reset! account: nil

# Main account operation handler
defn bank-account(operations):
last:
for operation operations:
operation
.operation
.str('do-' _)
.call(operation)

# Account operation implementations
defn- do-open(op):
when deref(account):
die: ERROR-MESSAGES.account-open
reset! account: 0

defn- do-close(op):
when-not deref(account):
die: ERROR-MESSAGES.account-closed
reset! account: nil

defn- do-balance(op):
balance =: deref(account)
if-not balance:
die: ERROR-MESSAGES.account-closed
else: balance

defn- do-deposit(op):
when-not deref(account):
die: ERROR-MESSAGES.account-closed
when op.amount <= 0:
die: ERROR-MESSAGES.invalid-amount
swap! account +: op.amount

defn- do-withdraw(op):
balance =: deref(account)
when-not balance:
die: ERROR-MESSAGES.account-closed

cond:
op.amount <= 0:
die: ERROR-MESSAGES.invalid-amount
op.amount > balance:
die: ERROR-MESSAGES.insufficient-funds
else:
swap! account -: op.amount
13 changes: 13 additions & 0 deletions solutions/yamlscript/binary-search/1/binary-search.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
!yamlscript/v0

defn find(array value):
loop low 0, high array.--:
when low > high:
die: 'value not in array'
mid =: (high + low).quot(2)
item =: array.$mid

cond:
value == item : mid
value < item : recur(low mid.--)
else : recur(mid.++ high)
11 changes: 11 additions & 0 deletions solutions/yamlscript/bob/1/bob.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
!yamlscript/v0

defn response(hey-bob):
condp re-matches hey-bob:trim:
/\s*/ : 'Fine. Be that way!'
/[^a-zA-Z]+\?/ : 'Sure.'
/[^a-z]+\?/ : "Calm down, I know what I'm doing!"
/.*\?/ : 'Sure.'
/[^a-zA-Z]*/ : 'Whatever.'
/[^a-z]*/ : 'Whoa, chill out!'
else : 'Whatever.'
22 changes: 22 additions & 0 deletions solutions/yamlscript/bottle-song/1/bottle-song.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
!yamlscript/v0

defn recite(start-bottles take-down):
nums =: start-bottles ..
(start-bottles - take-down).++
nums: .map(verse).join("\n"):lines

defn- verse(num): |
$uc1(bottles(num)) hanging on the wall,
$uc1(bottles(num)) hanging on the wall,
And if one green bottle should accidentally fall,
There'll be $bottles(num.--) hanging on the wall.

nums =:
zipmap (2 .. 10):
qw(two three four five six seven eight nine ten)

defn- bottles(num):
case num:
0 : 'no green bottles'
1 : 'one green bottle'
else : "$(nums.$num) green bottles"
6 changes: 6 additions & 0 deletions solutions/yamlscript/circular-buffer/1/circular-buffer.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
!yamlscript/v0

# ?????

defn run(capacity operations):
-{}
11 changes: 11 additions & 0 deletions solutions/yamlscript/collatz-conjecture/1/collatz-conjecture.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
!yamlscript/v0

defn steps(number):
number > 0 ||:
die: 'Only positive integers are allowed'

loop num number, steps 0:
cond:
num.eq(1) : steps
num:even? : recur(num.div(2), steps.++)
else : recur(num.mul(3).++, steps.++)
8 changes: 8 additions & 0 deletions solutions/yamlscript/darts/1/darts.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
!yamlscript/v0

defn score(x y):
condp ge math/hypot(x y):
1 : 10
5 : 5
10 : 1
else : 0
13 changes: 13 additions & 0 deletions solutions/yamlscript/diamond/1/diamond.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
!yamlscript/v0

defn rows(letter):
ipad =:
letter.0:N.sub(64).mul(2).sub(3) * ' '

loop C letter.0, I ipad, O '', dmnd '':
line =: I.?.if("$O$C$I$C$O\n" "$O$C$O\n")
dmnd =: dmnd.?.if("$line$dmnd$line" line)

if I.?:
recur: C.--, I.chop(2), "$O ", dmnd
else: dmnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
!yamlscript/v0

defn square-of-sum(number):
sqr: sum(1 .. number)

defn sum-of-squares(number):
sum: (1 .. number).map(sqr)

defn difference-of-squares(number):
square-of-sum(number) -
sum-of-squares(number)
7 changes: 7 additions & 0 deletions solutions/yamlscript/eliuds-eggs/1/eliuds-eggs.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
!yamlscript/v0

defn egg-count(number):
loop num number, eggs 0:
if num > 0:
recur: quot(num 2), eggs.add(num % 2)
else: eggs
6 changes: 6 additions & 0 deletions solutions/yamlscript/etl/1/etl.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
!yamlscript/v0

defn transform(legacy):
into {}:
for [score words] legacy, word words:
-[lc(word) to-int(score)]
28 changes: 28 additions & 0 deletions solutions/yamlscript/food-chain/1/food-chain.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
!yamlscript/v0
animals-and-comments =::
- fly: I don't know why she swallowed the fly. Perhaps she'll die.
- spider: It wriggled and jiggled and tickled inside her.
- bird: How absurd to swallow a bird!
- cat: Imagine that, to swallow a cat!
- dog: What a hog, to swallow a dog!
- goat: Just opened her throat and swallowed a goat!
- cow: I don't know how she swallowed a cow!
- horse: She's dead, of course!
defn recite(start-verse end-verse):
reduce(build-verse [] (start-verse.-- .. end-verse.--)):drop-last
defn build-verse(accumulated-verses current-verse):
current-animal =: animals-and-comments.$current-verse.first().0
accumulated-verses .=: conj("I know an old lady who swallowed a $current-animal.")
accumulated-verses .=: conj(animals-and-comments.$current-verse.first().1)
conj _ '':
or _ accumulated-verses:
when 0 < current-verse < animals-and-comments.#.--:
conj _ animals-and-comments.0:first.1:
reduce _ accumulated-verses (current-verse .. 1):
fn(verse-lines verse-num):
conj verse-lines:
predator =: animals-and-comments.$verse-num.first().0
prey =: animals-and-comments.nth(verse-num.--):first.0
S("She swallowed the $predator to catch the $prey."):
.call(fn([line] if((prey != 'spider') line
replace(line /\./ replace(animals-and-comments.1:first.1 /It/ ' that'))))_)
7 changes: 7 additions & 0 deletions solutions/yamlscript/grains/1/grains.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
!yamlscript/v0

defn square(square):
(1 <= square <= 64) ||:
die: 'square must be between 1 and 64'

pow 2: square - 1
7 changes: 7 additions & 0 deletions solutions/yamlscript/hamming/1/hamming.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
!yamlscript/v0

defn distance(strand1 strand2):
strand1.# == strand2.# ||:
die: 'strands must be of equal length'

len: map(ne strand1 strand2).filter(a)
4 changes: 4 additions & 0 deletions solutions/yamlscript/hello-world/1/hello-world.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
!YS-v0

defn hello():
'Hello, World!'
7 changes: 7 additions & 0 deletions solutions/yamlscript/isogram/1/isogram.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
!yamlscript/v0

defn isogram(string):
empty?(string) ||:
lc(string):split \"Want to be case insensitive"
.filter(/^[a-z]$/) \"Keep letters only"
.distinct?(*) \"Check if distinct letters"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
!yamlscript/v0

defn largest-product(digits span):
cond:
span < 0 : die('span must not be negative')
span > digits.# : die('span must be smaller than string length')
digits =~ /[^\d]/ : die('digits input must only contain digits')

digits.split(''):
.map(to-num)
.partition(span 1)
.map(\(_.mul(*)))
.max(*)
6 changes: 6 additions & 0 deletions solutions/yamlscript/leap/1/leap.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
!yamlscript/v0

defn leap-year(year):
(year % 4):zero? &&:
(year % 100):pos? ||:
(year % 400):zero?
28 changes: 28 additions & 0 deletions solutions/yamlscript/list-ops/1/list-ops.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
!yamlscript/v0

defn append(list1 list2):
list1 + list2

defn concat(lists):
lists.mapcat(a)

defn filter(list function):
list.filter(function)

defn length(list):
list:count

defn map(list function):
list.map(function)

defn foldl(list initial function):
list.reduce(function initial)

defn foldr(list initial function):
if len(list) > 0:
function _ list:first:
foldr: rest(list) initial function
else: initial

defn reverse(list):
core/reverse: list
Loading