Skip to content

Commit 359a7b3

Browse files
authored
Merge branch 'master' into euclid_asm
2 parents da41db5 + ebc4caf commit 359a7b3

File tree

31 files changed

+697
-176
lines changed

31 files changed

+697
-176
lines changed

.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,13 @@ indent_size = 2
109109
[*.rs]
110110
indent_style = space
111111
indent_size = 4
112+
113+
# Emojicode
114+
[*.emojic]
115+
indent_style = space
116+
indent_size = 2
117+
118+
# PHP
119+
[*.php]
120+
indent_style = space
121+
indent_size = 4

.travis.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ script:
1818

1919
after_success:
2020
- |
21-
if [[ "${TRAVIS_BRANCH}" == master && "${TRAVIS_PULL_REQUEST}" == false ]]; then
22-
# Commits to master that are not pull requests, that is, only
23-
# actual addition of code to master, should deploy the book to
24-
# the site.
25-
bash "${TRAVIS_BUILD_DIR}"/tools/deploy/update_site_travis.bash
26-
fi
21+
if [[ "${TRAVIS_BRANCH}" == master && "${TRAVIS_PULL_REQUEST}" == false ]]; then
22+
# Commits to master that are not pull requests, that is, only
23+
# actual addition of code to master, should deploy the book to
24+
# the site.
25+
bash "${TRAVIS_BUILD_DIR}"/tools/deploy/update_site_travis.bash
26+
fi

CONTRIBUTING.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# Contributing
22

3-
A contribution guide on how to contribute to the Arcane Algorithm Archive (AAA) can be found on this Wiki page:
4-
https://github.com/algorithm-archivists/algorithm-archive/wiki/How-to-Contribute
3+
A contribution guide on how to contribute to the Arcane Algorithm Archive (AAA) can be found on this Wiki page: https://github.com/algorithm-archivists/algorithm-archive/wiki/How-to-Contribute
54

6-
The community member Buttercak3 also created a video series, explaining the contribution process of the AAA.
7-
You can find a playlist with all videos here:
8-
https://www.youtube.com/playlist?list=PL5NSPcN6fRq2vwgdb9noJacF945CeBk8x
5+
The community member Buttercak3 also created a video series, explaining the contribution process of the AAA. You can find a playlist with all videos here: https://www.youtube.com/playlist?list=PL5NSPcN6fRq2vwgdb9noJacF945CeBk8x

CONTRIBUTORS.md

Lines changed: 34 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -2,67 +2,37 @@ This file lists everyone, who contributed to this repo and wanted to show up her
22

33
# Contributors
44

5-
James Schloss
6-
<br>
7-
Nicole Mazzuca
8-
<br>
9-
Marius Becker
10-
<br>
11-
Gathros
12-
<br>
13-
Jeremie Gillet (- Jie -)
14-
<br>
15-
Salim Khatib
16-
<br>
17-
Hitesh C
18-
<br>
19-
Shaurya
20-
<br>
21-
Maxime Dherbécourt
22-
<br>
23-
Jess 3Jane
24-
<br>
25-
Pen Pal
26-
<br>
27-
Chinmaya Mahesh
28-
<br>
29-
Unlambder
30-
<br>
31-
Kjetil Johannessen
32-
<br>
33-
CDsigma
34-
<br>
35-
Gammison
36-
<br>
37-
hsjoihs
38-
<br>
39-
DominikRafacz
40-
<br>
41-
lulucca12
42-
<br>
43-
GuyPozner
44-
<br>
45-
William Boyles
46-
<br>
47-
Max Weinstein
48-
<br>
49-
Gibus Wearing Brony
50-
<br>
51-
Gorzoid
52-
<br>
53-
Arun Sahadeo
54-
<br>
55-
NIFR91
56-
<br>
57-
Michal Hanajik
58-
<br>
59-
Bendik Samseth
60-
<br>
61-
mukundan314
62-
<br>
63-
Trashtalk
64-
<br>
65-
Cyrus Burt
66-
<br>
67-
Patrik Tesarik
68-
<br>
5+
- James Schloss
6+
- Nicole Mazzuca
7+
- Marius Becker
8+
- Gathros
9+
- Jeremie Gillet (- Jie -)
10+
- Salim Khatib
11+
- Hitesh C
12+
- Shaurya
13+
- Maxime Dherbécourt
14+
- Jess 3Jane
15+
- Pen Pal
16+
- Chinmaya Mahesh
17+
- Unlambder
18+
- Kjetil Johannessen
19+
- CDsigma
20+
- Gammison
21+
- hsjoihs
22+
- DominikRafacz
23+
- lulucca12
24+
- GuyPozner
25+
- William Boyles
26+
- Max Weinstein
27+
- Gibus Wearing Brony
28+
- Gorzoid
29+
- Arun Sahadeo
30+
- NIFR91
31+
- Michal Hanajik
32+
- Bendik Samseth
33+
- mukundan314
34+
- Trashtalk
35+
- Cyrus Burt
36+
- Patrik Tesarik
37+
- Ken Power
38+
- PaddyKe

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2017 James Schloss et. al
1+
Copyright 2018 James Schloss et. al
22

