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
fun leet(text: String): String{ | |
val characters = text.uppercase().toCharArray() | |
for(i in 0..characters.size - 1){ | |
when(characters[i]){ | |
'E' -> characters[i] = '3' | |
'L' -> characters[i] = '1' | |
'O' -> characters[i] = '0' | |
'S' -> characters[i] = '5' | |
'T' -> characters[i] = '7' | |
'A' -> characters[i] = '4' |
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
fun sumOfFactors(ac: Int, b: Int): Pair<Int,Int>?{ | |
for(divisor in 1..ac){ | |
if(ac % divisor == 0){ | |
val factor = ac / divisor | |
if(factor + divisor == b) | |
return Pair(factor,divisor) | |
if(-Math.abs(factor) + divisor == b) | |
return Pair(-Math.abs(factor), divisor) | |
if(-Math.abs(factor) + -Math.abs(divisor) == b) | |
return Pair(-Math.abs(factor), -Math.abs(divisor)) |
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
import java.util.Collections | |
import java.util.concurrent.ConcurrentHashMap | |
import kotlin.concurrent.thread | |
fun main() { | |
println("Find the greatest common factor by entering a list of number seperated by a space") | |
loop@while(true){ | |
print("Enter your numbers: ") | |
val input = readlnOrNull()?.trim() | |
if(input.isNullOrBlank()) |
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
#include <iostream> | |
using namespace std; | |
class Word{ | |
public: | |
string word; | |
Word(string word){ | |
this->word = word; |
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
#include <iostream> | |
using namespace std; | |
struct EmptyListException : public exception{ | |
const char* what() throw() { | |
return "empty list"; | |
} | |
}; |
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
public static String directorySearch(File initialDirectory, String fileToSearchFor){ | |
final Queue<File> queue = new LinkedList<>(); | |
queue.add(initialDirectory); | |
while(!queue.isEmpty()){ | |
File currDir = queue.remove(); | |
String[] dirContents = currDir.list(); | |
if(dirContents == null) break; |
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
class LinkedQueue<T>{ | |
Node<T> front = null, rear = null; | |
public void enqueue(T value){ | |
if(front == null){ | |
rear = new Node<>(value, null); | |
front = rear; | |
return; | |
} | |
rear.next = new Node<>(value, null); |
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
class ArrayQueue<T>{ | |
private final T[] array; | |
private int front = 0, rear = 0, size = 0; | |
public ArrayQueue(int size){ | |
array = (T[]) new Object[size]; | |
} | |
public void enqueue(T value){ | |
size++; | |
array[rear] = value; |
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
class ArrayStack<T> { | |
private T[] array; | |
int top = 0; | |
public ArrayStack(int size){ | |
this.array = (T[]) new Object[size]; | |
} | |
public void push(T value){ | |
if(top == array.length){ |
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
import java.util.*; | |
class LinkedStack<T>{ | |
private Node<T> top = null; | |
public boolean isEmpty(){ | |
return top == null; | |
} | |
public void push(T value){ |