Tags » Code Snippets

Counting total number of set bits(1s) in all numbers from 1 to n.

#include <stdio.h>

int bincount(int);
int digitcount(int);
int main(void) {
 // your code goes here
 int n=4;
 printf("binary count is %d",bincount(n));
 return 0;
}
int bincount(int n)
{int count=0;
 for(int i=1;i<=n;i++)
 {
 count+=digitcount(i); 
 }

return count;
}
int digitcount(int n)
{
 if(n<1)
 {
 return 0;
 }
 return (n%2==0?0:1)+digitcount(n/2);
}
Coding

Linear / Logistic Regression in R: Dealing With Unknown Factor Levels in Test Data

Let’s say you have data containing a categorical variable with 50 levels. When you divide the data into train and test sets, chances are you don’t have all 50 levels featuring in your training set. 281 more words

Technical
const baseUrl=process.env.PUBLIC_URL;
const Routes = () => (
  <Router>
    
      
    
  </Router>
) 14 more words
Front-end

AngularJS - UI-Router : Multiple states with same URL

Usually, with angular ui-router, we can have one url for a single state something like this:

...
.state('app', {
  url: "/home",
  templateUrl: "....",
  controller: "myController",
  roles: ['administrator','authenticated']
  ... 168 more words
Code Snippets

WordPress: Display categories without the link

This post will show you how to get a WordPress category name as a string instead of a linked name.

Reposted from Behind The Scenes… 6 more words

Perceptron - Coding , Visualising and Tweaking a Artificial Neuron

This post is dedicated to Perceptron.

Perceptrons are simplest form of Neural Models that can be compared to a human neuron. It has certain properties which can be used as a classifier. 13 more words

Code Snippets

Chef Tom Colicchio’s Craft L.A. Is Turning 10, and You Can Help Him Celebrate

From Daniel Humm and April Bloomfield to David Chang and Dave Beran, many of America’s most celebrated chefs are flooding into Los Angeles, joining a vibrant food scene that has been on the rise the last few years. 333 more words

Food &amp; Drink