trackler 2.2.1.175 → 2.2.1.176

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/tracks/clojure/config.json +1 -0
  4. data/tracks/clojure/docs/ABOUT.md +13 -0
  5. data/tracks/clojure/docs/INSTALLATION.md +21 -0
  6. data/tracks/clojure/docs/LEARNING.md +29 -0
  7. data/tracks/clojure/docs/RESOURCES.md +9 -0
  8. data/tracks/clojure/docs/{TESTS.org → TESTS.md} +22 -27
  9. data/tracks/clojure/exercises/anagram/src/anagram.clj +1 -1
  10. data/tracks/clojure/exercises/armstrong-numbers/src/armstrong_numbers.clj +1 -1
  11. data/tracks/clojure/exercises/beer-song/src/beer_song.clj +1 -1
  12. data/tracks/clojure/exercises/bob/src/bob.clj +1 -1
  13. data/tracks/clojure/exercises/clock/src/clock.clj +3 -3
  14. data/tracks/clojure/exercises/collatz-conjecture/src/collatz_conjecture.clj +1 -1
  15. data/tracks/clojure/exercises/etl/src/etl.clj +1 -1
  16. data/tracks/clojure/exercises/flatten-array/src/flatten_array.clj +1 -1
  17. data/tracks/clojure/exercises/grade-school/src/grade_school.clj +3 -3
  18. data/tracks/clojure/exercises/hamming/src/hamming.clj +2 -2
  19. data/tracks/clojure/exercises/leap/src/leap.clj +1 -1
  20. data/tracks/clojure/exercises/nucleotide-count/src/nucleotide_count.clj +2 -2
  21. data/tracks/clojure/exercises/phone-number/src/phone_number.clj +3 -3
  22. data/tracks/clojure/exercises/reverse-string/src/reverse_string.clj +1 -1
  23. data/tracks/clojure/exercises/rna-transcription/src/rna_transcription.clj +1 -1
  24. data/tracks/clojure/exercises/robot-name/src/robot_name.clj +2 -2
  25. data/tracks/clojure/exercises/run-length-encoding/src/run_length_encoding.clj +3 -3
  26. data/tracks/clojure/exercises/say/src/say.clj +1 -1
  27. data/tracks/clojure/exercises/series/src/series.clj +1 -1
  28. data/tracks/clojure/exercises/sublist/src/sublist.clj +1 -1
  29. data/tracks/clojure/exercises/two-fer/src/two_fer.clj +1 -1
  30. data/tracks/clojure/exercises/word-count/src/word_count.clj +1 -1
  31. data/tracks/ecmascript/config.json +12 -0
  32. data/tracks/ecmascript/exercises/reverse-string/README.md +42 -0
  33. data/tracks/ecmascript/exercises/reverse-string/example.js +9 -0
  34. data/tracks/ecmascript/exercises/reverse-string/package.json +70 -0
  35. data/tracks/ecmascript/exercises/reverse-string/reverse-string.spec.js +33 -0
  36. data/tracks/erlang/config.json +11 -0
  37. data/tracks/erlang/exercises/armstrong-numbers/README.md +53 -0
  38. data/tracks/erlang/exercises/armstrong-numbers/rebar.config +30 -0
  39. data/tracks/erlang/exercises/armstrong-numbers/src/armstrong_numbers.app.src +9 -0
  40. data/tracks/erlang/exercises/armstrong-numbers/src/armstrong_numbers.erl +8 -0
  41. data/tracks/erlang/exercises/armstrong-numbers/src/example.erl +29 -0
  42. data/tracks/erlang/exercises/armstrong-numbers/test/armstrong_numbers_tests.erl +33 -0
  43. data/tracks/erlang/exercises/bracket-push/src/example.erl +1 -1
  44. data/tracks/erlang/exercises/isbn-verifier/src/example.erl +1 -1
  45. data/tracks/julia/config.json +12 -0
  46. data/tracks/julia/docs/ABOUT.md +3 -3
  47. data/tracks/julia/exercises/spiral-matrix/README.md +31 -0
  48. data/tracks/julia/exercises/spiral-matrix/example.jl +9 -0
  49. data/tracks/julia/exercises/spiral-matrix/runtests.jl +25 -0
  50. data/tracks/julia/exercises/spiral-matrix/spiral-matrix.jl +3 -0
  51. data/tracks/perl5/config.json +1 -0
  52. data/tracks/perl5/docs/ABOUT.md +4 -3
  53. data/tracks/perl6/config.json +1 -0
  54. data/tracks/powershell/config.json +1 -1
  55. data/tracks/python/exercises/hello-world/example.py +2 -5
  56. data/tracks/python/exercises/hello-world/hello_world.py +1 -1
  57. data/tracks/reasonml/.gitignore +1 -0
  58. data/tracks/reasonml/Makefile +6 -3
  59. data/tracks/reasonml/config.json +21 -0
  60. data/tracks/reasonml/exercises/anagram/src/Anagram.rei +1 -0
  61. data/tracks/reasonml/exercises/anagram/src/Example.re +10 -12
  62. data/tracks/reasonml/exercises/binary-search/src/BinarySearch.rei +1 -0
  63. data/tracks/reasonml/exercises/bob/src/Bob.rei +1 -0
  64. data/tracks/reasonml/exercises/change/src/Change.rei +2 -0
  65. data/tracks/reasonml/exercises/change/src/Example.re +16 -15
  66. data/tracks/reasonml/exercises/hello-world/src/HelloWorld.rei +1 -0
  67. data/tracks/reasonml/exercises/leap/src/Leap.rei +1 -0
  68. data/tracks/reasonml/exercises/pangram/README.md +21 -0
  69. data/tracks/reasonml/exercises/pangram/__tests__/Pangram_test.re +36 -0
  70. data/tracks/reasonml/exercises/pangram/bsconfig.json +30 -0
  71. data/tracks/reasonml/exercises/pangram/package.json +20 -0
  72. data/tracks/reasonml/exercises/pangram/src/Example.re +36 -0
  73. data/tracks/reasonml/exercises/pangram/src/Pangram.rei +1 -0
  74. data/tracks/reasonml/exercises/phone-number/.gitignore +6 -0
  75. data/tracks/reasonml/exercises/phone-number/README.md +43 -0
  76. data/tracks/reasonml/exercises/phone-number/__tests__/PhoneNumber_test.re +48 -0
  77. data/tracks/reasonml/exercises/phone-number/bsconfig.json +27 -0
  78. data/tracks/reasonml/exercises/phone-number/package-lock.json +5853 -0
  79. data/tracks/reasonml/exercises/phone-number/package.json +20 -0
  80. data/tracks/reasonml/exercises/phone-number/src/Example.re +13 -0
  81. data/tracks/reasonml/exercises/phone-number/src/PhoneNumber.rei +1 -0
  82. data/tracks/reasonml/exercises/raindrops/src/Raindrops.rei +1 -0
  83. data/tracks/reasonml/exercises/rna-transcription/src/Example.re +13 -6
  84. data/tracks/reasonml/exercises/rna-transcription/src/RnaTranscription.rei +13 -0
  85. data/tracks/reasonml/exercises/run-length-encoding/src/RunLengthEncoding.rei +2 -0
  86. data/tracks/reasonml/exercises/space-age/__tests__/SpaceAge_test.re +8 -8
  87. data/tracks/reasonml/exercises/space-age/src/Example.re +3 -5
  88. data/tracks/reasonml/exercises/space-age/src/SpaceAge.rei +11 -0
  89. data/tracks/reasonml/exercises/word-count/src/WordCount.rei +1 -0
  90. data/tracks/sml/config.json +1 -0
  91. data/tracks/swift/.gitignore +5 -3
  92. data/tracks/swift/.travis.yml +8 -1
  93. data/tracks/swift/Package.swift +70 -11
  94. data/tracks/swift/exercises/atbash-cipher/Package.swift +1 -1
  95. data/tracks/swift/exercises/atbash-cipher/Sources/{Atbash.swift → AtbashCipher.swift} +0 -0
  96. data/tracks/swift/exercises/atbash-cipher/Sources/{AtbashExample.swift → AtbashCipherExample.swift} +1 -1
  97. data/tracks/swift/exercises/atbash-cipher/Tests/{AtbashTests/AtbashTests.swift → AtbashCipherTests/AtbashCipherTests.swift} +11 -11
  98. data/tracks/swift/exercises/atbash-cipher/Tests/LinuxMain.swift +2 -2
  99. data/tracks/swift/exercises/custom-set/Sources/CustomSetExample.swift +6 -2
  100. data/tracks/swift/exercises/poker/Sources/PokerExample.swift +2 -2
  101. metadata +49 -14
  102. data/tracks/clojure/docs/ABOUT.org +0 -24
  103. data/tracks/clojure/docs/INSTALLATION.org +0 -26
  104. data/tracks/clojure/docs/LEARNING.org +0 -35
  105. data/tracks/clojure/docs/RESOURCES.org +0 -9
  106. data/tracks/swift/.swift-version +0 -1
  107. data/tracks/swift/allProjects.xcworkspace.source/contents.xcworkspacedata +0 -4
  108. data/tracks/swift/allProjects.xcworkspace.source/xcshareddata/xcschemes/AllTest.xcscheme +0 -46
  109. data/tracks/swift/allProjectsPopulateWorkspace.sh +0 -35
