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
object DLLPlayground { | |
trait DLList[+T] { | |
def value: T | |
def prev: DLList[T] | |
def next: DLList[T] | |
def isEmpty: Boolean | |
def prepend[S >: T](element: S): DLList[S] |
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
#### Disclaimer #### | |
#### THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
#!/bin/bash | |
#### | |
#### Tiny script to quickly turn/ your Scrimba (scrimba.com) React project downloaded as a zip file, into a new "create-react-app" project. | |
#### This script is at least specific to the "React Bootcamp - Become a professional |
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 EmberRouter from '@ember/routing/router'; | |
import config from './config/environment'; | |
const Router = EmberRouter.extend({ | |
location: 'none', | |
rootURL: config.rootURL | |
}); | |
Router.map(function() { | |
this.route('list-rentals'); |
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
// flames.js | |
// FLAMES game. Algorithm can be found here: http://flamesgame.appspot.com/algorithm | |
const getFlame = (name1, name2) => | |
name1.toLowerCase().split(''). // take all characters in "name1", to compare | |
filter(c => name2.toLowerCase().includes(c)). // keep only characters (in "name1") also found in "name2" | |
reduce((result, c) => [ | |
result[0].replace(new RegExp(`${c}`, 'g'), ''), // replace common characters in "name1" | |
result[1].replace(new RegExp(`${c}`, 'g'), '') // replace common characters in "name2" | |
], [name1.toLowerCase(), name2.toLowerCase()]). |
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
object QuickSort { | |
def sort(list: Seq[Int]): Seq[Int] = { | |
if (list.length < 2) list | |
else { | |
val midIndex = list.length / 2 | |
val mid = list(midIndex) | |
val result = list.zipWithIndex.filter(_._2 != midIndex) | |
.partition(n => n._1 < mid) | |
result match { |
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
function createNode(key) { | |
const children = []; | |
const attributes = {}; | |
return { | |
key, | |
children, | |
attributes, | |
addChild(key) { | |
const child = createNode(key); |
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
object ReverseSentence extends App { | |
if (args == null || args.length == 0) { | |
printf("%d arguments found; 2 arguments required.", Option(args).map(_.length).getOrElse(0)) | |
sys.exit(0); | |
} | |
if (args(0) == args(1)) { | |
println("The string parameters are equal.") | |
sys.exit(0) | |
} |
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
/* | |
* Replace the contents of the "string" variable with the actual input numbers you have. | |
* Make sure you space them, with each number on its own line. | |
*/ | |
const numbers = ` | |
2 | |
1 | |
2 | |
3 | |
1 |
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
object Main { | |
type T = Any | |
trait Listy[T] { | |
val value: T | |
def isEmpty: Boolean | |
def head: Option[T] | |
def tail: Listy[T] | |
def filter(predicate: T => Boolean): Listy[T] = { | |
if (predicate(value)) ListyImpl(value, tail.filter(predicate)) else tail | |
} |
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.Scanner; | |
public class Depreciation { | |
private static Scanner scanner = new Scanner(System.in); | |
private static Column[] columns = { | |
new Column("Year", " "), | |
new Column("Start Value", " "), | |
new Column("Amt. Depreciated", " "), | |
new Column("Total Depreciation", "") | |
}; |
NewerOlder