Coddicted - Page 9 of 35 - Codes.Notes.Tutorials.

Add Digits

Title: Add Digits Source: leetcode.com Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, return it. Follow up: Could you do ...

Bulls and Cows

Title: Bulls and Cows Source: leetcode.com You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hint that indicates how many digits in said guess match your secret ...

OnePlus One : The Review

OnePlus One : The Review
Hello Everyone, We finally bring you the much awaited review of the super hyped and ‘The Flagship Killer’ titled mobile phone device. The One from OnePlus. While the specs are astonishing compared to its contemporary phones, with 3 GB RAM, Qualcomm Snapdragon 2.5 GHz Quad Core CPU chip, 13 MP Rear and 5MP front camera, ...

Running Hadoop Example(TDG/CH02) on Cloudera Quick Start VM 1

prerequisite 1. VMWare Player (Oracle VM box didn’t work for me) Download VMWare Player 2. Cloudera Quick Start VM Download Cloudera Quick Start VM 3. Download CH02 example java code from here. 4. create a folder BigDataAssignment1/code(name it whatever you want) inside /home/cloudera/workspace/ 5. Download hadoop-core-0.20.2.jar from here and place it inside code folder you ...

The OnePlus One: unpacking in pictures.

The OnePlus One: unpacking in pictures.
Hi everyone, Wish you all a very happy and productive new year. 🙂 Hope you are having an excellent run so far. For the first post of the new year we bring you the unpacking of one of the most talked about phone in tech community: the OnePlus One. Titled as “the flagship killer”, the ...

Lossless Dependency Preserving 3NF decomposition Algorithm 1

The minimal cover of F is given 1. Search for dependencies in F-having the same attribute set on the left hand side A: A->B1, A->B2, A->B3, …, A->Bk And construct relation as (A, B1, B2, B3,…, Bk) 2. Construct a relation with remainder attributes. 3. In case none of the relations has a candidate key, ...

Find maximal uni-directional path length for a Binary Tree

Find maximal uni-directional path length for a Binary Tree
Continuing from our last post for a Generic Binary Tree implementation, we’ve come up with a solution to quite an interesting problem. We define a path in a binary tree to be a non-empty sequence of nodes that one can traverse by following the pointers in the nodes. A path only goes to the right ...

Implementing a Generic Binary Tree in Java

Implementing a Generic Binary Tree in Java
The following two classes demonstrate an implementation of the Generic Binary Tree data structure. The first class is BinaryTreeNode.java which acts as the node class for the tree, holding integer type data and two pointers for left and right child respectively of type same as the node class itself. The member fields are declared to ...

Data truncation: Incorrect datetime value: ” for column 2

While using Acitiviti API you might encounter this error which says something like this ### Error updating database. Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: ” for column ‘DEPLOY_TIME_’ at row 1### The error may involve org.activiti.engine.impl.persistence.entity.DeploymentEntity.insertDeployment-Inline### The error occurred while setting parameters### Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: ” for column ‘DEPLOY_TIME_’ at row ...

Python newline caveat

Hello Everyone, This will be a small post about a caveat in Python language (v2.7) for writing output to files. On Windows the new line character is actually treated as ‘\r\n‘ or CRLF as we know it (Carriage Return followed by a Newline). Sometimes however you may not want to output this newline character into ...