Skip to content

Instantly share code, notes, and snippets.

View themonster2015's full-sized avatar
👋

Yen Vo themonster2015

👋
  • Spain
View GitHub Profile
//https://www.hackerrank.com/challenges/diagonal-difference/problem?isFullScreen=true
function diagonalDifference(arr) {
let sum1 = 0, sum2 = 0
for(let i = 0; i < arr.length; i++ ){
sum1 += arr[i][i]
let j = arr.length - 1 - i
sum2 += arr[i][j]
//console.log(arr[i][j])
}
Example 1:
const pets = ['Cat', 'Dog', 'Bird', 'Fish', 'Frog', 'Hamster', 'Pig', 'Horse' 'Lion', 'Dragon'];
// Print all pets
console.log(pets[0]);
console.log(pets[1]);
console.log(pets[2]);
console.log(pets[3]);
...
.cat {
@themonster2015
themonster2015 / install.sh
Created February 7, 2020 22:10 — forked from coryhouse/install.sh
Dependencies for React Auth0 on Pluralsight - Last Updated 11/30/2018
npm install auth0-js@9.8.0 auth0-lock@11.10.0 express@4.16.3 express-jwt@5.3.1 express-jwt-authz@1.0.0 jwks-rsa@1.3.0 npm-run-all@4.1.3 react-router-dom@4.3.1
@themonster2015
themonster2015 / docker-compose.yml
Created May 3, 2019 14:51
BDE2020 Docker-compose.yml
version: "2"
services:
namenode:
build: ./namenode
image: bde2020/hadoop-namenode:1.1.0-hadoop2.7.1-java8
container_name: namenode
volumes:
- hadoop_namenode:/hadoop/dfs/name
environment:
@themonster2015
themonster2015 / vue polling.js
Last active April 27, 2019 13:55
vue code for periodically polling an api
new Vue({
el: '#app',
data: {
items: [],
interval: null,
},
methods: {
loadData: function () {
$.get('/api/data', function (response) {
this.items = response.items;
@themonster2015
themonster2015 / binarysearchtree.rb
Created April 14, 2019 13:24
Ruby implementation of Binary Search Tree
class Node
attr_accessor :value, :left, :right
def initialize(value =nil)
@value = value
@left = nil
@right = nil
end
end
@themonster2015
themonster2015 / linkedlist.rb
Last active April 15, 2019 19:52
Ruby implementation of Singly Linked List
class Node
attr_accessor :value, :next_node
def initialize(value)
@value = value
@next_node = nil
end
def tail?
@next_node.nil?
end
end
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<ul> Ingredients
<li>Sugar</li>
<li>Milk</li>
function pairElement(str) {
arr = str.split('');
arr2 = [];
for (i = 0; i < arr.length-1; i++) {
for (k =1; k < arr.length; k++) {
if(arr[i] != arr[k]){
arr2.push([arr[i],arr[k]]);
}
}
DNA Pairing
The DNA strand is missing the pairing element. Take each character, get its pair, and return the results as a 2d array.
Base pairs are a pair of AT and CG. Match the missing element to the provided character.
Return the provided character as the first element in each array.
For example, for the input GCG, return [["G", "C"], ["C","G"],["G", "C"]]
The character and its pair are paired up in an array, and all the arrays are grouped into one encapsulating array.