All Questions
29 questions
4
votes
1
answer
102
views
Swift Arrays: Write a rotate-right function
Task:
Write a function which rotates all elements of a given array to the right.
Example: [1, 2, 3] => [3, 1, 2]
My solution:
...
3
votes
2
answers
377
views
Write a Swift-function, which computes the Digital Root
Task: Write a function, which computes the Digital Root of a given number n.
Here's the solution, which I developed:
...
4
votes
1
answer
699
views
Caesar Cipher in Swift (iOS-app)
I have implemented the Caesar Cipher in Swift and incorporated it into an iOS-app.
I guess it's formally correct. Please see the attached images, which show how the usage of the app is meant.
Here's ...
4
votes
3
answers
208
views
Bubble Sort as extension to Swift-Arrays
Task description:
Implement an extension for Array, which sorts the elements using the Bubble Sort-algorithm.
My implementation:
...
2
votes
1
answer
201
views
Swift-function for finding missing Integers in an array of sequential Integers
Task description:
Implement a function, which receives an array of unsorted numbers from 1 to 100. In the array zero or more numbers might be missing. The function shall return an array containing the ...
1
vote
1
answer
160
views
Implement the Swift pow(base, exp)-function yourself
Task: Implement a function, which accepts two integers and results the first number raised to the power of the second number. Both numbers have to be positive.
Examples:
The arguments 4 and 3 shall ...
2
votes
1
answer
210
views
Trie data structure in Swift lang
This is an implementation of a generic Trie DS, in Swift-lang, that is using however, for the sake of a easy example, strings.
It implements two operations, insert and search. So it can insert a text, ...
2
votes
2
answers
215
views
Create a custom split method that keeps the delimiters in Swift
I have implemented a custom split method that replicates the original functionality of the collection's split method in Swift and keep the delimiters (element separator). After a lot of trial and ...
2
votes
1
answer
131
views
Projecteuler.net Problem 2 using collection pipeline Pattern
I solve projecteuler.net Problem 2 deferent way
Generate number from 1 to range ex 100 and get the even number
Get Fibonacci numbers from list
Reduce array
I have one problem with a large set of ...
2
votes
1
answer
260
views
Trie implementation for strings in Swift
A trie for handling strings for an autocomplete dictionary. This passes my fairly casual tests, though it's always possible that there are broken edge cases, but I'm mainly concerned about design and ...
4
votes
1
answer
1k
views
Find minimum count of items where sum of them is X from an array
I recently faced an interview question where you have to find minimum needed items from an array that can added together to generate X value.
For example giving:
<...
2
votes
1
answer
3k
views
Dynamic Array Problem (Hacker rank)
I am trying to solve the Dynamic Array problem on HackerRank:
Create a list, seqList, of N empty sequences, where each sequence is indexed from 0 to N-1. The elements within each of the N ...
2
votes
1
answer
185
views
Sequence for Pre-order traversal of Binary Trees
I wanted to make a Sequence that can do a pre-order traversal of Binary Tree. Doing so provides automatically unlocks wonderfully useful methods, like ...
4
votes
1
answer
166
views
Swift Prim's algorithm
Lots of Prim's algorithm implementations seem long, and rely on a priority queue implementation.
If I use an adjacency matrix I can then calculate the next item to take using functional programming ...
6
votes
1
answer
738
views
Dijkstra algorithm implementation in Swift
I've implemented Dijkstra's algorithm to find the minimum path between two nodes.
...