33
Permission is hereby granted, free of charge, to any person
44
obtaining a copy of this software and associated documentation

book.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,20 @@
137137
"name": "Nim"
138138
},
139139
{
140-
"lang": "x64",
140+
"lang": "asm-x64",
141141
"name": "X86-64 Assembly"
142142
},
143143
{
144144
"lang": "f90",
145145
"name": "Fortran90"
146+
},
147+
{
148+
"lang": "scala",
149+
"name": "Scala"
150+
},
151+
{
152+
"lang": "emojic",
153+
"name": "Emojicode"
146154
}
147155
]
148156
}

contents/bitlogic/res/not.jpg

-5.02 KB
Loading

contents/bogo_sort/bogo_sort.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ In code, it looks something like this:
3131
[import:17-20, lang:"haskell"](code/haskell/bogoSort.hs)
3232
{% sample lang="m" %}
3333
[import:21-28, lang:"matlab"](code/matlab/bogosort.m)
34+
{% sample lang="lua" %}
35+
[import:1-22, lang="lua"](code/lua/bogosort.lua)
3436
{% sample lang="cpp" %}
3537
[import:33-38, lang:"c_cpp"](code/c++/bogosort.cpp)
3638
{% sample lang="rs" %}
@@ -43,14 +45,15 @@ In code, it looks something like this:
4345
[import:16-18, lang:"nim"](code/nim/bogo_sort.nim)
4446
{% sample lang="ruby" %}
4547
[import:12-16, lang:"ruby"](code/ruby/bogo.rb)
48+
{% sample lang="f90" %}
49+
[import:24-32, lang:"fortran"](code/fortran/bogo.f90)
4650
{% endmethod %}
4751

4852
That's it.
4953
Ship it!
5054
We are done here!
5155

52-
## Example Code
53-
56+
## Example Code
5457
{% method %}
5558
{% sample lang="jl" %}
5659
[import, lang:"julia"](code/julia/bogo.jl)
@@ -73,6 +76,8 @@ We are done here!
7376
[import, lang:"haskell"](code/haskell/bogoSort.hs)
7477
{% sample lang="m" %}
7578
[import, lang:"matlab"](code/matlab/bogosort.m)
79+
{% sample lang="lua" %}
80+
[import, lang="lua"](code/lua/bogosort.lua)
7681
{% sample lang="cpp" %}
7782
[import, lang:"c_cpp"](code/c++/bogosort.cpp)
7883
{% sample lang="rs" %}
@@ -85,6 +90,8 @@ We are done here!
8590
[import, lang:"nim"](code/nim/bogo_sort.nim)
8691
{% sample lang="ruby" %}
8792
[import, lang:"ruby"](code/ruby/bogo.rb)
93+
{% sample lang="f90" %}
94+
[import, lang:"fortran"](code/fortran/bogo.f90)
8895
{% endmethod %}
8996

