digital root sort algorithm

I'm running through challenges on codefight and all tests pass except 1 "hidden test" where I'm unable to see the test data inserted... I'm looking for help pointing out what I'm missing or a failing test case with my solution. Problem: Digit ro...
more »

2017-06-18 23:06 (1) Answers

Rotate the indices on a hexagon

I have hexagons made of little unit hexagons. Each hexagon has a hex number of unit hexagons. The first few are numbered like: Size 1: 0 Size 2: 0 1 2 3 4 5 6 Size 3: 0 1 2 3 4 5 6 7 8 9 A B C D E F 101112 (Last one is in hexad...
more »

2017-06-17 19:06 (4) Answers

Solving crosswords

I have a crossword puzzle and a list of words which can be used to solve it (words can be placed multiple times or not even once). There is always a solution for the given crossword and word list. I searched for clues on how to solve this problem an...
more »

2017-06-17 18:06 (1) Answers

How to abbreviate a full name in C?

I am trying to get a full name from the user and display his name abbreviated, something like that : “Edward Cantrell Cavender Davis” --> Name the user entered "DAVIS, E. C. C.” -- Name abbreaviated The problem is that I don't know how ...
more »

2017-06-15 16:06 (3) Answers

Sorting node graph by connections

I have a node graph something like in the image below I would like to sort the nodes by levels. So something like [8, 4, 5, 9, 3, 1, 2, 7 , 6, 10] When I construct the nodes and connections they can be in any order. like class Element: def...
more »

2017-06-14 10:06 (1) Answers

Trouble with alternating string case

Working through exercises on the CodeWars website and I need help being pointed in the right direction for a simple function: Write a function toWeirdCase (weirdcase in Ruby) that accepts a string, and returns the same string with all even inde...
more »

2017-06-14 05:06 (6) Answers

HeapSort - Sorted before swapping

I was working with algorithms and specifically heapsort. From my understanding the heapsort algorithm involves preparing the list by first turning it into a max heap. Turning my [2, 8, 5, 3, 9, 1] Into [9, 8, 5, 3, 2, 1] With heapsort I am suppo...
more »

2017-06-13 14:06 (2) Answers

Changing O(n^3) to O(n^2) in JavaScript

I'm trying to wrap my head around saving time in my coding solution. I have a function called tripletSum which takes two parameters x and a where x is a number and a is an array. This function is supposed to return true if the list a contains three...
more »

2017-06-12 23:06 (3) Answers

Java 8 : map.merge time complexity

I am trying to find the complexity of below code, because of for loop it will be O(n * complexity_of_map.merge) public int solution(int K, int[] A) { Map<Integer, Integer> map = new HashMap<Integer, Integer>(); for(int i =0; ...
more »

2017-06-12 04:06 (1) Answers

erase-remove_if idiom - was anything removed?

I'm creating an API which users will call to remove items from an internal vector. They will pass in criteria to search the vector for elements to remove. I'd like my API to return a boolean for if any elements were found and removed. I'm planning...
more »

2017-05-24 23:05 (4) Answers

Shortest path with a twist

I have n vertices and m undirected weighted edges between them (weights are representing minutes). Each vertex contains a number of minutes required to drink a coffee on that vertex. I want to determine the shortest amount of time (minutes) neccess...
more »

2017-05-23 13:05 (3) Answers

Combination of elements in an array returning sum

I am learning optimization problem using data structures. For that I have considered a problem in hand. I have an array like: movies[] = { 2,3,4,5,6,7,2,4,9 } I have a sum value: k = 5 Now I am finding the combination of array elements returning...
more »

2017-05-22 19:05 (1) Answers

Sorting n lists whith no coincidences

(This is my very first question, if I'm doing something wrong, please tell me :)) I have n lists whose elements have an integer attribute (unique per list) and a duration in seconds. I have to sort these lists with no coioncidence of elements with ...
more »

2017-05-22 13:05 (0) Answers

For loop number path calculation

I have a bidirectional network, that is, a network where flow exists both from i->j and j->i. And I want to calculate the number of simple paths between each [i,j] and report in matrices according to the path length, that is, for each [i,j] pair ther...
more »

2017-05-19 16:05 (0) Answers

How to properly count occurrence in arrays?

I've got an in depth array (arrays of arrays). I'm trying to make a decent function without using any extra methods and JS designs (like closures). This is a working solution (but a bad one because of the global variable) var counter=0; functio...
more »

2017-05-18 18:05 (4) Answers

Nodejs createCipher vs createCipheriv

I am currently trying to encrypt data at rest with NodeJS, I have read in the Node API docs that createCipher is not recommended. The implementation of crypto.createCipher() derives keys using the OpenSSL function EVP_BytesToKey with the digest...
more »

2017-05-17 19:05 (0) Answers

haskell backtracking with integer

I am a Haskell newbie. So, I would like to ask a simple question. I have to find with help of backtracking the (unique) number containing 9 numbers with the following characteristics: The numbers 1/9 appear exactly once. The first k numbers...
more »

2017-05-16 12:05 (1) Answers