Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
unzip uiua.zip
echo "${PWD}" >> "${GITHUB_PATH}"
env:
VERSION: 0.16.0
VERSION: 0.17.2
GH_TOKEN: ${{ github.token }}

- name: Verify all exercises
Expand Down
2 changes: 1 addition & 1 deletion docs/INSTALLATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
See the [official installation guide][install-guide] for the latest instructions, including IDE integration and fonts.

```exercism/note
Currently our online test-runner uses version `0.14.1`.
Currently our online test-runner uses version `0.17.0`.
With Uiua's rapid development process, that might be subject to change, so keep this in mind if you can't reproduce the testing results from the website.
```

Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/affine-cipher/.meta/example.ua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Coprime ← ¬/↥≡⌕ ∩(°/×)
MMI ← 1˜◿×⊃(⋅⇡|⊙∘)
MMI ← ˜⨂1˜◿×⊃(⋅⇡|⊙∘)
Validate ← ⍤"a and m must be coprime" (Coprime :26)
Groups ← ⊜(□∘)\+=0◿5°⊏
Sanitize ← ▽+⊃(⌵±|×⊃(≥@0|≤@9)).¯⌵
Encrypt ← ⍜(-@a▽)(◿26+×)⌵±.
Encode ← /$"_ _" Groups Encrypt Sanitize ⊃(⊙Validate|⋅∘)
Decrypt ← ◿26×⊃(⋅(MMI:26)|-:⊙⋅∘)
Decrypt ← ◿26×⊃(⋅(MMI : 26)|-:⊙⋅∘)
Decode ← ⍜(-@a▽|Decrypt)⌵±. ▽≠@\s. ⊃(⊙Validate|⋅∘)
4 changes: 2 additions & 2 deletions exercises/practice/affine-cipher/tests.ua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
⍤⤙≍ "swxtj npvyk lruol iejdc blaxk swxmh qzglf" Encode "The quick brown fox jumps over the lazy dog." 17 33

# encode with a not coprime to m
⍤⤙≍ "a and m must be coprime" ⍣(Encode "This is a test." 6 17)
⍤⤙≍ "a and m must be coprime" ⍣(Encode "This is a test." 6 17|∘)

# decode exercism
⍤⤙≍ "exercism" Decode "tytgn fjr" 3 7
Expand All @@ -46,4 +46,4 @@
⍤⤙≍ "jollygreengiant" Decode "vszzm cly yd cg qdp" 15 16

