Skip to content
This repository was archived by the owner on Aug 1, 2021. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
6fa14b3
Merge pull request #4 from michaelavila/add_mit_license
kytrinyx Feb 28, 2014
e0d6c43
make JS tests run again
wilmoore Mar 2, 2014
af751fd
fix gitignore
wilmoore Mar 2, 2014
c60b4cc
Merge pull request #5 from wilmoore/fix-js-tests
kytrinyx Mar 2, 2014
a5c470b
added travis.yml for JS
wilmoore Mar 2, 2014
f0d3f05
Merge pull request #6 from wilmoore/configure-travis
kytrinyx Mar 3, 2014
d2f1977
Come at it the other way so we don't have to muck around with built-ins.
Mar 6, 2014
47ef926
Merge pull request #7 from cbojar/master
kytrinyx Mar 6, 2014
b802c3a
Update README
kytrinyx Mar 18, 2014
aa216d9
Added international characters test
dpashkevich Apr 1, 2014
623070e
Merge pull request #9 from dpashkevich/test-i11l-chars
kytrinyx Apr 1, 2014
8c7b37b
Add test for multiline string
dpashkevich Apr 1, 2014
b3ab226
Merge pull request #10 from dpashkevich/multiline
kytrinyx Apr 1, 2014
86c4374
refactor anagram example's API dropping constructor pattern (no new) …
wilmoore Apr 17, 2014
3e7e64b
accept a string as an argument
dpashkevich Apr 17, 2014
46fa645
skip tests 2..end
wilmoore Apr 17, 2014
1c36b39
Merge pull request #13 from wilmoore/anagram-refactor
kytrinyx Apr 17, 2014
8ad88b2
Update robot simulator spec with semicolons
nixterrimus May 2, 2014
a379bda
Merge pull request #14 from nixterrimus/patch-4
kytrinyx May 2, 2014
b5432f7
Add instructions about unskipping tests
kytrinyx May 3, 2014
4c7cf09
Explain how to run the test suite
kytrinyx May 3, 2014
7ead89a
Add circular buffer exercism
anthonygreen May 16, 2014
154fdd6
Merge pull request #17 from anthonygreen/circular-buffer
wilmoore May 16, 2014
53882ee
Fix nomenclature per recent discussions
kytrinyx May 18, 2014
1c0c350
Introduce proper config file
kytrinyx May 19, 2014
aaa0230
Delete outdated text config
kytrinyx May 19, 2014
3786294
Update config to ignore node modules
kytrinyx May 20, 2014
a876b1b
Add orhpaned exercises to problem list. Fixes #18
kytrinyx May 20, 2014
b64bfa5
Add deprecated section to config
kytrinyx May 20, 2014
4a91ad0
add clock excercise
wilmoore May 25, 2014
1e77d7a
Merge pull request #20 from wilmoore/clock
kytrinyx May 25, 2014
1cf476c
skip all but first test and drop extra level of indentation in exampl…
wilmoore May 25, 2014
4039a55
Merge pull request #21 from wilmoore/cleanup-clock
kytrinyx May 25, 2014
be4363b
use strict checking && fix stict violation
wilmoore May 28, 2014
dcd2b2d
Merge pull request #22 from wilmoore/strict-palindrome-products
kytrinyx May 28, 2014
9f70113
Add configlet binaries
kytrinyx Jun 2, 2014
220847a
Update configlet binaries
kytrinyx Jun 2, 2014
cf3abbf
Add configlet to travis build
kytrinyx Jun 2, 2014
a9a8bba
Ignore the bin directory when running tests
kytrinyx Jun 2, 2014
076fe6a
Refactor makefile
kytrinyx Jun 2, 2014
d1d650c
Fix ignore pattern in makefile
kytrinyx Jun 2, 2014
0c8c6fc
Refactor makefile
wilmoore Jun 3, 2014
8262f30
Batch basename call to improve performance.
cbojar Jun 4, 2014
1916338
Merge pull request #24 from cbojar/master
wilmoore Jun 4, 2014
2da92b9
Update configlet binaries
kytrinyx Jun 9, 2014
9da583a
Update configlet binaries
kytrinyx Jun 9, 2014
460619e
Removing "!" from calm test.
Jun 12, 2014
83ace83
Merge pull request #25 from montlebalm/master
wilmoore Jun 12, 2014
53a18a8
Change name of key for consistency
kytrinyx Jun 15, 2014
877c794
Update configlet binaries
kytrinyx Jun 15, 2014
455e192
Add foregone key to config
kytrinyx Jun 18, 2014
9f22bfb
Update configlet binaries
kytrinyx Jun 18, 2014
3bb7e96
Update configlet binaries
kytrinyx Jun 26, 2014
e461cf5
Update configlet binaries
kytrinyx Aug 1, 2014
16d9ba2
nucleotide-count: Remove special treatment of uracil
sjakobi Aug 17, 2014
f972ea7
Merge pull request #28 from sjakobi/adjust-nucleotide-count
wilmoore Aug 17, 2014
0c49384
refactor nucleotide-count assignment
wilmoore Aug 18, 2014
8495b42
Merge pull request #29 from wilmoore/nucleotide-count-refactor
kytrinyx Aug 18, 2014
7d33099
New Proposed JS Exercism - bracket-push
ginna-baker Aug 25, 2014
9dd9371
Refactored, added space, boolean literals, condensed test
ginna-baker Aug 27, 2014
64101a4
Delete bracket-push.js
ginna-baker Aug 31, 2014
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
35 changes: 35 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# unifying the coding style for different editors and IDEs => editorconfig.org