@@ -0,0 +1,9 @@
1
+ function reverseString(string) {
2
+ let revString = '';
3
+ for (let i = string.length - 1; i >= 0; i -= 1) {
4
+ revString += string[i];
5
+ }
6
+ return revString;
7
+ }
8
+
9
+ export default reverseString;
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "xecmascript",
3
+ "version": "0.0.0",
4
+ "description": "Exercism exercises in ECMAScript 6.",
5
+ "author": "Katrina Owen",
6
+ "private": true,
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/exercism/xecmascript"
10
+ },
11
+ "devDependencies": {
12
+ "babel-jest": "^21.2.0",
13
+ "babel-plugin-transform-builtin-extend": "^1.1.2",
14
+ "babel-preset-env": "^1.4.0",
15
+ "eslint": "^3.19.0",
16
+ "eslint-config-airbnb": "^15.0.1",
17
+ "eslint-plugin-import": "^2.2.0",
18
+ "eslint-plugin-jsx-a11y": "^5.0.1",
19
+ "eslint-plugin-react": "^7.0.1",
20
+ "jest": "^21.2.1"
21
+ },
22
+ "jest": {
23
+ "modulePathIgnorePatterns": [
24
+ "package.json"
25
+ ]
26
+ },
27
+ "babel": {
28
+ "presets": [["env",{"targets":[{"node": "current"}]}]
29
+ ],
30
+ "plugins": [
31
+ [
32
+ "babel-plugin-transform-builtin-extend",
33
+ {
34
+ "globals": [
35
+ "Error"
36
+ ]
37
+ }
38
+ ],
39
+ [
40
+ "transform-regenerator"
41
+ ]
42
+ ]
43
+ },
44
+ "scripts": {
45
+ "test": "jest --no-cache ./*",
46
+ "watch": "jest --no-cache --watch ./*",
47
+ "lint": "eslint .",
48
+ "lint-test": "eslint . && jest --no-cache ./* "
49
+ },
50
+ "eslintConfig": {
51
+ "parserOptions": {
52
+ "ecmaVersion": 6,
53
+ "sourceType": "module"
54
+ },
55
+ "env": {
56
+ "es6": true,
57
+ "node": true,
58
+ "jest": true
59
+ },
60
+ "extends": "airbnb",
61
+ "rules": {
62
+ "import/no-unresolved": "off",
63
+ "import/extensions": "off"
64
+ }
65
+ },
66
+ "licenses": [
67
+ "MIT"
68
+ ],
69
+ "dependencies": {}
70
+ }
@@ -0,0 +1,33 @@
1
+ import reverseString from './reverse-string';
2
+
3
+ describe('ReverseString', () => {
4
+ test('empty string', () => {
5
+ const expected = '';
6
+ const actual = reverseString('');
7
+ expect(actual).toEqual(expected);
8
+ });
9
+
10
+ xtest('a word', () => {
11
+ const expected = 'tobor';
12
+ const actual = reverseString('robot');
13
+ expect(actual).toEqual(expected);
14
+ });
15
+
16
+ xtest('a capitalized word', () => {
17
+ const expected = 'nemaR';
18
+ const actual = reverseString('Ramen');
19
+ expect(actual).toEqual(expected);
20
+ });
21
+
22
+ xtest('a sentence with punctuation', () => {
23
+ const expected = '!yrgnuh ma I';
24
+ const actual = reverseString('I am hungry!');
25
+ expect(actual).toEqual(expected);
26
+ });
27
+
28
+ xtest('a palindrome', () => {
29
+ const expected = 'racecar';
30
+ const actual = reverseString('racecar');
31
+ expect(actual).toEqual(expected);
32
+ });
33
+ });
@@ -199,6 +199,17 @@
199
199
  "mathematics"