# decode with a not coprime to m
⍤⤙≍ "a and m must be coprime" ⍣(Decode "Test" 13 5)
⍤⤙≍ "a and m must be coprime" ⍣(Decode "Test" 13 5|∘)
2 changes: 1 addition & 1 deletion exercises/practice/all-your-base/.meta/example.ua
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ ValidBases ← (
ValidDigits ← ⍤"all digits must satisfy 0 <= d < input base" /×↧⊃(≥0|<:)
Valid ← ⊃(ValidDigits|⋅ValidBases)
FromInput ← /+×ⁿ:⊙(⇌°⊏):
ToOutput ← ⨬([0]|◿:⌊÷⊸⊃(ⁿ⊙⋅∘|⋅∘)◡(⇌⇡+1⌊:))±.
ToOutput ← ⨬([0]|◿:⌊÷⊸⊃(ⁿ⊙⋅∘|⋅∘)◡(⇌⇡+1⌊⌝˜ⁿ:))±.
Rebase ← ToOutput FromInput ◡Valid
18 changes: 9 additions & 9 deletions exercises/practice/all-your-base/tests.ua
Original file line number Diff line number Diff line change
Expand Up @@ -88,52 +88,52 @@ Expected ← [4 2]
Digits ← [0]
InputBase ← 1
OutputBase ← 10
⍤⤙≍ "input base must be >= 2" ⍣(Rebase Digits InputBase OutputBase)
⍤⤙≍ "input base must be >= 2" ⍣(Rebase Digits InputBase OutputBase|∘)

# Input base is zero
Digits ← []
InputBase ← 0
OutputBase ← 10
⍤⤙≍ "input base must be >= 2" ⍣(Rebase Digits InputBase OutputBase)
⍤⤙≍ "input base must be >= 2" ⍣(Rebase Digits InputBase OutputBase|∘)

# Input base is negative
Digits ← [1]
InputBase ← ¯2
OutputBase ← 10
⍤⤙≍ "input base must be >= 2" ⍣(Rebase Digits InputBase OutputBase)
⍤⤙≍ "input base must be >= 2" ⍣(Rebase Digits InputBase OutputBase|∘)

# Negative digit
Digits ← [1 ¯1 1 0 1 0]
InputBase ← 2
OutputBase ← 10
⍤⤙≍ "all digits must satisfy 0 <= d < input base" ⍣(Rebase Digits InputBase OutputBase)
⍤⤙≍ "all digits must satisfy 0 <= d < input base" ⍣(Rebase Digits InputBase OutputBase|∘)

# Invalid positive digit
Digits ← [1 2 1 0 1 0]
InputBase ← 2
OutputBase ← 10
⍤⤙≍ "all digits must satisfy 0 <= d < input base" ⍣(Rebase Digits InputBase OutputBase)
⍤⤙≍ "all digits must satisfy 0 <= d < input base" ⍣(Rebase Digits InputBase OutputBase|∘)

# Output base is one
Digits ← [1 0 1 0 1 0]
InputBase ← 2
OutputBase ← 1
⍤⤙≍ "output base must be >= 2" ⍣(Rebase Digits InputBase OutputBase)
⍤⤙≍ "output base must be >= 2" ⍣(Rebase Digits InputBase OutputBase|∘)

# Output base is zero
Digits ← [7]
InputBase ← 10
OutputBase ← 0
⍤⤙≍ "output base must be >= 2" ⍣(Rebase Digits InputBase OutputBase)
⍤⤙≍ "output base must be >= 2" ⍣(Rebase Digits InputBase OutputBase|∘)

# Output base is negative
Digits ← [1]
InputBase ← 2
OutputBase ← ¯7
⍤⤙≍ "output base must be >= 2" ⍣(Rebase Digits InputBase OutputBase)
⍤⤙≍ "output base must be >= 2" ⍣(Rebase Digits InputBase OutputBase|∘)

# Both bases are negative
Digits ← [1]
InputBase ← ¯2
OutputBase ← ¯7
⍤⤙≍ "input base must be >= 2" ⍣(Rebase Digits InputBase OutputBase)
⍤⤙≍ "input base must be >= 2" ⍣(Rebase Digits InputBase OutputBase|∘)
2 changes: 1 addition & 1 deletion exercises/practice/anagram/.meta/example.ua
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ FilterSelf ← |2 ▽≠⊙(¯⌵.)(¯⌵□)
GetAnagrams ← |3 ▽=⊙□
Sort ← |1 ⍆¯⌵
# Anagrams ? Target Words
FindAnagrams ← |2 FilterSelf : GetAnagrams≡(□Sort°□):Sort:⤙⊙:.
FindAnagrams ← |2 FilterSelf : GetAnagrams≡(□Sort°□):Sort :⤙⊙:.
2 changes: 1 addition & 1 deletion exercises/practice/atbash-cipher/.meta/example.ua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ Alnum ← ⊂Letters Digits
Reversed ← ⊂⇌Letters Digits
Sanitize ← ▽∊Alnum.
Groups ← ⊜(□∘)\+=0◿5°⊏
Translate ← ⊏ ⟜Reversed ⟜Alnum Sanitize ¯⌵
Translate ← ⊏ ⟜Reversed ˜⨂ ⟜Alnum Sanitize ¯⌵
Encode ← /$"_ _" Groups Translate
Decode ← Translate Sanitize
6 changes: 3 additions & 3 deletions exercises/practice/change/tests.ua
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ Expected ← []
# Error testing for change smaller than the smallest of coins
Coins ← [5 10]
Target ← 3
⍤⤙≍ "can't make target with given coins" ⍣(Change Coins Target)
⍤⤙≍ "can't make target with given coins" ⍣(Change Coins Target|∘)

# Error if no combination can add up to target
Coins ← [5 10]
Target ← 94
⍤⤙≍ "can't make target with given coins" ⍣(Change Coins Target)
⍤⤙≍ "can't make target with given coins" ⍣(Change Coins Target|∘)

# Cannot find negative change values
Coins ← [1 2 5]
Target ← ¯5
⍤⤙≍ "target can't be negative" ⍣(Change Coins Target)
⍤⤙≍ "target can't be negative" ⍣(Change Coins Target|∘)
4 changes: 2 additions & 2 deletions exercises/practice/collatz-conjecture/tests.ua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
⍤⤙≍ 4 Steps 16

# zero is an error
⍤⤙≍ "only positive integers are allowed" ⍣(Steps 0)
⍤⤙≍ "only positive integers are allowed" ⍣(Steps 0|∘)

# negative value is an error
⍤⤙≍ "only positive integers are allowed" ⍣(Steps ¯15)
⍤⤙≍ "only positive integers are allowed" ⍣(Steps ¯15|∘)
2 changes: 1 addition & 1 deletion exercises/practice/darts/.meta/example.ua
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Distance ← |2 √+∩(×.)
Score ← |2 ⊡ : 10_5_1_0 1 ≤ 1_5_10_∞ Distance
Score ← |2 ⊡ : 10_5_1_0 ˜⨂ 1 ≤ 1_5_10_∞ Distance
2 changes: 1 addition & 1 deletion exercises/practice/dnd-character/.meta/example.ua
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Constitution ← °□⊡2
Intelligence ← °□⊡3
Wisdom ← °□⊡4
Charisma ← °□⊡5
Hitpoints ← +10 Modifier Constitution
Hitpoints ← +10 Modifier Constitution
4 changes: 2 additions & 2 deletions exercises/practice/flower-field/tests.ua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
~ "flower-field.ua" ~ Annotate

# No rows
Garden ← ""
Expected ← ""
Garden ← ""
Expected ← ""
⍤⤙≍ Expected Annotate Garden

# No columns
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/forth/.meta/example.ua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
! ↚ ⋅⍜↙₂/^0
F ↚ (
⊜(⤚:{"DUP""DROP""SWAP""OVER""+""-""*""/"}□)⊸≠@ ⌵⊙[]
⊜(⤚˜⨂:{"DUP""DROP""SWAP""OVER""+""-""*""/"}□)⊸≠@ ⌵⊙[]
⇌∧⨬(
⊂⊸⊢◌
| ↘₁⍤.>₀⊸⧻◌
Expand All @@ -16,7 +16,7 @@ F ↚ (
Evaluate ← (
⍣(<∞⊸/↥F
| ▽⊜⍣(1⋕)∩0⊸≠@ ◌
1⨬"empty stack""only one value on the stack"≍1⍣⊣
1⨬"empty stack""only one value on the stack"≍1⍣⊣
)
⍤"divide by zero"
)
30 changes: 15 additions & 15 deletions exercises/practice/forth/tests.ua
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,28 @@
⍤⤙≍ [3] Evaluate "1 2 +"

# Addition - errors if there is nothing on the stack
⍤⤙≍ "empty stack" ⍣(Evaluate "+")
⍤⤙≍ "empty stack" ⍣(Evaluate "+"|∘)

# Addition - errors if there is only one value on the stack
⍤⤙≍ "only one value on the stack" ⍣(Evaluate "1 +")
⍤⤙≍ "only one value on the stack" ⍣(Evaluate "1 +"|∘)

# Subtraction - can subtract two numbers
⍤⤙≍ [¯1] Evaluate "3 4 -"

# Subtraction - errors if there is nothing on the stack
⍤⤙≍ "empty stack" ⍣(Evaluate "-")
⍤⤙≍ "empty stack" ⍣(Evaluate "-"|∘)

# Subtraction - errors if there is only one value on the stack
⍤⤙≍ "only one value on the stack" ⍣(Evaluate "1 -")
⍤⤙≍ "only one value on the stack" ⍣(Evaluate "1 -"|∘)

# Multiplication - can multiply two numbers
⍤⤙≍ [8] Evaluate "2 4 *"

# Multiplication - errors if there is nothing on the stack
⍤⤙≍ "empty stack" ⍣(Evaluate "*")
⍤⤙≍ "empty stack" ⍣(Evaluate "*"|∘)

# Multiplication - errors if there is only one value on the stack
⍤⤙≍ "only one value on the stack" ⍣(Evaluate "1 *")
⍤⤙≍ "only one value on the stack" ⍣(Evaluate "1 *"|∘)

# Division - can divide two numbers
⍤⤙≍ [4] Evaluate "12 3 /"
Expand All @@ -40,13 +40,13 @@
⍤⤙≍ [2] Evaluate "8 3 /"

# Division - errors if dividing by zero
⍤⤙≍ "divide by zero" ⍣(Evaluate "4 0 /")
⍤⤙≍ "divide by zero" ⍣(Evaluate "4 0 /"|∘)

# Division - errors if there is nothing on the stack
⍤⤙≍ "empty stack" ⍣(Evaluate "/")
⍤⤙≍ "empty stack" ⍣(Evaluate "/"|∘)

# Division - errors if there is only one value on the stack
⍤⤙≍ "only one value on the stack" ⍣(Evaluate "1 /")
⍤⤙≍ "only one value on the stack" ⍣(Evaluate "1 /"|∘)

# Combined arithmetic - addition and subtraction
⍤⤙≍ [¯1] Evaluate "1 2 + 4 -"
Expand All @@ -61,7 +61,7 @@
⍤⤙≍ [1 2 2] Evaluate "1 2 dup"

# Dup - errors if there is nothing on the stack
⍤⤙≍ "empty stack" ⍣(Evaluate "dup")
⍤⤙≍ "empty stack" ⍣(Evaluate "dup"|∘)

# Drop - removes the top value on the stack if it is the only one
⍤⤙≍ [] Evaluate "1 drop"
Expand All @@ -70,7 +70,7 @@
⍤⤙≍ [1] Evaluate "1 2 drop"

# Drop - errors if there is nothing on the stack
⍤⤙≍ "empty stack" ⍣(Evaluate "drop")
⍤⤙≍ "empty stack" ⍣(Evaluate "drop"|∘)

# Swap - swaps the top two values on the stack if they are the only ones
⍤⤙≍ [2 1] Evaluate "1 2 swap"
Expand All @@ -79,10 +79,10 @@
⍤⤙≍ [1 3 2] Evaluate "1 2 3 swap"

# Swap - errors if there is nothing on the stack
⍤⤙≍ "empty stack" ⍣(Evaluate "swap")
⍤⤙≍ "empty stack" ⍣(Evaluate "swap"|∘)

# Swap - errors if there is only one value on the stack
⍤⤙≍ "only one value on the stack" ⍣(Evaluate "1 swap")
⍤⤙≍ "only one value on the stack" ⍣(Evaluate "1 swap"|∘)

# Over - copies the second element if there are only two
⍤⤙≍ [1 2 1] Evaluate "1 2 over"
Expand All @@ -91,10 +91,10 @@
⍤⤙≍ [1 2 3 2] Evaluate "1 2 3 over"

# Over - errors if there is nothing on the stack
⍤⤙≍ "empty stack" ⍣(Evaluate "over")
⍤⤙≍ "empty stack" ⍣(Evaluate "over"|∘)

# Over - errors if there is only one value on the stack
⍤⤙≍ "only one value on the stack" ⍣(Evaluate "1 over")
⍤⤙≍ "only one value on the stack" ⍣(Evaluate "1 over"|∘)

# Case-insensitivity - DUP is case-insensitive
⍤⤙≍ [1 1 1 1] Evaluate "1 DUP Dup dup"
Expand Down
10 changes: 5 additions & 5 deletions exercises/practice/grains/tests.ua
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
⍤⤙≍ 2147483648 Square 32

# grains on square 64?
⍤⤙≍ 9223372036854775808 Square 64
⍤⤙≍ 9223372036854776000 Square 64

# square greater than 64 is invalid
⍤⤙≍ "square must be between 1 and 64" ⍣(Square 65)
⍤⤙≍ "square must be between 1 and 64" ⍣(Square 65|∘)

# square 0 is invalid
⍤⤙≍ "square must be between 1 and 64" ⍣(Square 0)
⍤⤙≍ "square must be between 1 and 64" ⍣(Square 0|∘)

# negative square is invali
⍤⤙≍ "square must be between 1 and 64" ⍣(Square `1)
⍤⤙≍ "square must be between 1 and 64" ⍣(Square ¯1|∘)

# returns the total number of grains on the board
⍤⤙≍ 18446744073709551615 Total
⍤⤙≍ 18446744073709552000 Total
8 changes: 4 additions & 4 deletions exercises/practice/hamming/tests.ua
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
⍤⤙≍ 9 Distance "GGACGGATTCTG" "AGGACGGATTCT"

# disallow empty first strand
⍤⤙≍ "strands must be of equal length" ⍣(Distance "" "G")
⍤⤙≍ "strands must be of equal length" ⍣(Distance "" "G"|∘)

# disallow empty second strand
⍤⤙≍ "strands must be of equal length" ⍣(Distance "G" "")
⍤⤙≍ "strands must be of equal length" ⍣(Distance "G" ""|∘)

# disallow first strand longer
⍤⤙≍ "strands must be of equal length" ⍣(Distance "AATG" "AAA")
⍤⤙≍ "strands must be of equal length" ⍣(Distance "AATG" "AAA"|∘)

# disallow second strand longer
⍤⤙≍ "strands must be of equal length" ⍣(Distance "ATA" "AGTG")
⍤⤙≍ "strands must be of equal length" ⍣(Distance "ATA" "AGTG"|∘)
8 changes: 4 additions & 4 deletions exercises/practice/intergalactic-transmission/tests.ua
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ Expected ← [41]

# first byte has wrong parity
Message ← [7 0]
⍤⤙≍ "wrong parity" ⍣(DecodeMessage Message)
⍤⤙≍ "wrong parity" ⍣(DecodeMessage Message|∘)

# second byte has wrong parity
Message ← [3 104]
⍤⤙≍ "wrong parity" ⍣(DecodeMessage Message)
⍤⤙≍ "wrong parity" ⍣(DecodeMessage Message|∘)

# 0xcf4b00 is decoded to 0xce94
Message ← [207 75 0]
Expand All @@ -110,7 +110,7 @@ Expected ← [71 114 101 97 116 49 33]

# last byte has wrong parity
Message ← [71 184 153 172 23 160 197 67]
⍤⤙≍ "wrong parity" ⍣(DecodeMessage Message)
⍤⤙≍ "wrong parity" ⍣(DecodeMessage Message|∘)

# eight byte message
Message ← [192 0 68 102 125 6 120 66 33 129]
Expand All @@ -124,4 +124,4 @@ Expected ← [69 120 101 114 99 105 115 109 32 105 115 32 97 119 101 115 111 109

# wrong parity on 16th byte
Message ← [68 189 24 175 39 27 165 231 108 144 27 46 51 3 132 239 101 184 219 237 215 40 132]
⍤⤙≍ "wrong parity" ⍣(DecodeMessage Message)
⍤⤙≍ "wrong parity" ⍣(DecodeMessage Message|∘)
8 changes: 4 additions & 4 deletions exercises/practice/largest-series-product/tests.ua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
⍤⤙≍ 0 LargestProduct "99099" 3

# rejects span longer than string length
⍤⤙≍ "span must be smaller than string length" ⍣(LargestProduct "123" 4)
⍤⤙≍ "span must be smaller than string length" ⍣(LargestProduct "123" 4|∘)

# reports 1 for empty string and empty product (0-span)
⍤⤙≍ 1 LargestProduct "" 0
Expand All @@ -37,10 +37,10 @@
⍤⤙≍ 1 LargestProduct "123" 0

# rejects empty string and nonzero span
⍤⤙≍ "span must be smaller than string length" ⍣(LargestProduct "" 1)
⍤⤙≍ "span must be smaller than string length" ⍣(LargestProduct "" 1|∘)

# rejects invalid character in digits
⍤⤙≍ "invalid character in digits" ⍣(LargestProduct "1234a5" 2)
⍤⤙≍ "invalid character in digits" ⍣(LargestProduct "1234a5" 2|∘)

# rejects negative span
⍤⤙≍ "span must not be negative" ⍣(LargestProduct "12345" ¯1)
⍤⤙≍ "span must not be negative" ⍣(LargestProduct "12345" ¯1|∘)
2 changes: 1 addition & 1 deletion exercises/practice/nth-prime/tests.ua
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
⍤⤙≍ 104743 Prime 10001

# There is no zeroth prime
⍤⤙≍ "there is no zeroth prime" ⍣(Prime 0)
⍤⤙≍ "there is no zeroth prime" ⍣(Prime 0|∘)
2 changes: 1 addition & 1 deletion exercises/practice/nucleotide-count/tests.ua
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
⍤⤙≍ map "ACGT" 20_12_17_21 NucleotideCounts "AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC"

# strand with invalid nucleotides
⍤⤙≍ "invalid nucleotide in strand" ⍣(NucleotideCounts "AGXXACT")
⍤⤙≍ "invalid nucleotide in strand" ⍣(NucleotideCounts "AGXXACT"|∘)
Loading
Loading