; indicate this is the root of the project
root = true

###########################################################
; common
###########################################################

[*]
charset = utf-8

end_of_line = LF
insert_final_newline = true
trim_trailing_whitespace = true

indent_style = space
indent_size = 2

###########################################################
; make
###########################################################

[Makefile]
indent_style = tab

[makefile]
indent_style = tab

###########################################################
; markdown
###########################################################

[*.md]
trim_trailing_whitespace = false
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*.beam
*.swp
.DS_Store
node_modules
npm-debug.log
tmp
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: node_js

node_js:
- 0.10

script:
- "make test"
- ./bin/configlet-linux-amd64 .

54 changes: 0 additions & 54 deletions EXERCISES.txt

This file was deleted.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# assignments
ASSIGNMENT ?= ""
IGNOREDIRS := "node_modules"
ASSIGNMENTS = $(shell find . -maxdepth 1 -mindepth 1 -type d | tr -d './' | sort | grep -Ev $(IGNOREDIRS))
IGNOREDIRS := "^(\.git|bin|node_modules)$$"
ASSIGNMENTS = $(shell find . -maxdepth 1 -mindepth 1 -type d -exec basename -a {} + | sort | grep -Ev $(IGNOREDIRS))

# output directories
TMPDIR ?= "/tmp"
Expand Down
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
# xJavaScript
# xJavaScript [![Build Status](https://travis-ci.org/exercism/xjavascript.png?branch=master)](https://travis-ci.org/exercism/xjavascript)

Exercism exercises in JavaScript

## Running Unit Test Suite

### All Assignments

% make test

### Single Assignment

% make test-assignment ASSIGNMENT=wordy

## Contributing Guide

