2017-08-15

This commit is contained in:
Brian Buller 2017-08-15 10:04:10 -05:00
parent 63b955575a
commit 88b47de8c8
24 changed files with 3100 additions and 0 deletions

52
d/hello-world/README.md Normal file
View File

@ -0,0 +1,52 @@
# Hello World
The classical introductory exercise. Just say "Hello, World!".
["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is
the traditional first program for beginning programming in a new language
or environment.
The objectives are simple:
- Write a function that returns the string "Hello, World!".
- Run the test suite and make sure that it succeeds.
- Submit your solution and check it at the website.
If everything goes well, you will be ready to fetch your first real exercise.
## Getting Started
Make sure you have read [D page](http://exercism.io/languages/dlang) on
exercism.io. This covers the basic information on setting up the development
environment expected by the exercises.
## Passing the Tests
Get the first test compiling, linking and passing by following the [three
rules of test-driven development](http://butunclebob.com/ArticleS.UncleBob.TheThreeRulesOfTdd).
Create just enough structure by declaring namespaces, functions, classes,
etc., to satisfy any compiler errors and get the test to fail. Then write
just enough code to get the test to pass. Once you've done that,
uncomment the next test by moving the following line past the next test.
```D
static if (all_tests_enabled)
```
This may result in compile errors as new constructs may be invoked that
you haven't yet declared or defined. Again, fix the compile errors minimally
to get a failing test, then change the code minimally to pass the test,
refactor your implementation for readability and expressiveness and then
go on to the next test.
Try to use standard D facilities in preference to writing your own
low-level algorithms or facilities by hand. [DRefLanguage](https://dlang.org/spec/spec.html)
and [DReference](https://dlang.org/phobos/index.html) are references to the D language and D standard library.
## Source
This is an exercise to introduce users to using Exercism [http://en.wikipedia.org/wiki/%22Hello,_world!%22_program](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program)
## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.

2
d/hello-world/dub.sdl Normal file
View File

@ -0,0 +1,2 @@
name "hello-world"
buildRequirements "disallowDeprecations"

View File

@ -0,0 +1,13 @@
module helloworld_test;
unittest {
const int allTestsEnabled = 0;
assert(hello() == "Hello, World!");
static if (allTestsEnabled) {
assert(hello("Alice") == "Hello, Alice!");
assert(hello("Bob") == "Hello, Bob!");
assert(hello("") == "Hello, !");
}
}

View File

@ -0,0 +1,60 @@
program HelloWorld;
{$IFNDEF TESTINSIGHT}
{$APPTYPE CONSOLE}
{$ENDIF}{$STRONGLINKTYPES ON}
uses
System.SysUtils,
{$IFDEF TESTINSIGHT}
TestInsight.DUnitX,
{$ENDIF }
DUnitX.Loggers.Console,
DUnitX.Loggers.Xml.NUnit,
DUnitX.TestFramework,
uTestHelloWorld in 'uTestHelloWorld.pas',
uHelloWorld in 'uHelloWorld.pas';
var
runner : ITestRunner;
results : IRunResults;
logger : ITestLogger;
nunitLogger : ITestLogger;
begin
{$IFDEF TESTINSIGHT}
TestInsight.DUnitX.RunRegisteredTests;
exit;
{$ENDIF}
try
//Check command line options, will exit if invalid
TDUnitX.CheckCommandLine;
//Create the test runner
runner := TDUnitX.CreateRunner;
//Tell the runner to use RTTI to find Fixtures
runner.UseRTTI := True;
//tell the runner how we will log things
//Log to the console window
logger := TDUnitXConsoleLogger.Create(true);
runner.AddLogger(logger);
//Generate an NUnit compatible XML File
nunitLogger := TDUnitXXMLNUnitFileLogger.Create(TDUnitX.Options.XMLOutputFile);
runner.AddLogger(nunitLogger);
runner.FailsOnNoAsserts := False; //When true, Assertions must be made during tests;
//Run tests
results := runner.Execute;
if not results.AllPassed then
System.ExitCode := EXIT_ERRORS;
{$IFNDEF CI}
//We don't want this happening when running under CI.
if TDUnitX.Options.ExitBehavior = TDUnitXExitBehavior.Pause then
begin
System.Write('Done.. press <Enter> key to quit.');
System.Readln;
end;
{$ENDIF}
except
on E: Exception do
System.Writeln(E.ClassName, ': ', E.Message);
end;
end.

View File

@ -0,0 +1,42 @@
# Hello World
The classical introductory exercise. Just say "Hello, World!".
["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is
the traditional first program for beginning programming in a new language
or environment.
The objectives are simple:
- Write a function that returns the string "Hello, World!".
- Run the test suite and make sure that it succeeds.
- Submit your solution and check it at the website.
If everything goes well, you will be ready to fetch your first real exercise.
## Testing
In order to run the tests for this track, you will need to install
DUnitX. Please see the [installation](http://www.exercism.io/languages/delphi/installing) instructions for more information.
### Loading Exercises into Delphi
If Delphi is properly installed, and `*.dpr` file types have been associated with Delphi, then double clicking the supplied `*.dpr` file will start Delphi and load the exercise/project. `control + F9` is the keyboard shortcut to compile the project or pressing `F9` will compile and run the project.
Alternatively you may opt to start Delphi and load your project via. the `File` drop down menu.
### When Questions Come Up
We monitor the [Pascal-Delphi](https://gitter.im/exercism/Pascal-Delphi) support room on [gitter.im](https://gitter.im) to help you with any questions that might arise.
### Submitting Exercises
Note that, when trying to submit an exercise, make sure the exercise file you're submitting is in the `exercism/delphi/<exerciseName>` directory.
For example, if you're submitting `ubob.pas` for the Bob exercise, the submit command would be something like `exercism submit <path_to_exercism_dir>/delphi/bob/ubob.pas`.
## Source
This is an exercise to introduce users to using Exercism [http://en.wikipedia.org/wiki/%22Hello,_world!%22_program](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program)
## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.

View File

@ -0,0 +1,85 @@
(******************************************************************************
You got an error, which is exactly as it should be.
This is the first step in the Test-Driven Development
(TDD) process.
The most important part of the error is
"cannot compile"
It's looking for a file named uHelloWorld.pas that doesn't exist.
To fix the error, create a unit file named uHelloWorld.pas
in the same directory as the file uTestHelloWorld.pas.
The beginning of the new unit file should contain a unit statement:
unit uHelloWorld;
The new unit should contain Interface, Implementation, and End. statements.
The primary focus of this exercise is to provide you with a very simple
exercise that you can use to test the tools necessary for this language track,
are working correctly. To that end we are providing you with code that you may
use as the solution to this exercise:
{------------------< start solution >------------------}
unit uHelloWorld;
interface
function Hello: string;
implementation
function Hello: string;
begin
result := 'Hello, World!';
end;
end.
{------------------< end solution >------------------}
Hint: Delphi will take care of all this if you instruct it to add a new unit
to your project. Be sure to save the new unit as uHelloWorld.pas before
trying to compile again.
For more guidance as you work on this exercise, see
GETTING_STARTED.md.
******************************************************************************)
unit uTestHelloWorld;
interface
uses
DUnitX.TestFramework;
type
[TestFixture]
HelloWorldTest = class(TObject)
public
[Test]
procedure Say_hi;
end;
implementation
uses uHelloWorld;
procedure HelloWorldTest.Say_hi;
var
Expected: string;
Actual: string;
begin
Expected := 'Hello, World!'; //Expected: This is what is expected to be returned by the function/method (Hello)
Actual := Hello; //Actual: This is what is actually returned by the function/method (Hello)
Assert.AreEqual(Expected, Actual);
//As you progress in this track you will find that not every exercise has Expected and
//Actual defined as explicitly as they have been above. Often times you may find
//that the Expected outcome is inserted as an inline statement and the the call
//to the method being tested will be inserted in the Actual position of AreEqual like so:
//Assert.AreEqual('Hello, World!', Hello);
end;
initialization
TDUnitX.RegisterTestFixture(HelloWorldTest);
end.

View File

@ -0,0 +1,15 @@
#`(
This is a 'stub' file. It's a little start on your solution.
It is not a complete solution though; you will have to write some code.
The ':ver<>' adverb defines the version of a module or class.
The version is checked in the test suite to ensure the exercise
and test suite line up. If the test is updated, it will indicate
to others who test your code that some tests may no longer pass.
)
unit module HelloWorld:ver<2>;
sub hello is export {
# Write your solution to pass the test suite here.
# Be sure to remove all stock comments once you are done!
}

View File

@ -0,0 +1,36 @@
# Hello World
The classical introductory exercise. Just say "Hello, World!".
["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is
the traditional first program for beginning programming in a new language
or environment.
The objectives are simple:
- Write a function that returns the string "Hello, World!".
- Run the test suite and make sure that it succeeds.
- Submit your solution and check it at the website.
If everything goes well, you will be ready to fetch your first real exercise.
## Resources
Remember to check out the Perl 6 [documentation](https://docs.perl6.org/) and
[resources](https://perl6.org/resources/) pages for information, tips, and
examples if you get stuck.
## Running the tests
There is a test script included with the exercise; a file with the extension
`.t`. You can run the test script for the exercise by executing the command
`prove . --exec=perl6` in the exercise directory. You can also add the `-v` flag
e.g. `prove . --exec=perl6 -v` to display all tests, including any optional
tests marked as 'TODO'.
## Source
This is an exercise to introduce users to using Exercism [http://en.wikipedia.org/wiki/%22Hello,_world!%22_program](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program)
## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.

View File

@ -0,0 +1,60 @@
#!/usr/bin/env perl6
use v6;
use Test;
use lib my $dir = $?FILE.IO.dirname; #`[Look for the module inside the same directory as this test file.]
use JSON::Fast;
my $exercise = 'HelloWorld'; #`[The name of this exercise.]
my $version = v2; #`[The version we will be matching against the exercise.]
my $module = %*ENV<EXERCISM> ?? 'Example' !! $exercise; #`[%*ENV<EXERCISM> is for tests not directly for the exercise, don't worry about these :)]
plan 3; #`[This is how many tests we expect to run.]
#`[Check that the module can be use-d.]
use-ok $module or bail-out;
require ::($module);
#`[If the exercise is updated, we want to make sure other people testing
your code don't think you've made a mistake if things have changed!]
if ::($exercise).^ver !~~ $version {
warn "\nExercise version mismatch. Further tests may fail!"
~ "\n$exercise is $(::($exercise).^ver.gist). "
~ "Test is $($version.gist).\n";
bail-out 'Example version must match test version.' if %*ENV<EXERCISM>;
}
#`[Import '&hello' from 'HelloWorld']
require ::($module) <&hello>;
my $c-data;
#`[Go through the cases (hiding at the bottom of this file)
and check that &hello gives us the correct response.]
is &::('hello')(), |.<expected description> for @($c-data<cases>);
#`[Ignore this for your exercise! Tells Exercism folks when exercise cases become out of date.]
if %*ENV<EXERCISM> {
if (my $c-data-file = "$dir/../../problem-specifications/exercises/{$dir.IO.resolve.basename}/canonical-data.json".IO.resolve) ~~ :f {
is-deeply $c-data, EVAL('use JSON::Fast; from-json($c-data-file.slurp);'), 'canonical-data';
} else { flunk 'canonical-data' }
} else { skip }
done-testing; #`[There are no more tests after this :)]
#`['INIT' is a phaser, it makes sure that the test data is available before everything else
starts running (otherwise we'd have to shove the test data into the middle of the file!)]
INIT {
$c-data := from-json q:to/END/;
{
"exercise": "hello-world",
"version": "1.0.0",
"cases": [
{
"description": "Say Hi!",
"property": "hello",
"expected": "Hello, World!"
}
]
}
END
}

View File

@ -0,0 +1,36 @@
# Rna Transcription
Given a DNA strand, return its RNA complement (per RNA transcription).
Both DNA and RNA strands are a sequence of nucleotides.
The four nucleotides found in DNA are adenine (**A**), cytosine (**C**),
guanine (**G**) and thymine (**T**).
The four nucleotides found in RNA are adenine (**A**), cytosine (**C**),
guanine (**G**) and uracil (**U**).
Given a DNA strand, its transcribed RNA strand is formed by replacing
each nucleotide with its complement:
* `G` -> `C`
* `C` -> `G`
* `T` -> `A`
* `A` -> `U`
### Submitting Exercises
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
For example, if you're submitting `bob.py` for the Bob exercise, the submit command would be something like `exercism submit <path_to_exercism_dir>/python/bob/bob.py`.
For more detailed information about running tests, code style and linting,
please see the [help page](http://exercism.io/languages/python).
## Source
Rosalind [http://rosalind.info/problems/rna](http://rosalind.info/problems/rna)
## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.

View File

@ -0,0 +1,2 @@
def to_rna():
pass

View File

@ -0,0 +1,35 @@
import unittest
from rna_transcription import to_rna
# test cases adapted from `x-common//canonical-data.json` @ version: 1.0.0
class DNATests(unittest.TestCase):
def test_transcribes_guanine_to_cytosine(self):
self.assertEqual(to_rna('G'), 'C')
def test_transcribes_cytosine_to_guanine(self):
self.assertEqual(to_rna('C'), 'G')
def test_transcribes_thymine_to_adenine(self):
self.assertEqual(to_rna('T'), 'A')
def test_transcribes_adenine_to_uracil(self):
self.assertEqual(to_rna('A'), 'U')
def test_transcribes_all_occurences(self):
self.assertMultiLineEqual(to_rna('ACGTGGTCTTAA'), 'UGCACCAGAAUU')
def test_correctly_handles_single_invalid_input(self):
self.assertEqual(to_rna('U'), '')
def test_correctly_handles_completely_invalid_input(self):
self.assertMultiLineEqual(to_rna('XXX'), '')
def test_correctly_handles_partially_invalid_input(self):
self.assertMultiLineEqual(to_rna('ACGTXXXCTTAA'), '')
if __name__ == '__main__':
unittest.main()

31
r/hello-world/README.md Normal file
View File

@ -0,0 +1,31 @@
# Hello World
The classical introductory exercise. Just say "Hello, World!".
["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is
the traditional first program for beginning programming in a new language
or environment.
The objectives are simple:
- Write a function that returns the string "Hello, World!".
- Run the test suite and make sure that it succeeds.
- Submit your solution and check it at the website.
If everything goes well, you will be ready to fetch your first real exercise.
## Installation
See [this guide](https://github.com/exercism/xr/blob/master/docs/INSTALLATION.md) for instructions on how to setup your local R environment.
## How to implement your solution
In each problem folder, there is a file named `<exercise_name>.R` containing a function that returns a `NULL` value. Place your implementation inside the body of the function.
## How to run tests
Inside of RStudio, simply execute the `test_<exercise_name>.R` script. This can be conveniently done with [testthat's `auto_test` function](https://www.rdocumentation.org/packages/testthat/topics/auto_test). Because exercism code and tests are in the same folder, use this same path for both `code_path` and `test_path` parameters. On the command-line, you can also run `Rscript test_<exercise_name>.R`.
## Source
This is an exercise to introduce users to using Exercism [http://en.wikipedia.org/wiki/%22Hello,_world!%22_program](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program)
## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.

View File

@ -0,0 +1,3 @@
hello_world <- function() {
}

View File

@ -0,0 +1,16 @@
source("./hello-world.R")
library(testthat)
test_that("no name", {
expect_equal(hello_world(), "Hello, World!")
})
test_that("sample name", {
expect_equal(hello_world("Alice"), "Hello, Alice!")
})
test_that("other sample name", {
expect_equal(hello_world("Bob"), "Hello, Bob!")
})
message("All tests passed for exercise: hello-world")

View File

@ -0,0 +1,47 @@
# Hello World
The classical introductory exercise. Just say "Hello, World!".
["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is
the traditional first program for beginning programming in a new language
or environment.
The objectives are simple:
- Write a function that returns the string "Hello, World!".
- Run the test suite and make sure that it succeeds.
- Submit your solution and check it at the website.
If everything goes well, you will be ready to fetch your first real exercise.
## Setup
Go through the setup instructions for TypeScript to
install the necessary dependencies:
http://exercism.io/languages/typescript
## Requirements
Install assignment dependencies:
```bash
$ yarn install
```
## Making the test suite pass
Execute the tests with:
```bash
$ yarn test
```
## Source
This is an exercise to introduce users to using Exercism [http://en.wikipedia.org/wiki/%22Hello,_world!%22_program](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program)
## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.

View File

@ -0,0 +1,17 @@
import HelloWorld from "./hello-world"
describe('Hello World', () => {
it('says hello world with no name', () => {
expect(HelloWorld.hello()).toEqual('Hello, World!')
})
xit('says hello to bob', () => {
expect(HelloWorld.hello('Bob')).toEqual('Hello, Bob!')
})
xit('says hello to sally', () => {
expect(HelloWorld.hello('Sally')).toEqual('Hello, Sally!')
})
})

View File

@ -0,0 +1,36 @@
{
"name": "xtypescript",
"version": "0",
"description": "Exercism exercises in Typescript.",
"author": "",
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/exercism/xtypescript"
},
"devDependencies": {},
"scripts": {
"test": "tsc --noEmit -p . && jest --no-cache",
"lint": "tsc --noEmit -p . && tslint \"*.ts?(x)\"",
"lintci": "tslint \"*.ts?(x)\" --force"
},
"dependencies": {
"@types/jest": "^20.0.0",
"@types/node": "^7.0.5",
"jest": "^20.0.4",
"ts-jest": "^20.0.6",
"tslint": "^5.4.3",
"typescript": "^2.2.1"
},
"jest": {
"transform": {
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js"
]
}
}

View File

@ -0,0 +1,22 @@
{
"compilerOptions": {
"target": "es2017",
"module": "commonjs",
"alwaysStrict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitAny": true,
"strictNullChecks": true,
"preserveConstEnums": true,
"noFallthroughCasesInSwitch":true,
"noImplicitThis":true,
"noImplicitReturns":true,
"sourceMap": true,
"noEmitOnError": true,
"outDir": "./build"
},
"compileOnSave": true,
"exclude": [
"node_modules"
]
}

View File

@ -0,0 +1,127 @@
{
"jsRules": {
"class-name": true,
"comment-format": [
true,
"check-space"
],
"indent": [
true,
"spaces"
],
"no-duplicate-variable": true,
"no-eval": true,
"no-trailing-whitespace": true,
"no-unsafe-finally": true,
"one-line": [
true,
"check-open-brace",
"check-whitespace"
],
"quotemark": [
false,
"double"
],
"semicolon": [
true,
"never"
],
"triple-equals": [
true,
"allow-null-check"
],
"variable-name": [
true,
"ban-keywords"
],
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
]
},
"rules": {
"class-name": true,
"comment-format": [
true,
"check-space"
],
"indent": [
true,
"spaces"
],
"no-eval": true,
"no-internal-module": true,
"no-trailing-whitespace": true,
"no-unsafe-finally": true,
"no-var-keyword": true,
"one-line": [
true,
"check-open-brace",
"check-whitespace"
],
"semicolon": [
true,
"never"
],
"triple-equals": [
true,
"allow-null-check"
],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"variable-name": [
true,
"ban-keywords"
],
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
],
"no-namespace": true,
"prefer-for-of": true,
"only-arrow-functions": [true, "allow-declarations"],
"no-var-requires": true,
"no-any": true,
"curly": true,
"forin": true,
"no-arg": true,
"label-position": true,
"no-conditional-assignment": true,
"no-console": [true, "log", "error"],
"no-construct": true,
"no-duplicate-variable": true,
"no-empty": true,
"no-invalid-this": [true, "check-function-in-method"],
"no-misused-new": true,
"no-null-keyword": true,
"no-string-literal": true,
"radix": true,
"typeof-compare": true,
"use-isnan": true,
"prefer-const": true,
"array-type": [true, "array-simple"],
"arrow-parens": true,
"new-parens": true,
"no-consecutive-blank-lines": [true,1],
"no-parameter-properties": true,
"no-unnecessary-initializer": true,
"object-literal-shorthand": true,
"object-literal-key-quotes": [true, "as-needed"]
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,30 @@
# Hello World
The classical introductory exercise. Just say "Hello, World!".
["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is
the traditional first program for beginning programming in a new language
or environment.
The objectives are simple:
- Write a function that returns the string "Hello, World!".
- Run the test suite and make sure that it succeeds.
- Submit your solution and check it at the website.
If everything goes well, you will be ready to fetch your first real exercise.
# How to run the tests
If you don't know how to run Vader tests, see:
[Tests](http://exercism.io/languages/vimscript/tests).
For general information about the Vim script track, see:
[Help](http://exercism.io/languages/vimscript).
## Source
This is an exercise to introduce users to using Exercism [http://en.wikipedia.org/wiki/%22Hello,_world!%22_program](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program)
## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.

View File

@ -0,0 +1,8 @@
Execute (says hello using default argument):
AssertEqual "Hello, World!", Hello()
Execute (says hello using name "Bram"):
AssertEqual "Hello, Bram!", Hello('Bram')
Execute (says hello using name "Bill Joy"):
AssertEqual "Hello, Bill Joy!", Hello('Bill Joy')

View File

@ -0,0 +1,20 @@
"
" Greet someone or something!
"
" If no argument is given, return 'Hello, World!'.
" If the optional argument is given, greet that name instead.
"
" Hint: If you're confused by the first line in the function,
" read `:help a:0`.
"
" It also uses the short if-then-else syntax which is
" called ternary operator in other languages:
"
" condition ? true : false
"
function! Hello(...) abort
let name = (a:0 == 1 ? a:1 : 'World')
" your implementation goes here
endfunction