Skip to content

Instantly share code, notes, and snippets.

Nedim Dedic ndedic

  • Bosnia and Herzegovina
Block or report user

Report or block ndedic

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ndedic
ndedic / kaprekar-constant.js
Created Dec 13, 2018
Kaprekar's constant solver
View kaprekar-constant.js
// https://en.wikipedia.org/wiki/6174_(number)
const kaprekar = 6174;
const routine = (input) => {
const res = new Map();
let i = 0;
while (input !== kaprekar) {
input = cycle(input);
res.set(i++, input);
@ndedic
ndedic / elevation-map.js
Last active Apr 6, 2018
Elevation map solver
View elevation-map.js
/*
You are given an array of non-negative integers that represents a two-dimensional elevation map where each element is unit-width wall and the integer is the height. Suppose it will rain and all spots between two walls get filled up.
Compute how many units of water remain trapped on the map in O(N) time and O(1) space.
For example, given the input [2, 1, 2], we can hold 1 unit of water in the middle.
Given the input [3, 0, 1, 3, 0, 5], we can hold 3 units in the first index, 2 in the second, and 3 in the fourth index (we cannot hold 5 since it would run off to the left), so we can trap 8 units of water.
*/
/**
* Solution:
*
@ndedic
ndedic / day5.go
Created Dec 6, 2017
Advent Of Code, day 5
View day5.go
package aoc18
import (
"io/ioutil"
"log"
"strconv"
"strings"
)
type Maze struct {
View video-store-refactor.js
let AmountCalculator = {
'new'(days) {
return days * 3;
},
'regular'(days) {
let amount = 2;
return days > 2 ? (amount + (days - 2) * 1.5) : amount;
},
'childrens'(days) {
let amount = 1.5;
@ndedic
ndedic / trello-challenge.js
Last active Nov 29, 2015
Trello dev challenge, for the fun of it
View trello-challenge.js
var TrelloSolver = (function solver() {
var ALLOWED_LETTERS = 'acdegilmnoprstuw';
function hash(str) {
var h = 7;
for ( var i = 0, iLimit = str.length; i < iLimit; i++ ) {
h = ( h * 37 + validate(ALLOWED_LETTERS.indexOf(str[i])));
You can’t perform that action at this time.