Please see the [contributing guide](https://github.com/exercism/x-api/blob/master/CONTRIBUTING.md#the-exercise-data)

## License

The MIT License (MIT)

Copyright (c) 2014 Katrina Owen, _@kytrinyx.com

13 changes: 13 additions & 0 deletions SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Making the Test Suite Pass

Execute the tests with:

```bash
$ jasmine-node bob_test.spec.js
```

All but the first test have been skipped.

Once you get a test passing, you can unskip the next one by
changing `xit` to `it`.

55 changes: 36 additions & 19 deletions anagram/anagram_test.spec.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,75 @@
var Anagram = require('./anagram');
var anagram = require('./anagram');

describe('Anagram', function() {

it("no matches",function() {
var detector = new Anagram("diaper");
var matches = detector.match([ "hello", "world", "zombies", "pants"]);
var subject = anagram("diaper");
var matches = subject.matches([ "hello", "world", "zombies", "pants"]);

expect(matches).toEqual([]);
});

xit("detects simple anagram",function() {
var detector = new Anagram("ant");
var matches = detector.match(['tan', 'stand', 'at']);
var subject = anagram("ant");
var matches = subject.matches(['tan', 'stand', 'at']);

expect(matches).toEqual(['tan']);
});

xit("does not detect false positives",function() {
var detector = new Anagram("galea");
var matches = detector.match(["eagle"]);
var subject = anagram("galea");
var matches = subject.matches(["eagle"]);

expect(matches).toEqual([]);
});

xit("detects multiple anagrams",function() {
var detector = new Anagram("master");
var matches = detector.match(['stream', 'pigeon', 'maters']);
var subject = anagram("master");
var matches = subject.matches(['stream', 'pigeon', 'maters']);

expect(matches).toEqual(['stream', 'maters']);
});

xit("does not detect anagram subsets",function() {
var detector = new Anagram("good");
var matches = detector.match(['dog', 'goody']);
var subject = anagram("good");
var matches = subject.matches(['dog', 'goody']);

expect(matches).toEqual([]);
});

xit("detects anagram",function() {
var detector = new Anagram("listen");
var matches = detector.match(['enlists', 'google', 'inlets', 'banana']);
var subject = anagram("listen");
var matches = subject.matches(['enlists', 'google', 'inlets', 'banana']);

expect(matches).toEqual(['inlets']);
});

xit("detects multiple anagrams",function() {
var detector = new Anagram("allergy");
var matches = detector.match(['gallery', 'ballerina', 'regally', 'clergy', 'largely', 'leading']);
var subject = anagram("allergy");
var matches = subject.matches(['gallery', 'ballerina', 'regally', 'clergy', 'largely', 'leading']);

expect(matches).toEqual(['gallery', 'regally', 'largely']);
});

xit("detects anagrams case-insensitively",function() {
var detector = new Anagram("Orchestra");
var matches = detector.match(['cashregister', 'Carthorse', 'radishes']);
var subject = anagram("Orchestra");
var matches = subject.matches(['cashregister', 'Carthorse', 'radishes']);

expect(matches).toEqual(['Carthorse']);
});

xit("does not detect a word as its own anagram",function() {
var detector = new Anagram("banana");
var matches = detector.match(['Banana']);
var subject = anagram("banana");
var matches = subject.matches(['Banana']);

expect(matches).toEqual([]);
});

xit("matches() accepts string arguments",function() {
var subject = anagram("ant");
var matches = subject.matches("stand", "tan", "at");

expect(matches).toEqual(["tan"]);
});

});
50 changes: 23 additions & 27 deletions anagram/example.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,30 @@
(function() {
'use strict';
"use strict";
module.exports = anagram;

function Anagram(word) {
this.word = word.toLowerCase();
}

Anagram.prototype.match = function(words) {
var matches = [];

for(var i = 0; i < words.length; i++) {
var currentWord = words[i];
function anagram(word) {
return {
// public API
matches: matches.bind(this, word)
};
}

if (currentWord.length == this.word.length && currentWord.toLowerCase() != this.word) {
var currentWordLetters = currentWord.toLowerCase().split('').sort();
var matchingWordLetters = this.word.split('').sort();
function matches(word, words) {
words = Array.isArray(words) ? words : [].slice.call(arguments, 1);

var isMatch = true;
return words.filter(function (candidate) {
return !sameWord(word, candidate) && isAnagram(word, candidate);
});
}

for (var j = 0; j < currentWordLetters.length; j++) {
if (currentWordLetters[j] != matchingWordLetters[j]) {
isMatch = false;
}
}
function sameWord(word, candidate) {
return word.toLowerCase() === candidate.toLowerCase();
}

if (isMatch) { matches.push(currentWord); }
}
function isAnagram(word, candiate) {
return normalize(word) === normalize(candiate);
}

}
return matches;
};
function normalize(string) {
return string.toLowerCase().split("").sort().toString();
}

module.exports = Anagram;
})();
2 changes: 0 additions & 2 deletions assignments/javascript/.gitignore

This file was deleted.

12 changes: 4 additions & 8 deletions beer-song/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
var str = "";

if (number === 0) {
str = "no more bottles";
str = "No more bottles";
} else if (number === 1) {
str = "1 bottle";
} else {
Expand All @@ -29,7 +29,7 @@
}

function next_bottle(current_verse) {
return bottles(next_verse(current_verse)) + " of beer on the wall.\n";
return bottles(next_verse(current_verse)).toLowerCase() + " of beer on the wall.\n";
}

function next_verse(current_verse) {
Expand All @@ -53,15 +53,11 @@
};

exports.verse = function(number) {
var line1 = bottles(number).capitalize() + " of beer on the wall, ";
var line2 = bottles(number) + " of beer.\n";
var line1 = bottles(number) + " of beer on the wall, ";
var line2 = bottles(number).toLowerCase() + " of beer.\n";
var line3 = action(number);
var line4 = next_bottle(number);

return [line1, line2, line3, line4].join("");
};

String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
};
})();
Binary file added bin/configlet-darwin-386
Binary file not shown.
Binary file added bin/configlet-darwin-amd64
Binary file not shown.
Binary file added bin/configlet-linux-386
Binary file not shown.
Binary file added bin/configlet-linux-amd64
Binary file not shown.
Binary file added bin/configlet-windows-386.exe
Binary file not shown.
Binary file added bin/configlet-windows-amd64.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion bob/bob_test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe("Bob", function() {
});

xit("calmly speaking about umlauts", function() {
var result = bob.hey("\xdcML\xe4\xdcTS!");
var result = bob.hey("\xdcML\xe4\xdcTS");
expect(result).toEqual('Whatever.');
});

Expand Down
28 changes: 28 additions & 0 deletions bracket-push/bracket-push_test.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
var bracket = require('./bracket-push');

describe("bracketPush()", function() {
it("checks for appropriate bracketing in a set of brackets", function() {
expect(bracketPush("{}")).toEqual(true);
});

xit("returns false for unclosed brackets", function() {
expect(bracketPush("{{")).toEqual(false);
});

xit("checks bracketing in more than one pair of brackets", function() {
expect(bracketPush("{}[]")).toEqual(true);
});

xit("checks bracketing in nested brackets", function() {
expect(bracketPush("{[]}")).toEqual(true);
});

xit("checks bracket closure with deeper nesting", function() {
expect(bracketPush("{[)][]}")).toEqual(false);
});

xit("checks bracket closure in a long string of brackets", function() {
expect(bracketPush("{[]([()])}")).toEqual(true);
});

});
Loading