Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update current exercises #91

Merged
merged 17 commits into from
Apr 2, 2024
Merged
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 README
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
## Status

A fair amount of work has been done to configure this track, including creating a test runner.
There are 5 implemented exercises for this track.
There are 7 implemented exercises for this track.

If you wish to work on this track, please post in the [Exercism Community Forum](https://forum.exercism.org/c/exercism/building-exercism/125) to discuss it with the team.
42 changes: 42 additions & 0 deletions bin/fetch-configlet.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This file is a copy of the
# https://github.com/exercism/configlet/blob/main/scripts/fetch-configlet.ps1 file.
# Please submit bugfixes/improvements to the above file to ensure that all tracks
# benefit from the changes.

$ErrorActionPreference = "Stop"
$ProgressPreference = "SilentlyContinue"

$requestOpts = @{
Headers = If ($env:GITHUB_TOKEN) { @{ Authorization = "Bearer ${env:GITHUB_TOKEN}" } } Else { @{ } }
MaximumRetryCount = 3
RetryIntervalSec = 1
}

Function Get-DownloadUrl {
$arch = If ([Environment]::Is64BitOperatingSystem) { "x86-64" } Else { "i386" }
$latestUrl = "https://api.github.com/repos/exercism/configlet/releases/latest"
Invoke-RestMethod -Uri $latestUrl -PreserveAuthorizationOnRedirect @requestOpts `
| Select-Object -ExpandProperty assets `
| Where-Object { $_.name -match "^configlet_.+_windows_${arch}.zip$" } `
| Select-Object -ExpandProperty browser_download_url -First 1
}

$outputDirectory = "bin"
if (!(Test-Path -Path $outputDirectory)) {
Write-Output "Error: no ./bin directory found. This script should be ran from a repo root."
exit 1
}

Write-Output "Fetching configlet..."
$downloadUrl = Get-DownloadUrl
$outputFileName = "configlet.zip"
$outputPath = Join-Path -Path $outputDirectory -ChildPath $outputFileName
Invoke-WebRequest -Uri $downloadUrl -OutFile $outputPath @requestOpts

$configletPath = Join-Path -Path $outputDirectory -ChildPath "configlet.exe"
if (Test-Path -Path $configletPath) { Remove-Item -Path $configletPath }
[System.IO.Compression.ZipFile]::ExtractToDirectory($outputPath, $outputDirectory)
Remove-Item -Path $outputPath

$configletVersion = (Select-String -Pattern "/releases/download/(.+?)/" -InputObject $downloadUrl -AllMatches).Matches.Groups[1].Value
Write-Output "Downloaded configlet ${configletVersion} to ${configletPath}"
53 changes: 30 additions & 23 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
{
"track_id": "j",
"language": "J",
"slug": "j",
"version": 3,
"blurb": "J is a terse interpreted array language originally designed by Ken Iverson and Roger Hui. It is great for wholemeal functional programming, supports object orientation, and blazes through numerical vector computations.\n",
"active": false,
"status": {
"concept_exercises": false,
"test_runner": false,
"test_runner": true,
"representer": false,
"analyzer": false
},
"blurb": "J is a terse interpreted array language originally designed by Ken Iverson and Roger Hui. It is great for wholemeal functional programming, supports object orientation, and blazes through numerical vector computations.\n",
"version": 3,
"online_editor": {
"indent_style": "space",
"indent_size": 0,
"indent_size": 2,
"highlightjs_language": "text"
},
"test_runner": {
"average_run_time": 20
},
"files": {
"solution": [
"%{kebab_slug}.ijs"
Expand All @@ -24,32 +26,29 @@
"test.ijs"
],
"example": [
"example.ijs"
".meta/example.ijs"
],
"exemplar": [
".meta/exemplar.ijs"
]
},
"exercises": {
"concept": [],
"practice": [
{
"slug": "hello-world",
"name": "Hello World",
"uuid": "b59cd640-e925-4570-aa6e-3d903651e9f1",
"practices": [],
"prerequisites": [],
"difficulty": 1,
"version": "1.1.0"
"difficulty": 1
},
{
"slug": "hamming",
"name": "Hamming",
"uuid": "ab2c70c9-a1db-4be4-bd74-a08fe72ccba8",
"practices": [],
"prerequisites": [],
"difficulty": 1,
"version": "2.3.0",
"difficulty": 2,
"status": "deprecated"
},
{
Expand All @@ -58,35 +57,31 @@
"uuid": "266be147-836e-42c7-91d0-6c577037c2ff",
"practices": [],
"prerequisites": [],
"difficulty": 1,
"version": "1.3.0"
"difficulty": 2
},
{
"slug": "rna-transcription",
"name": "Rna Transcription",
"uuid": "b6570e32-ed50-4ff9-bc9d-0202aa39b344",
"practices": [],
"prerequisites": [],
"difficulty": 1,
"version": "1.3.0"
"difficulty": 1
},
{
"slug": "pascals-triangle",
"name": "Pascals Triangle",
"uuid": "e044a725-8509-4978-ad3b-ab0546663986",
"practices": [],
"prerequisites": [],
"difficulty": 1,
"version": "1.5.0"
"difficulty": 4
},
{
"slug": "sum-of-multiples",
"name": "Sum Of Multiples",
"uuid": "14555b65-4f96-4d4b-bbb0-fcd0b21a1a15",
"practices": [],
"prerequisites": [],
"difficulty": 1,
"version": "1.5.0"
"difficulty": 1
},
{
"slug": "difference-of-squares",
Expand All @@ -95,12 +90,24 @@
"practices": [],
"prerequisites": [],
"difficulty": 1,
"version": "1.2.0",
"status": "deprecated"
}
]
},
"concepts": [],
"key_features": [],
"tags": []
"tags": [
"paradigm/declarative",
"paradigm/functional",
"paradigm/object_oriented",
"platform/linux",
"platform/windows",
"platform/ios",
"platform/mac",
"platform/android",
"runtime/language_specific",
"runtime/standalone_executable",
"used_for/financial_systems",
"used_for/guis",
"used_for/scientific_calculations",
"used_for/scripts"
]
}
2 changes: 1 addition & 1 deletion docs/INSTALLATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Refer to [System/Installation](https://code.jsoftware.com/wiki/System/Installation) for instructions on how to get things set up on your system.

After installing, I'd suggest using the package manager (called `pacman`) to grab available addons. This includes fun bits like plotting, graphics, image manipulation, and much else. To do this, you can start a `J` console session by typing `jconsole` then enter:
After installing, Use the package manager (called `pacman`) to grab available addons. This includes fun bits like plotting, graphics, image manipulation, and much else. To do this, you can start a `J` console session by typing `jconsole` then enter:

```j
load 'pacman'
Expand Down
2 changes: 2 additions & 0 deletions docs/LEARNING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
- [J Primer](https://www.jsoftware.com/help/primer/contents.htm) a tour of `J` and great starting point that avoids being overly concise and focused on the complex aspects of the language.
- [Learning J](https://www.jsoftware.com/help/learning/contents.htm) a more in depth tour of `J` suitable for beginners as well as experienced programmers.
- [J For C Programmers](https://www.jsoftware.com/help/jforc/contents.htm) a more detailed introduction to `J` assuming familiarity with `C`.
- [At Play With J](https://code.jsoftware.com/wiki/At_Play_With_J) A compilation of 41 articles originally published in Vector magazine by Eugene McDonnell. It's a painless well-motivated way into J for the novice.
- [Fifty Shades of J](https://code.jsoftware.com/wiki/Fifty_Shades_of_J) A collection of 50 essays published at the J-ottings column in Vector magazine. It will look some J's basic features in detail and present ways to make them even more useful and interesting.
- [J Phrases](https://www.jsoftware.com/help/phrases/contents.htm) a collection of `J` sentences and phrases. Helpful for learning `J` idioms, developing `J` reading comprehension, and looking up approaches to common tasks.
- [J Dictionary](https://www.jsoftware.com/help/dictionary/contents.htm) `J` thourgh sessions, covering a good breadth of the language.

Expand Down
11 changes: 8 additions & 3 deletions docs/TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ If you run in to any issues with running the tests at all please just submit you
- Head to the problem directory (eg `~/Exercism/hello-world`).
- Start a `jconsole` session (eg by typing `jconsole` or `ijconsole`) in a terminal.
- Load your solution file (eg `load 'hello-world.ijs'`)
- Test your solution by typing `0!:2 < 'test.ijs'`.
- Load the unit test framework by typing `load 'general/unittest'`
- Test your solution by typing `unittest 'test.ijs'`.


# Terminal
Expand All @@ -26,10 +27,14 @@ Then from inside the J console, reload by typing
load 'hamming.ijs'
```

Next Step is load the unit test framework by typing
```j
load 'general/unittest'
```
To run the tests &#x2013; after you have loaded your solution &#x2013; type

```j
0!:2 < 'test.ijs'
unittest 'test.ijs'
```

The verb (aka function) [0!:2](https://code.jsoftware.com/wiki/Vocabulary/Foreigns#m0) is an example of something called a *foreign*. It loads its argument and treats each line of it as an assertion which will be true or false (1 or 0) and prints out the line and the result of checking the assertion. Another option to test is using `0!:3` which won't print for each line but will return 1 if all assertions pass or 0 if something doesn't. `0!:2` and `0!:3` expect boxed strings as their arguments, that's the purpose of `<` above.
And the observe the results.
3 changes: 2 additions & 1 deletion exercises/practice/difference-of-squares/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"jitwit"
],
"contributors": [
"iHiD"
"iHiD",
"eNascimento178"
],
"files": {
"solution": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
square_of_sum=: ]
sum_of_square=: ]
difference_of_squares =: ]
square_of_sum=: 'You need to implement this verb.'13!:8 (55)
sum_of_square=: 'You need to implement this verb.'13!:8 (55)
difference_of_squares =: 'You need to implement this verb.'13!:8 (55)
67 changes: 59 additions & 8 deletions exercises/practice/difference-of-squares/test.ijs
Original file line number Diff line number Diff line change
@@ -1,8 +1,59 @@
225 = square_of_sum 5
25502500 = square_of_sum 100
1 = sum_of_square 1
55 = sum_of_square 5
338350 = sum_of_square 100
0 = difference_of_squares 0
170 = difference_of_squares 5
25164150 = difference_of_squares 100
load 'difference-of-squares.ijs'

before_all=: monad define
order=: i.0
tasks=: i.0
)

after_all=: monad define
(, LF ,~"1 ": order ,. tasks) 1!:2 < jpath '~temp/helper.txt'
)


square_of_sum_5_ignore=: 0
test_square_of_sum_5 =: monad define
order=: order , 1 [ tasks=: tasks , 1
assert 225 = square_of_sum 5
)

square_of_sum_100_ignore=: 1 NB. Change this value to 0 to run this test
test_square_of_sum_100 =: monad define
order=: order , 2 [ tasks=: tasks , 1
assert 25502500 = square_of_sum 100
)

sum_of_square_1_ignore=: 1 NB. Change this value to 0 to run this test
test_sum_of_square_1 =: monad define
order=: order , 3 [ tasks=: tasks , 2
assert 1 = sum_of_square 1
)

sum_of_square_5_ignore=: 1 NB. Change this value to 0 to run this test
test_sum_of_square_5 =: monad define
order=: order , 4 [ tasks=: tasks , 2
assert 55 = sum_of_square 5
)

sum_of_square_100_ignore=: 1 NB. Change this value to 0 to run this test
test_sum_of_square_100 =: monad define
order=: order , 5 [ tasks=: tasks , 2
assert 338350 = sum_of_square 100
)

difference_of_squares_0_ignore=: 1 NB. Change this value to 0 to run this test
test_difference_of_squares_0 =: monad define
order=: order , 6 [ tasks=: tasks , 3
assert 0 = difference_of_squares 0
)

difference_of_squares_5_ignore=: 1 NB. Change this value to 0 to run this test
test_difference_of_squares_5 =: monad define
order=: order , 7 [ tasks=: tasks , 3
assert 170 = difference_of_squares 5
)

difference_of_squares_100_ignore=: 1 NB. Change this value to 0 to run this test
test_difference_of_squares_100 =: monad define
order=: order , 8 [ tasks=: tasks , 3
assert 25164150 = difference_of_squares 100
)
3 changes: 2 additions & 1 deletion exercises/practice/hamming/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"jitwit"
],
"contributors": [
"iHiD"
"iHiD",
"eNascimento178"
],
"files": {
"solution": [
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/hamming/hamming.ijs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
hamming=: ]
hamming=: 'You need to implement this verb.'13!:8 (55)
46 changes: 41 additions & 5 deletions exercises/practice/hamming/test.ijs
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
0=''hamming''
0=(,:'a')hamming(,:'a')
1=(,:'g')hamming(,:'t')
0='GGACTGAAATCTG'hamming'GGACTGAAATCTG'
9='GGACGGATTCTG'hamming'AGGACGGATTCT'
load'hamming.ijs'

before_all=: monad define
order=: i.0
tasks=: 1
)

after_all=: monad define
(, LF ,~"1 ": order ,. tasks) 1!:2 < jpath '~temp/helper.txt'
)


empty_strands_ignore=: 0
test_empty_strands =: monad define
order=: order , 1
assert 0 = '' hamming ''
)

single_letter_identical_strands_ignore=: 1 NB. Change this value to 0 to run this test
test_single_letter_identical_strands =: monad define
order=: order , 2
assert 0 = (1$'A') hamming (1$'A')
)

single_letter_different_strands_ignore=: 1 NB. Change this value to 0 to run this test
test_single_letter_different_strands =: monad define
order=: order , 3
assert 1 = (1$'G') hamming (1$'T')
)

long_identical_strands_ignore=: 1 NB. Change this value to 0 to run this test
test_long_identical_strands =: monad define
order=: order , 4
assert 0 = 'GGACTGAAATCTG' hamming 'GGACTGAAATCTG'
)

long_different_strands_ignore=: 1 NB. Change this value to 0 to run this test
test_long_different_strands =: monad define
order=: order , 5
assert 9 = 'GGACGGATTCTG' hamming 'AGGACGGATTCT'
)
Loading