Skip to content

Commit 1949d91

Browse files
committed
Remove author signature
1 parent 2e8d4f0 commit 1949d91

14 files changed

+17
-98
lines changed

src/swift/binarySearch.swift

-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
//
2-
// binarySearch.swift
3-
//
4-
//
5-
// Written by Roberto Martins on 07/10/2023
6-
// Based on the C code presented in the Portuguese Wikipedia article for Binary Search
7-
81
func binarySearch(array: [Int], searchedElement: Int) -> Int {
92
var firstIndex: Int = 0
103
var lastIndex: Int = array.count - 1

src/swift/calculatePi.swift

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
1-
//
2-
// calculatePi.swift
3-
//
4-
//
5-
// Created by Matheus Torres on 14/11/20.
6-
//
7-
81
func calculatePi(_ number: Int) -> Float {
92
var denominator: Float = 1
103
var operation: Float = 1
114
var pi: Float = 0
12-
5+
136
for _ in 0..<number {
147
pi += operation * (4 / denominator)
158
denominator += 2
169
operation *= -1
1710
}
18-
11+
1912
return pi
2013
}
2114

src/swift/deque.swift

+6-13
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,26 @@
1-
//
2-
// deque.swift
3-
//
4-
//
5-
// Created by Matheus Torres on 14/11/20.
6-
//
7-
81
class Deque {
92
var deque: [Int] = []
10-
3+
114
func addAtBeginning(_ value: Int) {
125
deque.insert(value, at: 0)
136
}
14-
7+
158
func addAtEnd(_ value: Int) {
169
deque.append(value)
1710
}
18-
11+
1912
func removeAtBeggining() {
2013
deque.removeFirst()
2114
}
22-
15+
2316
func removeAtEnd() {
2417
deque.removeLast()
2518
}
26-
19+
2720
func read() {
2821
print(deque)
2922
}
30-
23+
3124
func readReverse() {
3225
print(Array(deque.reversed()))
3326
}

src/swift/exponentiation.swift

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/* exponentiation.swift
2-
Written by Roberto Martins on 10/10/2023
3-
*/
4-
51
func exponentiation<Number: Numeric>(base: Number, power: Int) -> Number {
62
var result = base
73
if power == 0 {
@@ -19,4 +15,4 @@ func main() {
1915
print(exponentiation(base: 50, power: 0))
2016
}
2117

22-
main()
18+
main()

src/swift/exponentiationRecursive.swift

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/* recursiveExponentiation.swift
2-
Written by Roberto Martins on 10/10/2023
3-
*/
4-
51
func recursiveExponentiation<Number: Numeric>(base: Number, power: Int) -> Number {
62
if (power == 0) {
73
return 1
@@ -15,4 +11,4 @@ func main() {
1511
print(recursiveExponentiation(base: 50, power: 0))
1612
}
1713

18-
main()
14+
main()

src/swift/factorial.swift

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
//
2-
// factorial.swift
3-
//
4-
// Created by Matheus Torres on 13/11/20.
5-
//
6-
71
func factorial(_ number: Int) -> Int {
82
var result: Int = 1
93
for index in (1...number).reversed() {

src/swift/factorialRecursive.swift

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
//
2-
// factorial.swift
3-
//
4-
// Created by Matheus Torres on 13/11/20.
5-
//
6-
71
func factorial(_ number: Int) -> Int {
82
if number <= 1 { return 1 }
93
return number * factorial(number - 1)

src/swift/insertionSort.swift

-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
//
2-
// insertionSort.swift
3-
//
4-
//
5-
// Created by Matheus Torres on 14/11/20.
6-
//
7-
81
func insertionSort(_ array: [Int]) -> [Int] {
92
var newArray: [Int] = array
103
for i in 1..<newArray.count {

src/swift/linearSearch.swift

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/* sequentialSearch.swift
2-
Written by Roberto Martins on 07/10/2023
3-
*/
4-
51
func sequentialSearch(array: [Int], searchedElement: Int) -> Int {
62
for index in 0..<array.count {
73
if array[index] == searchedElement {

src/swift/palindrome.swift

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
//
2-
// palindromo.swift
3-
//
4-
// Created by Matheus Torres on 14/11/20.
5-
//
6-
71
import Foundation
82

93
func isPalindrome(_ string: String) -> Bool {

src/swift/queue.swift

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
1-
//
2-
// fila.swift
3-
//
4-
// Created by Matheus Torres on 14/11/20.
5-
//
6-
71
class Queue {
82
var queue: [Int] = []
9-
3+
104
func enqueue(_ value: Int) {
115
self.queue.append(value)
126
}
13-
7+
148
func dequeue() {
159
self.queue.removeFirst()
1610
}
17-
11+
1812
func show() {
1913
print(self.queue)
2014
}
21-
15+
2216
func clear() {
2317
self.queue = []
2418
}

src/swift/singlyLinkedList.swift

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
/* singlyLinkedList.swift
2-
Written by Roberto Martins on 09/10/2023
3-
*/
4-
5-
// Type: Equatable makes it so that you can have Nodes of any type and their values can be compared
1+
// Type: Equatable makes it so that you can have Nodes of any type and their values can be compared
62
// Use of generic "Type" makes it so you can have a Linked List of any type
73
class Node<Type: Equatable>
84
{
@@ -51,7 +47,7 @@ class LinkedList<Type: Equatable> {
5147
currentNode = currentNode!.next
5248
}
5349
}
54-
50+
5551
func remove(value: Type) {
5652
var currentNode = self.head
5753
var previousNode: Node<Type>? = nil
@@ -116,4 +112,4 @@ func main() {
116112
stringsLinkedList.printList()
117113
}
118114

119-
main()
115+
main()

src/swift/stack.swift

-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
//
2-
// stack.swift
3-
//
4-
//
5-
// Created by Matheus Torres on 14/11/20.
6-
//
7-
81
class Stack {
92
var stack: [Int] = []
103

src/swift/towerOfHanoi.swift

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
//
2-
// hanoi.swift
3-
//
4-
// Created by Matheus Torres on 13/11/20.
5-
//
6-
71
func hanoi(_ p1: Int, _ p2: Int, _ p3: Int, disks: Int) {
82
if disks == 1 {
93
print("Move de \(p1) para \(p2)")

0 commit comments

Comments
 (0)