9097

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
PROGRAM bogo
2+
IMPLICIT NONE
3+
REAL(8), DIMENSION(5) :: array
4+
5+
array = (/ 1d0, 1d0, 0d0, 3d0, 7d0 /)
6+
7+
CALL bogo_sort(array)
8+
9+
WRITE(*,*) array
10+
11+
contaINs
12+
13+
LOGICAL FUNCTION is_sorted(array)
14+
REAL(8), DIMENSION(:), INTENT(IN) :: array
15+
INTEGER :: i
16+
17+
DO i = 1, SIZE(array)
18+
IF (array(i+1) < array(i)) THEN
19+
is_sorted = .FALSE.
20+
END IF
21+
END DO
22+
END FUNCTION is_sorted
23+
24+
SUBROUTINE bogo_sort(array)
25+
REAL(8), DIMENSION(:), INTENT(INOUT) :: array
26+
27+
DO WHILE (is_sorted(array) .EQV. .FALSE.)
28+
29+
CALL shuffle(array)
30+
31+
END DO
32+
END SUBROUTINE bogo_sort
33+
34+
SUBROUTINE shuffle(array)
35+
REAL(8), DIMENSION(:), INTENT(INOUT) :: array
36+
INTEGER :: i, randpos
37+
REAL(8) :: r, temp
38+
39+
DO i = size(array), 2, -1
40+
CALL RANDOM_NUMBER(r)
41+
randpos = INT(r * i) + 1
42+
temp = array(randpos)
43+
array(randpos) = array(i)
44+
array(i) = temp
45+
END DO
46+
47+
END SUBROUTINE shuffle
48+
END PROGRAM bogo
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
local function shuffle(arr)
2+
for i = 1, #arr-1 do
3+
local rand = math.random(i,#arr)
4+
arr[i], arr[rand] = arr[rand], arr[i]
5+
end
6+
end
7+
8+
local function issorted(arr)
9+
for i = 1,#arr-1 do
10+
if arr[i] > arr[i+1] then
11+
return false
12+
end
13+
end
14+
return true
15+
end
16+
17+
function bogosort(arr)
18+
while not issorted(arr) do
19+
shuffle(arr)
20+
end
21+
end
22+
23+
local arr = {1, 45, 756, 4569, 56, 3, 8, 5, -10, -4}
24+
print(("Unsorted array: {%s}"):format(table.concat(arr,", ")))
25+
26+
bogosort(arr)
27+
28+
print(("Sorted array: {%s}"):format(table.concat(arr,", ")))

contents/bogo_sort/code/ruby/bogo.rb

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,19 @@
11
#!/usr/bin/env ruby
22

33
def is_sorted(a)
4-
for i in 0...a.length-1
5-
if a[i+1] < a[i]
6-
return false
7-
end
8-
end
9-
return true
4+
a.each_cons(2).all? { |(l, r)| l <= r }
105
end
116

127
def bogo_sort(a)
13-
while !is_sorted(a)
14-
a.shuffle!
15-
end
8+
a.shuffle! until is_sorted a
169
end
1710

18-
def main()
19-
a = [1, 1, 0, 3, 7]
20-
21-
puts("Unsorted")
22-
print(a)
23-
24-
bogo_sort(a)
25-
26-
puts("\n\nSorted")
27-
print(a)
28-
end
11+
a = [1, 1, 0, 3, 7]
12+
13+
puts "Unsorted"
14+
p a
2915

30-
main()
16+
bogo_sort a
3117

18+
puts "Sorted"
19+
p a

contents/bubble_sort/bubble_sort.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ This means that we need to go through the vector $$\mathcal{O}(n^2)$$ times with
2222
[import:4-9, lang:"python"](code/python/bubblesort.py)
2323
{% sample lang="m" %}
2424
[import:1-13, lang:"matlab"](code/matlab/bubblesort.m)
25+
{% sample lang="lua" %}
26+
[import:1-9, lang="lua"](code/lua/bubble_sort.lua)
2527
{% sample lang="hs" %}
2628
[import, lang:"haskell"](code/haskell/bubbleSort.hs)
2729
{% sample lang="cpp" %}
@@ -48,8 +50,14 @@ This means that we need to go through the vector $$\mathcal{O}(n^2)$$ times with
4850
[import:3-28, lang:"lisp"](code/lisp/bubble_sort.lisp)
4951
{% sample lang="nim" %}
5052
[import:5-9, lang:"nim"](code/nim/bubble_sort.nim)
53+
{% sample lang="asm-x64" %}
54+
[import:44-110, lang:"asm-x64"](code/asm-x64/bubble_sort.s)
5155
{% sample lang="f90" %}
5256
[import:19-40, lang:"fortran"](code/fortran/bubble.f90)
57+
{% sample lang="scala" %}
58+
[import:3-14, lang:"scala"](code/scala/bubble_sort.scala)
59+
{% sample lang="emojic" %}
60+
[import:2-14, lang:"emojicode"](code/emojicode/bubble_sort.emojic)
5361
{% endmethod %}
5462

5563
... And that's it for the simplest bubble sort method.
@@ -77,6 +85,8 @@ Trust me, there are plenty of more complicated algorithms that do precisely the
7785
[import, lang:"python"](code/python/bubblesort.py)
7886
{% sample lang="m" %}
7987
[import, lang:"matlab"](code/matlab/bubblesort.m)
88+
{% sample lang="lua" %}
89+
[import, lang="lua"](code/lua/bubble_sort.lua)
8090
{% sample lang="hs" %}
8191
[import, lang:"haskell"](code/haskell/bubbleSort.hs)
8292
{% sample lang="cpp" %}
@@ -103,8 +113,14 @@ Trust me, there are plenty of more complicated algorithms that do precisely the
103113
[import, lang:"lisp"](code/lisp/bubble_sort.lisp)
104114
{% sample lang="nim" %}
105115
[import, lang:"nim"](code/nim/bubble_sort.nim)
116+
{% sample lang="asm-x64" %}
117+
[import, lang:"asm-x64"](code/asm-x64/bubble_sort.s)
106118
{% sample lang="f90" %}
107119
[import, lang:"fortran"](code/fortran/bubble.f90)
120+
{% sample lang="scala" %}
121+
[import, lang:"scala"](code/scala/bubble_sort.scala)
122+
{% sample lang="emojic" %}
123+
[import, lang:"emojicode"](code/emojicode/bubble_sort.emojic)
108124
{% endmethod %}
109125

110126
<script>

0 commit comments

Comments
 (0)