jeka 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/Gemfile.lock +55 -2
- data/README.rdoc +6 -14
- data/VERSION +1 -1
- data/bin/jeka +64 -94
- data/jeka.gemspec +56 -28
- data/lib/jeka.rb +6 -4
- data/lib/jeka/algorithm.rb +106 -24
- data/lib/jeka/analysis.rb +15 -0
- data/lib/jeka/analysis/algorithm.rb +13 -0
- data/lib/jeka/analysis/compiler.rb +14 -0
- data/lib/jeka/analysis/compiler_option.rb +24 -0
- data/lib/jeka/analysis/database.rb +11 -0
- data/lib/jeka/analysis/implementation.rb +15 -0
- data/lib/jeka/analysis/implementation_information.rb +24 -0
- data/lib/jeka/analysis/result.rb +20 -0
- data/lib/jeka/analysis/source_file.rb +24 -0
- data/lib/jeka/analysis/test.rb +15 -0
- data/lib/jeka/analysis/test_case.rb +13 -0
- data/lib/jeka/compilers.rb +3 -0
- data/lib/jeka/compilers/compiler.rb +48 -0
- data/lib/jeka/compilers/gpp.rb +29 -0
- data/lib/jeka/compilers/ruby.rb +21 -0
- data/lib/jeka/console.rb +55 -0
- data/lib/jeka/implementation.rb +22 -97
- data/lib/jeka/test.rb +15 -31
- data/lib/jeka/test_case.rb +41 -0
- data/test/bubble_sort/_tests/_test_01.rb +13 -0
- data/test/bubble_sort/algorithm_bubble_sort.rb +15 -0
- data/test/bubble_sort/cpp/_implementation.yaml +3 -0
- data/test/{example/01_bubble_sort/cpp/bubble.cpp → bubble_sort/cpp/bubble_sort.cpp} +9 -10
- data/test/bubble_sort/ruby/_implementation.yaml +3 -0
- data/test/{example/01_bubble_sort/ruby/bubble.rb → bubble_sort/ruby/bubble_sort.rb} +2 -5
- data/test/double/_tests/_test_01.rb +13 -0
- data/test/double/algorithm_double.rb +15 -0
- data/test/double/cpp/double.cpp +10 -0
- data/test/double/ruby/double.rb +2 -0
- data/test/test_algorithm.rb +25 -11
- data/test/test_gpp.rb +29 -0
- data/test/test_implementation.rb +25 -10
- data/test/test_test_case.rb +21 -0
- metadata +94 -52
- data/lib/jeka/jeka_helper.rb +0 -16
- data/lib/jeka/make.rb +0 -103
- data/test/example/01_bubble_sort/_algorithm.yaml +0 -12
- data/test/example/01_bubble_sort/_description.textile +0 -1
- data/test/example/01_bubble_sort/_references.textile +0 -1
- data/test/example/01_bubble_sort/_tests/test_01.yaml +0 -3
- data/test/example/01_bubble_sort/_tests/test_02.yaml +0 -3
- data/test/example/01_bubble_sort/cpp/_implementation.yaml +0 -9
- data/test/example/01_bubble_sort/ruby/_implementation.yaml +0 -6
- data/test/site/algorithm.textile +0 -27
- data/test/site/cpp.textile +0 -46
- data/test/site/ruby.textile +0 -28
- data/test/test_make.rb +0 -34
- data/test/test_test.rb +0 -16
@@ -1 +0,0 @@
|
|
1
|
-
Bubble sort, also known as sinking sort, is a simple sorting algorithm that works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted. The algorithm gets its name from the way smaller elements "bubble" to the top of the list. Because it only uses comparisons to operate on elements, it is a comparison sort. The equally simple insertion sort has better performance than bubble sort, so some have suggested no longer teaching the bubble sort.
|
@@ -1 +0,0 @@
|
|
1
|
-
http://en.wikipedia.org/wiki/Bubble_sort
|
data/test/site/algorithm.textile
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
---
|
2
|
-
layout: algorithm
|
3
|
-
title: Bubble Sort
|
4
|
-
---
|
5
|
-
|
6
|
-
h1. Bubble Sort
|
7
|
-
|
8
|
-
h2. Sorting
|
9
|
-
|
10
|
-
h3. Descrição
|
11
|
-
|
12
|
-
Bubble sort, also known as sinking sort, is a simple sorting algorithm that works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted. The algorithm gets its name from the way smaller elements "bubble" to the top of the list. Because it only uses comparisons to operate on elements, it is a comparison sort. The equally simple insertion sort has better performance than bubble sort, so some have suggested no longer teaching the bubble sort.
|
13
|
-
|
14
|
-
h3. Complexidade
|
15
|
-
|
16
|
-
O(n^2)
|
17
|
-
|
18
|
-
h3. Referências
|
19
|
-
|
20
|
-
http://en.wikipedia.org/wiki/Bubble_sort
|
21
|
-
|
22
|
-
h3. Implementações
|
23
|
-
|
24
|
-
|_. Linguagem |_. Comentário |_. Código fonte |_. Tempo de execução médio |
|
25
|
-
| c++ | Implementação simples em C++ | "ver":../../../../implementations/2011/01/01/Implementa%C3%A7%C3%A3o_simples_em_C++.html | 0.003s |
|
26
|
-
| ruby | Implementação simples em Ruby | "ver":../../../../implementations/2011/01/01/Implementa%C3%A7%C3%A3o_simples_em_Ruby.html | 0.006500000000000001s |
|
27
|
-
|
data/test/site/cpp.textile
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
---
|
2
|
-
layout: implementation
|
3
|
-
title: Bubble Sort
|
4
|
-
---
|
5
|
-
|
6
|
-
{% highlight ruby %}
|
7
|
-
#include <iostream>
|
8
|
-
#include <vector>
|
9
|
-
#include <stdlib.h>
|
10
|
-
|
11
|
-
using namespace std;
|
12
|
-
|
13
|
-
vector<int> bubble_sort(vector<int> numbers) {
|
14
|
-
for(int i = 0; i < 9; i++) {
|
15
|
-
for(int j = i; j < 9; j++) {
|
16
|
-
if (numbers[i] > numbers[j]) {
|
17
|
-
int temp = numbers[i];
|
18
|
-
numbers[i] = numbers[j];
|
19
|
-
numbers[j] = temp;
|
20
|
-
}
|
21
|
-
}
|
22
|
-
}
|
23
|
-
return numbers;
|
24
|
-
}
|
25
|
-
|
26
|
-
int main() {
|
27
|
-
vector<int> numbers;
|
28
|
-
int max, v;
|
29
|
-
|
30
|
-
// Reading the input
|
31
|
-
cin >> max;
|
32
|
-
for (int i = 0; i < max; i++) {
|
33
|
-
cin >> v;
|
34
|
-
numbers.push_back(v);
|
35
|
-
}
|
36
|
-
|
37
|
-
numbers = bubble_sort(numbers);
|
38
|
-
|
39
|
-
// Printing the output
|
40
|
-
for (int i=0; i< 8; i++)
|
41
|
-
cout << numbers[i] << " ";
|
42
|
-
cout << numbers[8] << endl;
|
43
|
-
|
44
|
-
return 0;
|
45
|
-
}
|
46
|
-
{% endhighlight %}
|
data/test/site/ruby.textile
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
---
|
2
|
-
layout: implementation
|
3
|
-
title: Bubble Sort
|
4
|
-
---
|
5
|
-
|
6
|
-
{% highlight ruby %}
|
7
|
-
def bubble(numbers)
|
8
|
-
for i in (0..numbers.size-1)
|
9
|
-
for j in (i..numbers.size-1)
|
10
|
-
if numbers[i] > numbers[j]
|
11
|
-
temp = numbers[i]
|
12
|
-
numbers[i] = numbers[j]
|
13
|
-
numbers[j] = temp
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
numbers
|
18
|
-
end
|
19
|
-
|
20
|
-
# Reading the input
|
21
|
-
input = gets
|
22
|
-
input = input.split(' ')[1..-1].map {|c| c.to_i }
|
23
|
-
|
24
|
-
bubble(input)
|
25
|
-
|
26
|
-
# Printing the output
|
27
|
-
puts input.inject {|output, n| "#{output} #{n}"}
|
28
|
-
{% endhighlight %}
|
data/test/test_make.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
class TestMake < Test::Unit::TestCase
|
4
|
-
|
5
|
-
context "The example" do
|
6
|
-
|
7
|
-
should "pass all the tests" do
|
8
|
-
make = Jeka::Make.new(File.join(File.dirname(__FILE__), "example", "01_bubble_sort"))
|
9
|
-
make.build
|
10
|
-
make.test do |i, t, r|
|
11
|
-
assert r
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
should "generate the web pages" do
|
16
|
-
falgorithm = File.new(File.join(File.dirname(__FILE__), "site", "algorithm.textile"), "r")
|
17
|
-
falgorithm = falgorithm.readlines.join()
|
18
|
-
falgorithm = falgorithm.gsub(/(\d)*\.(\d)*s/, "*")
|
19
|
-
fcpp = File.new(File.join(File.dirname(__FILE__), "site", "cpp.textile"), "r")
|
20
|
-
fcpp = fcpp.readlines.join()
|
21
|
-
fruby = File.new(File.join(File.dirname(__FILE__), "site", "ruby.textile"), "r")
|
22
|
-
fruby = fruby.readlines.join()
|
23
|
-
make = Jeka::Make.new(File.join(File.dirname(__FILE__), "example", "01_bubble_sort"))
|
24
|
-
make.build
|
25
|
-
make.benchmark(1)
|
26
|
-
algorithm, implementations = make.generate_site
|
27
|
-
assert_equal falgorithm, algorithm[1].gsub(/(\d)*\.(\d)*s/, "*")
|
28
|
-
assert_equal fruby, implementations[0][1]
|
29
|
-
assert_equal fcpp, implementations[1][1]
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
data/test/test_test.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
class TestTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
context "The example" do
|
6
|
-
|
7
|
-
should "open the bubble sort tests" do
|
8
|
-
test = Jeka::Test.new(File.join(File.dirname(__FILE__), "example", "01_bubble_sort", "_tests", "test_01.yaml"))
|
9
|
-
assert_equal test.name, "Sequencia decrescente"
|
10
|
-
assert_equal test.input, "9 9 8 7 6 5 4 3 2 1"
|
11
|
-
assert_equal test.output, "1 2 3 4 5 6 7 8 9"
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|