forked from TheRenegadeCoder/sample-programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into Visual-Basic-Bubble-Sort
- Loading branch information
Showing
29 changed files
with
473 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,5 @@ __pycache__/ | |
.scratch | ||
# erlang | ||
*.beam | ||
|
||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
MsgBox, 0x30, Sample Programs, Hello, World! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
program fizz_buzz | ||
integer :: i | ||
|
||
do i = 1,100 | ||
if ((modulo(i,3) == 0) .and. (modulo(i,5) == 0)) then | ||
write (*,'(a)') "FizzBuzz" | ||
else if (modulo(i,3) == 0) then | ||
write (*,'(a)') "Fizz" | ||
else if (modulo(i,5) == 0) then | ||
write (*,'(a)') "Buzz" | ||
else | ||
write (*,'(I0)') i | ||
end if | ||
end do | ||
|
||
end program fizz_buzz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
class HelloWorld { | ||
public static void main(String[] args) { | ||
System.out.println("Hello, World!"); | ||
System.out.println("Hello, World!"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
Author : Nameer Waqas | ||
Date: 01/10/2020 | ||
Title: Implementation of Linear search algorithm in JS | ||
Algorithm Big-O = O(n) | ||
*/ | ||
|
||
function LinSearch(arr = [], valToSearch) { | ||
let check = false; | ||
if (arr.length == 0) return check | ||
if(valToSearch==='') return check | ||
else { | ||
for (i = 0; i < arr.length; i++) { | ||
if (arr[i] == valToSearch){ | ||
check = true | ||
return check | ||
} | ||
} | ||
return check | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/julia | ||
|
||
function err() | ||
println("Usage: please input a non-negative integer") | ||
end | ||
|
||
function fac(n) | ||
if n < 0 | ||
err() | ||
exit() | ||
end | ||
|
||
out = 1 | ||
for i = 1:n | ||
out = out * i | ||
end | ||
return out | ||
end | ||
|
||
try | ||
println(fac(parse(Int, ARGS[1]))) | ||
catch e | ||
err() | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/julia | ||
|
||
function SelectionSort(arr) | ||
l = length(arr) | ||
sorted_list = [] | ||
for i = 1:l | ||
m = minimum(arr) | ||
push!(sorted_list,m) | ||
deleteat!(arr, findfirst(x->x==m,arr)) | ||
end | ||
return sorted_list | ||
end | ||
|
||
function error() | ||
println("Usage: please provide a list of at least two integers to sort in the format \"1, 2, 3, 4, 5\"") | ||
end | ||
|
||
function HandleInput(inp) | ||
|
||
a = split(inp,",") | ||
a = map(x->split(x," "),a) | ||
a = map(x->last(x),a) | ||
numbers = map(x->parse(Int,x),a) | ||
if length(numbers) == 1 | ||
error() | ||
exit() | ||
end | ||
return numbers | ||
|
||
end | ||
|
||
function PrintOutput(out) | ||
for i = 1:length(out) | ||
print(out[i]) | ||
if i != length(out) | ||
print(", ") | ||
end | ||
end | ||
println() | ||
end | ||
|
||
try | ||
|
||
n = HandleInput(ARGS[1]) | ||
sorted = SelectionSort(n) | ||
PrintOutput(sorted) | ||
|
||
catch e | ||
error() | ||
end | ||
|
||
|
Oops, something went wrong.