200
200
  ]
201
201
  },
202
+ {
203
+ "slug": "armstrong-numbers",
204
+ "uuid": "a639ce2f-48e3-46cd-9d11-955ba2a9eaaa",
205
+ "core": false,
206
+ "unlocked_by": "collatz-conjecture",
207
+ "difficulty": 2,
208
+ "topics": [
209
+ "integers",
210
+ "mathematics"
211
+ ]
212
+ },
202
213
  {
203
214
  "slug": "anagram",
204
215
  "uuid": "8f0570ae-223f-4da4-8b84-268b797b28ad",
@@ -0,0 +1,53 @@
1
+ An [Armstrong number](https://en.wikipedia.org/wiki/Narcissistic_number) is a number that is the sum of its own digits each raised to the power of the number of digits.
2
+
3
+ For example:
4
+
5
+ - 9 is an Armstrong number, because `9 = 9^1 = 9`
6
+ - 10 is *not* an Armstrong number, because `10 != 1^2 + 0^2 = 1`
7
+ - 153 is an Armstrong number, because: `153 = 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153`
8
+ - 154 is *not* an Armstrong number, because: `154 != 1^3 + 5^3 + 4^3 = 1 + 125 + 64 = 190`
9
+
10
+ Write some code to determine whether a number is an Armstrong number.
11
+
12
+ ## Running tests
13
+
14
+ In order to run the tests, issue the following command from the exercise
15
+ directory:
16
+
17
+ For running the tests provided, `rebar3` is used as it is the official build and
18
+ dependency management tool for erlang now. Please refer to [the tracks installation
19
+ instructions](http://exercism.io/languages/erlang/installation) on how to do that.
20
+
21
+ In order to run the tests, you can issue the following command from the exercise
22
+ directory.
23
+
24
+ ```bash
25
+ $ rebar3 eunit
26
+ ```
27
+
28
+ ### Test versioning
29
+
30
+ Each problem defines a macro `TEST_VERSION` in the test file and
31
+ verifies that the solution defines and exports a function `test_version`
32
+ returning that same value.
33
+
34
+ To make tests pass, add the following to your solution:
35
+
36
+ ```erlang
37
+ -export([test_version/0]).
38
+
39
+ test_version() ->
40
+ 1.
41
+ ```
42
+
43
+ The benefit of this is that reviewers can see against which test version
44
+ an iteration was written if, for example, a previously posted solution
45
+ does not solve the current problem or passes current tests.
46
+
47
+ ## Questions?
48
+
49
+ For detailed information about the Erlang track, please refer to the
50
+ [help page](http://exercism.io/languages/erlang) on the Exercism site.
51
+ This covers the basic information on setting up the development
52
+ environment expected by the exercises.
53
+
@@ -0,0 +1,30 @@
1
+ %% Erlang compiler options
2
+ {erl_opts, [debug_info]}.
3
+
4
+ {deps, [{erl_exercism, "0.1.1"}]}.
5
+
6
+ {dialyzer, [
7
+ {warnings, [underspecs, no_return]},
8
+ {get_warnings, true},
9
+ {plt_apps, top_level_deps}, % top_level_deps | all_deps
10
+ {plt_extra_apps, []},
11
+ {plt_location, local}, % local | "/my/file/name"
12
+ {plt_prefix, "rebar3"},
13
+ {base_plt_apps, [stdlib, kernel, crypto]},
14
+ {base_plt_location, global}, % global | "/my/file/name"
15
+ {base_plt_prefix, "rebar3"}
16
+ ]}.
17
+
18
+ %% eunit:test(Tests)
19
+ {eunit_tests, []}.
20
+ %% Options for eunit:test(Tests, Opts)
21
+ {eunit_opts, [verbose]}.
22
+
23
+ %% == xref ==
24
+
25
+ {xref_warnings, true}.
26
+
27
+ %% xref checks to run
28
+ {xref_checks, [undefined_function_calls, undefined_functions,
29
+ locals_not_used, exports_not_used,
30
+ deprecated_function_calls, deprecated_functions]}.
@@ -0,0 +1,9 @@
1
+ {application, armstrong_numbers,
2
+ [{description, "exercism.io - armstrong-numbers"},
3
+ {vsn, "0.0.1"},
4
+ {modules, []},
5
+ {registered, []},
6
+ {applications, [kernel,
7
+ stdlib]},
8
+ {env, []}
9
+ ]}.
@@ -0,0 +1,8 @@
1
+ -module(armstrong_numbers).
2
+
3
+ -export([is_armstrong_number/1, test_version/0]).
4
+
5
+ is_armstrong_number(N) ->
6
+ undefined.
7
+
8
+ test_version() -> 1.
@@ -0,0 +1,29 @@
1
+ -module(example).
2
+
3
+ -export([is_armstrong_number/1, test_version/0]).
4
+
5
+ is_armstrong_number(N) ->
6
+ {Digits, Count}=to_digits(N),
7
+ N==calc_number(Digits, Count).
8
+
9
+ calc_number(Digits, Count) ->
10
+ calc_number(Digits, Count, 0).
11
+
12
+ calc_number([], _, Acc) ->
13
+ Acc;
14
+
15
+ calc_number([Digit|More], Count, Acc) ->
16
+ calc_number(More, Count, Acc+trunc(math:pow(Digit, Count))).
17
+
18
+ to_digits(N) ->
19
+ to_digits(N, [], 0).
20
+
21
+ to_digits(0, AccD, AccN) ->
22
+ {AccD, AccN};
23
+
24
+ to_digits(N, Digits, Count) ->
25
+ Digit=N rem 10,
26
+ NewN=N div 10,
27
+ to_digits(NewN, [Digit|Digits], Count+1).
28
+
29
+ test_version() -> 1.
@@ -0,0 +1,33 @@
1
+ %% based on canonical data version 1.0.0
2
+ %% https://raw.githubusercontent.com/exercism/problem-specifications/master/exercises/armstrong-numbers/canonical-data.json
3
+
4
+ -module(armstrong_numbers_tests).
5
+
6
+ -define(TESTED_MODULE, (sut(<erlangified_slug_name>))).
7
+ -define(TEST_VERSION, 1).
8
+ -include_lib("erl_exercism/include/exercism.hrl").
9
+ -include_lib("eunit/include/eunit.hrl").
10
+
11
+ single_digit_numbers_test() ->
12
+ ?assert(armstrong_numbers:is_armstrong_number(5)).
13
+
14
+ two_digit_numbers_test() ->
15
+ ?assertNot(armstrong_numbers:is_armstrong_number(10)).
16
+
17
+ three_digit_armstrong_numbers_test() ->
18
+ ?assert(armstrong_numbers:is_armstrong_number(153)).
19
+
20
+ three_digit_not_armstrong_numbers_test() ->
21
+ ?assertNot(armstrong_numbers:is_armstrong_number(100)).
22
+
23
+ four_digit_armstrong_numbers_test() ->
24
+ ?assert(armstrong_numbers:is_armstrong_number(9474)).
25
+
26
+ four_digit_not_armstrong_numbers_test() ->
27
+ ?assertNot(armstrong_numbers:is_armstrong_number(9475)).
28
+
29
+ seven_digit_armstrong_numbers_test() ->
30
+ ?assert(armstrong_numbers:is_armstrong_number(9926315)).
31
+
32
+ seven_digit_not_armstrong_numbers_test() ->
33
+ ?assertNot(armstrong_numbers:is_armstrong_number(9926314)).
@@ -1,4 +1,4 @@
1
- -module(bracket_push).
1
+ -module(example).
2
2
 
3
3
  -export([is_paired/1, test_version/0]).
4
4
 
@@ -1,4 +1,4 @@
1
- -module(isbn_verifier).
1
+ -module(example).
2
2
 
3
3
  -export([is_valid/1, test_version/0]).
4
4
 
@@ -407,6 +407,18 @@
407
407
  "exceptions"
408
408
  ]
409
409
  },
410
+ {
411
+ "uuid": "3a2facfd-5ec8-49a0-a5aa-2229f07da896",
412
+ "slug": "spiral-matrix",
413
+ "core": false,
414
+ "unlocked_by": null,
415
+ "difficulty": 3,
416
+ "topics": [
417
+ "matrix",
418
+ "mathematics",
419
+ "iterators"
420
+ ]
421
+ },
410
422
  {
411
423
  "slug": "isbn-verifier",
412
424
  "uuid": "22b64a2b-7f08-444d-be6e-8b42e5c9207c",
@@ -1,7 +1,7 @@
1
1
  The creators of Julia want to eat their cake and have it too. As they describe in their blog post ["Why We Created Julia"](http://julialang.org/blog/2012/02/why-we-created-julia) they want the speed of C, the dynamism of Ruby, the familiar mathematical notation of Matlab. They want it to be their favourite things from their favourite languages. String processing like Perl. Glue like the shell. Powerful but not impenetrably complex.
2
2
 
3
- Julia has a dynamic, nominative and parametric [type system](http://docs.julialang.org/en/stable/manual/types/). This allows writing dynamic code and specifying types if additional expressiveness is needed for simplification or performance increases. The language features multiple dispatch, meaning it chooses which method is called based on the types of each argument. This lets you write specific methods for certain types while providing generic fallbacks and is particularly useful for mathematical code, where it is not clear why an operation should belong to a specific argument.
3
+ Julia has a powerful, yet clear and intuitive, dynamic [type system](http://docs.julialang.org/en/stable/manual/types/). It allows writing dynamic code and specifying types if additional expressiveness is needed for simplification or performance increases. The language features multiple dispatch, meaning it chooses which method is called based on the types of each argument. This lets you write specific methods for certain types while providing generic fallbacks and is particularly useful for mathematical code, where it is not clear why an operation should belong to a specific argument.
4
4
 
5
- [Metaprogramming](http://docs.julialang.org/en/stable/manual/metaprogramming/) is easy in Julia due to its homoiconicity, i.e. Julia code can be represented in Julia itself. Large parts of [Julia's base library](https://github.com/julialang/julia) are also written in Julia. Understanding and changing it does not require knowledge of another language. If a library you need to use is written in another language, such as [C, Fortran](http://docs.julialang.org/en/stable/manual/calling-c-and-fortran-code/) or [Python](https://github.com/JuliaPy/PyCall.jl), you can use simple interfaces to call them directly from your code.
5
+ [Metaprogramming](http://docs.julialang.org/en/stable/manual/metaprogramming/) is easy in Julia due to its homoiconicity, i.e. Julia code can be represented in Julia itself, just like in Lisp. Large parts of [Julia's base and standard library](https://github.com/julialang/julia) are also written in Julia. Understanding and changing it does not require knowledge of another language. If a library you need to use is written in another language, such as [C, Fortran](http://docs.julialang.org/en/stable/manual/calling-c-and-fortran-code/) or [Python](https://github.com/JuliaPy/PyCall.jl), you can use simple interfaces to call them directly from your code.
6
6
 
7
- Despite its young age, Julia is already being used in the real world in a variety of fields, such as but not limited to Finance, Data Science and Scientific Computing. You can find many showcase applications on [juliabloggers.com](http://www.juliabloggers.com/) and a list of publications about the language and its technical computing applications [here](http://julialang.org/publications/).
7
+ Despite its young age, Julia is already being used in the real world in a variety of fields, such as but not limited to Finance, Data Science and Scientific Computing. You can find many showcase applications on [juliabloggers.com](http://www.juliabloggers.com/) and a list of publications about the language and its applications [here](http://julialang.org/publications/).
@@ -0,0 +1,31 @@
1
+ # Spiral Matrix
2
+
3
+ Given the size, return a square matrix of numbers in spiral order.
4
+
5
+ The matrix should be filled with natural numbers, starting from 1
6
+ in the top-left corner, increasing in an inward, clockwise spiral order,
7
+ like these examples:
8
+
9
+ ###### Spiral matrix of size 3
10
+
11
+ ```text
12
+ 1 2 3
13
+ 8 9 4
14
+ 7 6 5
15
+ ```
16
+
17
+ ###### Spiral matrix of size 4
18
+
19
+ ```text
20
+ 1 2 3 4
21
+ 12 13 14 5
22
+ 11 16 15 6
23
+ 10 9 8 7
24
+ ```
25
+ ## Source
26
+
27
+ Reddit r/dailyprogrammer challenge #320 [Easy] Spiral Ascension. [https://www.reddit.com/r/dailyprogrammer/comments/6i60lr/20170619_challenge_320_easy_spiral_ascension/](https://www.reddit.com/r/dailyprogrammer/comments/6i60lr/20170619_challenge_320_easy_spiral_ascension/)
28
+
29
+
30
+ ## Submitting Incomplete Solutions
31
+ It's possible to submit an incomplete solution so you can see how others have completed the exercise.
@@ -0,0 +1,9 @@
1
+ #Credit to u/SingularInfinity on Redit: https://www.reddit.com/r/dailyprogrammer/comments/6i60lr/20170619_challenge_320_easy_spiral_ascension/djb8po0
2
+
3
+ function spiral_matrix(n::Int)
4
+ n < 0 && throw(DomainError("n should be positive"))
5
+ n == 0 && return Matrix{Int}(0,0)
6
+ n == 1 && return reshape(Int[1], 1, 1)
7
+ m = (2n - 1) .+ spiral_matrix(n-1)
8
+ return [ RowVector(1:n); rot180(m) n+1:2n-1 ]
9
+ end
@@ -0,0 +1,25 @@
1
+ using Base.Test
2
+
3
+ include("spiral-matrix.jl")
4
+
5
+
6
+ @testset "Different valid values" begin
7
+ @testset "Empty spiral" begin
8
+ @test spiral_matrix(0) == Matrix{Int}(0,0)
9
+ end
10
+ @testset "Trivial spiral" begin
11
+ @test spiral_matrix(1) == reshape([1],(1,1))
12
+ end
13
+ @testset "Spiral of size 2" begin
14
+ @test spiral_matrix(2) == [1 2; 4 3]
15
+ end
16
+ @testset "Spiral of size 3" begin
17
+ @test spiral_matrix(3) == [1 2 3; 8 9 4; 7 6 5]
18
+ end
19
+ @testset "Spiral of size 4" begin
20
+ @test spiral_matrix(4) == [1 2 3 4; 12 13 14 5; 11 16 15 6; 10 9 8 7]
21
+ end
22
+ @testset "Spiral of size 5" begin
23
+ @test spiral_matrix(5) == [1 2 3 4 5; 16 17 18 19 6; 15 24 25 20 7; 14 23 22 21 8; 13 12 11 10 9]
24
+ end
25
+ end
@@ -0,0 +1,3 @@
1
+ function spiral_matrix(n::Int)
2
+
3
+ end
@@ -9,6 +9,7 @@
9
9
  "slug": "hello-world",
10
10
  "uuid": "e436ce92-78b9-4b3b-b87e-581fa54cdc65",
11
11
  "core": false,
12
+ "auto_approve": true,
12
13
  "unlocked_by": null,
13
14
  "difficulty": 1,
14
15
  "topics": []
@@ -1,6 +1,7 @@
1
- # What is Perl5?
2
- Perl v5 is a high-level general purpose programming language invented by Larry Wall and first
3
- released in 1987. It is an eclectic interpreted, procedural, loosely typed language which had its peak of popularity with the rise of the World Wide Web, though it remains widely used in Quality Assurance, IT infrastructure automation, text processing, bioinformatics and web application development, just to name a few areas. It is highly flexible, but this flexibility can have a follow-on maintenance cost.
1
+ Perl v5 is a high-level general purpose programming language invented by Larry Wall and first released in 1987.
2
+ It is an eclectic interpreted, procedural, loosely typed language.
3
+ Its popularity peaked with the rise of the World Wide Web, though it remains widely used in Quality Assurance, IT infrastructure automation, text processing, bioinformatics and web application development, just to name a few areas.
4
+ It is highly flexible, but this flexibility can have a follow-on maintenance cost.
4
5
 
5
6
  Perl also has
6
7