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

Adding more security guidelines to help people find the answer #1

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
856a873
Rename README to README.md
mindyor Oct 14, 2015
2efc0b5
Merge pull request #2 from mindyor/patch-2
mebartle Oct 14, 2015
43ccc85
Merge pull request #1 from rosatolen/master
mebartle Oct 14, 2015
449c0ec
Molly - updating readmen
Oct 14, 2015
44c093e
Actually format README.md to be prettier
mindyor Oct 14, 2015
0706138
Merge pull request #3 from mindyor/patch-3
mebartle Oct 14, 2015
bdfab60
format README.md minesweeper grids
mindyor Oct 14, 2015
7f990d8
Merge pull request #4 from mindyor/patch-4
mebartle Oct 14, 2015
8827240
Molly - updating more tests
Oct 14, 2015
8a0bc95
Molly - adding more tests and default start return for javascript; up…
Oct 14, 2015
f92e7f5
Add ouput for tests
Oct 14, 2015
05b5806
Merge pull request #5 from mariagomez/master
mebartle Oct 14, 2015
c70702a
Adding rspec test for same arrays to test equality of empty arrays - …
emccallum Oct 14, 2015
538ab84
Molly - adding two failing ruby tests
Oct 14, 2015
e5ba625
Molly - adding ruby tests, README, gitignore
Oct 14, 2015
cf609e9
Alexandra/Emily - add failing test for ruby fibonacci
Oct 14, 2015
e6bbd94
Merge remote-tracking branch 'upstream/master'
emccallum Oct 14, 2015
b91442c
Emily | removing rbenv file that was accidentally checked in
Oct 14, 2015
014981c
Merge pull request #7 from emirose/master
mebartle Oct 14, 2015
fb098a5
Merge pull request #6 from emccallum/master
mebartle Oct 14, 2015
f86118a
Molly - updating the minesweeper test
Oct 14, 2015
9aa6e46
[china] formatting same arrays info in README
chinaowl Oct 14, 2015
d27cefb
Merge pull request #8 from chinaowl/master
mebartle Oct 14, 2015
4d7c2b6
add ruby setup commands to README.md
mindyor Oct 14, 2015
efe6284
Merge pull request #10 from mindyor/patch-5
mebartle Oct 14, 2015
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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
# Remove python virtualenv
security/log-me-in/env
java/build/
java/.gradle/
.idea
.gradle
javascript/node_modules
**/*.iml
35 changes: 23 additions & 12 deletions README → README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
# Grace Hopper Coding Katas

## The katas are organized by language
## Each of the languages will have the same katas
The katas are organized by language

Each of the languages will have the same katas

# Java

## You will need gradle and Java 8 installed for these katas
## Run tests
### gradle test
You will need gradle and Java 8 installed for these katas

Run tests: ``` gradle test ```

See all gradle tasks: ``` gradle tasks ```

# JavaScript

## You will need gulp and node installed for these katas
## Run tests
### gulp test
You will need gulp and node installed for these katas

Run tests: ``` gulp test ```

See all gulp tasks: ``` gulp help ```

# ruby

## You will need ruby and bundle installed for these katas
## run tests
## ruby test.rb
You will need ruby and bundle (```gem install bundler```) installed for these katas

``` bundle install```

run tests: ``` rake all_tests```

# Minesweeper Kata
A field of N x M squares is represented by N lines of
Expand All @@ -28,20 +35,24 @@ a mine and the character '.' represents no-mine.

Example input (a 4 x 3 mine-field of 12 squares, 2 of
which are mines)
```
4 3
*...
..*.
....
```

Your task is to write a program to accept this input and
produce as output a hint-field of identical dimensions
where each square is a * for a mine or the number of
adjacent mine-squares if the square does not contain a mine.

Example output (for the above input)
```
*211
12*1
0111
```

# Same Arrays Kata
Given two arrays, the purpose of this Kata is to check if these two arrays are the same. "The same" in this Kata means the two arrays contains arrays of 2 numbers which are same and not necessarily sorted the same way. i.e. [[2,5], [3,6]] is same as [[5,2], [3,6]] or [[6,3], [5,2]] or [[6,3], [2,5]] etc
Expand All @@ -53,4 +64,4 @@ Two empty arrays [] are the same
An array can be empty or contain a minimun of one array of 2 integers and up to 100 array of 2 integers
Note:
1. [[]] is not applicable because if the array of array are to contain anything, there have to be two numbers.
2. 100 randomly generated tests that can contains either "same" or "not same" arrays.
2. 100 randomly generated tests that can contains either "same" or "not same" arrays.
14 changes: 9 additions & 5 deletions java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repositories {
dependencies {
compile 'org.slf4j:slf4j-api:1.7.7'
testCompile "junit:junit:4.11"
testCompile "org.mockito:mockito-core:1.9.5"
testCompile "org.mockito:mockito-core:1.9.5"
}

sourceCompatibility = 1.8
Expand All @@ -20,14 +20,18 @@ task wrapper(type: Wrapper) {

test {
include '**Test*'

testLogging.showStandardStreams = true

testLogging {
showStandardStreams = true
events "passed", "skipped", "failed"
}

beforeTest { descriptor ->
logger.lifecycle("Running test: " + descriptor)
}

onOutput { descriptor, event ->
logger.lifecycle("Test: " + descriptor + " produced standard out/err: " + event.message )
}
}

}
2 changes: 1 addition & 1 deletion java/src/main/java/Minesweeper.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ public Minesweeper(String map) {
}

public String solve() {
return null;
return "*";
}
}
61 changes: 50 additions & 11 deletions java/src/test/java/FibonacciTest.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,57 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.Ignore;
import static org.junit.Assert.assertEquals;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.assertEquals;

@Ignore
public class FibonacciTest {

@Ignore
@Test
public void shouldReturnAnArrayWithTheListOfNumbersInThatSequence() {
Fibonacci fibonacci = new Fibonacci();
ArrayList<Integer> sequence = fibonacci.forNumber(5);
assertEquals(Integer.valueOf(1), sequence.get(0));
}
@Test
public void shouldReturnAnEmptyArrayForZero() {
Fibonacci fibonacci = new Fibonacci();
ArrayList<Integer> sequence = fibonacci.forNumber(0);
assertEquals(0, sequence.size());
}

@Test
public void shouldReturnAnArrayOfOne() {
Fibonacci fibonacci = new Fibonacci();
ArrayList<Integer> sequence = fibonacci.forNumber(1);
assertEquals(1, sequence.size());
assertEquals(Integer.valueOf(1), sequence.get(0));
}

@Test
public void shouldReturnAnArrayWithTheFirst3Numbers() {
Fibonacci fibonacci = new Fibonacci();
ArrayList<Integer> sequence = fibonacci.forNumber(3);
assertEquals(Integer.valueOf(1), sequence.get(0));
assertEquals(Integer.valueOf(1), sequence.get(1));
assertEquals(Integer.valueOf(2), sequence.get(2));
}

@Test
public void shouldReturnAnArrayWithTheFirstFiveNumbers() {
Fibonacci fibonacci = new Fibonacci();
ArrayList<Integer> sequence = fibonacci.forNumber(5);
assertEquals(Integer.valueOf(1), sequence.get(0));
assertEquals(Integer.valueOf(1), sequence.get(1));
assertEquals(Integer.valueOf(2), sequence.get(2));
assertEquals(Integer.valueOf(3), sequence.get(3));
assertEquals(Integer.valueOf(5), sequence.get(4));
}

@Test
public void shouldReturnAnArrayWithTheListOfTheFirstTenNumbers() {
Fibonacci fibonacci = new Fibonacci();
ArrayList<Integer> sequence = fibonacci.forNumber(10);
assertEquals(10, sequence.size());
assertEquals(Integer.valueOf(1), sequence.get(0));
assertEquals(Integer.valueOf(1), sequence.get(1));
assertEquals(Integer.valueOf(2), sequence.get(2));
assertEquals(Integer.valueOf(3), sequence.get(3));
assertEquals(Integer.valueOf(5), sequence.get(4));
}
}
62 changes: 56 additions & 6 deletions java/src/test/java/MinesweeperTest.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,64 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.Ignore;

import java.util.InputMismatchException;

import static org.junit.Assert.assertEquals;

public class MinesweeperTest {

@Ignore
@Test
public void shouldReturnTrueWhenCheckingTwoEmptyArrays() {
Minesweeper arrayTester = new Minesweeper("*..");
assertEquals("*10", arrayTester.solve());
}
@Test
public void shouldReturnMapWithOneMine() {
Minesweeper arrayTester = new Minesweeper("*..");
assertEquals("*", arrayTester.solve());
}

@Ignore
@Test
public void shouldReturnMapWithOneMineAndIndicatingTheAdjacentSpace() {
Minesweeper arrayTester = new Minesweeper("*.");
assertEquals("*1", arrayTester.solve());
}

@Ignore
@Test
public void shouldReturnMapWithOneMineAndOneAdjacentAndOneNotNearMines() {
Minesweeper arrayTester = new Minesweeper("*..");
assertEquals("*10", arrayTester.solve());
}

@Ignore
@Test
public void shouldReturnMapWithTwoLinesAndOneMine() {
Minesweeper arrayTester = new Minesweeper("*..\n...");
assertEquals("*10\n110", arrayTester.solve());
}

@Ignore
@Test
public void shouldReturnMapWithTwoLinesAndMultipleMines() {
Minesweeper arrayTester = new Minesweeper("*..\n.*.");
assertEquals("*21\n221", arrayTester.solve());
}

@Ignore
@Test
public void shouldReturnMapWithThreeLines() {
Minesweeper arrayTester = new Minesweeper("*..\n..*\n...");
assertEquals("*11\n121\n011", arrayTester.solve());
}

@Ignore
@Test(expected = InputMismatchException.class)
public void shouldThrowAnExceptionForInvalidInput() {
new Minesweeper("jibberish");
}

@Ignore
@Test
public void shouldReturnAMapWithUnevenLines() {
Minesweeper arrayTester = new Minesweeper("*..**\n..*\n........*");
assertEquals("*12**\n12*\n01221001*", arrayTester.solve());
}
}
2 changes: 1 addition & 1 deletion javascript/src/main/fibonacci.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
fibonacci = function(initial_string) {
return [];
return [1, 1, 2];
}
2 changes: 1 addition & 1 deletion javascript/src/main/minesweeper.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
minesweeper = function(initial_string) {
return "";
return "*";
}
2 changes: 1 addition & 1 deletion javascript/src/main/sameArrays.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
sameArrays = function(initial_string) {
return "";
return true;
}
14 changes: 11 additions & 3 deletions javascript/src/test/fibonacci.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ require('../main/fibonacci.js');
var expect = require('chai').expect;

describe("should solve same arrays", function() {
it("should return the first five numbers in the fibonacci sequence", function(){
expect(fibonacci(5)).to.eql([1, 1, 2, 3, 5]);
});
it("should return the first three numbers in the fibonacci sequence by default", function(){
expect(fibonacci()).to.eql([1, 1, 2]);
});

xit("should return the first five numbers in the fibonacci sequence", function(){
expect(fibonacci(5)).to.eql([1, 1, 2, 3, 5]);
});

xit("should return the first ten numbers in the fibonacci sequence", function(){
expect(fibonacci(5)).to.eql([1, 1, 2, 3, 5, 8, 13, 21, 34, 55]);
});
});
30 changes: 19 additions & 11 deletions javascript/src/test/minesweeper.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,23 @@ require('../main/minesweeper.js');
var expect = require('chai').expect;

xdescribe("should solve minesweeper", function() {
it("should return string with mine and one", function(){
expect(minesweeper("*.")).toBe("*1");
});

it("should return string with one and zero", function(){
expect(minesweeper("*..")).toBe("*10");
});

it("should return string with two lines and two mines", function(){
expect(minesweeper("*..\n..*")).toBe("*11\n12*");
});
it("should return string with a mine", function(){
expect(minesweeper("*")).to.eql("*");
});

xit("should return string with mine and one", function(){
expect(minesweeper("*.")).to.eql("*1");
});

xit("should return string with one and zero", function(){
expect(minesweeper("*..")).to.eql("*10");
});

xit("should return string with one and zero", function(){
expect(minesweeper("*...*")).to.eql("*101*");
});

xit("should return string with two lines and two mines", function(){
expect(minesweeper("*..\n..*")).to.eql("*11\n12*");
});
});
34 changes: 27 additions & 7 deletions javascript/src/test/sameArrays.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,31 @@ require('../main/sameArrays.js');
var expect = require('chai').expect;

xdescribe("should solve same arrays", function() {
it("should return true for two empty arrays", function(){
expect(sameArrays([], [])).toBeTruthy();
});

it("should return false for two arrays with different numbers", function(){
expect(sameArrays([2], [5])).toBeFalsy();
});
it("should return true for two empty arrays", function(){
expect(sameArrays([], [])).to.be.true;
});

it("should return false for two arrays with different numbers", function(){
expect(sameArrays([2], [5])).to.be.false;
});

it("should return false for two arrays with different amounts", function(){
expect(sameArrays([2], [2, 6])).to.be.false;
});

it("should return false for two arrays with multiple different numbers", function(){
expect(sameArrays([2, 4], [2, 5])).to.be.false;
});

it("should return true for two nested arrays with the same numbers", function(){
expect(sameArrays([[3], [4]], [[3], [4]])).to.be.true;
});

it("should return false for two nested arrays with multiple different numbers", function(){
expect(sameArrays([[2], [4]], [[2], [5]])).to.be.false;
});

it("should not return true or false based on just the last element in the arrays", function(){
expect(sameArrays([[2], [4]], [[2], [5]])).to.be.false;
});
});
5 changes: 5 additions & 0 deletions ruby/spec/examples.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
example_id | status | run_time |
------------------------------- | ------ | --------------- |
./spec/fibonacci_spec.rb[1:1] | failed | 0.00006 seconds |
./spec/minesweeper_spec.rb[1:1] | failed | 0.00006 seconds |
./spec/same_arrays_spec.rb[1:1] | failed | 0.00012 seconds |
7 changes: 7 additions & 0 deletions ruby/spec/fibonacci_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require_relative "../src/fibonacci"

RSpec.describe "fibonacci" do
it "should return the first five numbers in the fibonacci sequence" do
expect(Fibonacci.new.for_number(5)).to eq([1, 1, 2, 3, 5])
end
end
Loading