# [Solved] R code for AdStock rate in Marketing mix modeling

Marketing mix is an important tool to understand the effect of our marketing budget and helps to prioritize different channels. In the role of data analyst you would certainly come across this term and sometimes you would need to develop a model for the same. As we discussed in our previous blog, AdStock is one of the most important entities in Marketing mix modeling and this should be addressed while developing the model. Today I am going to write R code for the same. I want to request you to read my previous article to understand the concept. Continue reading

# [Solved] Student Becomes the Teacher – Code Academy Problem’s Solution

Hello friends! From last few days I have been learning Python and I found Code Academy extremely helpful. The way they make you to solve a big problem into small small chunk is very helpful to understand each and every steps properly and increase the problem solving skills. I have been following their tutorial on Python and recently completed one not very tough but interesting problem on the combination of List, Dictionary and Function. I hope if you came here from Google then you must be trying to find the solution of “Grading the students” problem. Though it is not advisable to look after the solution; you should try harder but if you have done all your efforts and want to get some hints here is the solution. Continue reading

# Making a calculator with javascript

Here we are going to make a calculator, which will be programmed with simple javascript and html code only.
Please first learn some basic of javascript function and HTML and how to write them. Refer w3school.com.

Open notepad, and copy this code, exactly as it is. Now save the page and name it calci.html. Please note that while saving the page, select ‘Save as file: All file’ not .txt in the notepad.

```<html>
<meta http-equiv="Content-Language" content="en-us"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript" type="text/javascript">
var i, j, op1, op2, op, f;
function digit(i) {
switch (i) {
case 1:
document.calc.display.value = (document.calc.display.value) + "1";
break;
case 2:
document.calc.display.value = (document.calc.display.value) + "2";
break;
case 3:
document.calc.display.value = (document.calc.display.value) + "3";
break;
case 4:
document.calc.display.value = (document.calc.display.value) + "4";
break;
case 5:
document.calc.display.value = (document.calc.display.value) + "5";
break;
case 6:
document.calc.display.value = (document.calc.display.value) + "6";
break;
case 7:
document.calc.display.value = (document.calc.display.value) + "7";
break;
case 8:
document.calc.display.value = (document.calc.display.value) + "8";
break;
case 9:
document.calc.display.value = (document.calc.display.value) + "9";
break;
case 0:
document.calc.display.value = (document.calc.display.value) + "0";
break;
case 10:
document.calc.display.value = (document.calc.display.value) + ".";
break;
case 25:
document.calc.display.value = "";
break;

}
}
function operation(j) {
if (j == 1) {
op1 = parseFloat(document.calc.display.value);
document.calc.display.value = "";
op = 1;
}
if (j == 2) {
op1 = parseFloat(document.calc.display.value);
document.calc.display.value = "";
op = 2;
}
if (j == 3) {
op1 = parseFloat(document.calc.display.value);
document.calc.display.value = "";
op = 3;
}
if (j == 4) {
op1 = parseFloat(document.calc.display.value);
document.calc.display.value = "";
op = 4;
}
if (j == 5) {
op2 = parseFloat(document.calc.display.value);
if (op == 1) {
f = op1 + op2;
document.calc.display.value = f;
}
else if (op == 2) {
f = op1 - op2;
document.calc.display.value = f;
}
else if (op == 3) {
f = op1 * op2;
document.calc.display.value = f;
}
else if (op == 4) {
f = op1 / op2;
document.calc.display.value = f;
}
}
}
</script>

<div style=" margin-left:25px;" id="calc">
<form name="calc">
<table align="center" bgcolor="black" cellspadding=5 cellspacing=5 height=200px width=200px>
<tr>
<td colspan="3" align="center">
<input type="text" name="display" style=" width:200px"/>
</td>
<td><input type="button" name="B" value=" C " onClick="digit(25)" style=" width:50px"/></td>
</tr>
<tr>
<td>
<input type="button" name="B" value=" 7 " onClick="digit(7)" style=" width:50px"/>
</td>
<td>
<input type="button" name="B" value=" 8 " onClick="digit(8)" style=" width:50px"/>
</td>
<td>
<input type="button" name="B" value=" 9 " onClick="digit(9)" style=" width:50px"/>
</td>
<td>
<input type="button" name="B" value=" + " onClick="operation(1)" style=" width:50px"/>
</td>
</tr>
<tr>
<td>
<input type="button" name="B" value=" 4 " onClick="digit(4)" style=" width:50px"/>
</td>
<td>
<input type="button" name="B" value=" 5 " onClick="digit(5)" style=" width:50px"/>
</td>
<td>
<input type="button" name="B" value=" 6 " onClick="digit(6)" style=" width:50px"/>
</td>
<td>
<input type="button" name="B" value=" - " onClick="operation(2)" style=" width:50px"/>
</td>
</tr>
<tr>
<td>
<input type="button" name="B" value=" 1 " onClick="digit(1)" style=" width:50px"/>
</td>
<td>
<input type="button" name="B" value=" 2 " onClick="digit(2)" style=" width:50px"/>
</td>
<td>
<input type="button" name="B" value=" 3 " onClick="digit(3)" style=" width:50px"/>
</td>
<td>
<input type="button" name="B" value=" * " onClick="operation(3)" style=" width:50px"/>
</td>
</tr>
<tr>
<td>
<input type="button" name="B" value=" 0 " onClick="digit(0)" style=" width:50px"/>
</td>
<td>
<input type="button" name="B" value=" . " onClick="digit(10)" style=" width:50px"/>
</td>
<td>
<input type="button" name="B" value=" = " onClick="operation(5)" style=" width:50px"/>
</td>
<td>
<input type="button" name="B" value=" / " onClick="operation(4)" style=" width:50px"/>
</td>
</tr>
</table></form>

</div>

</body>
</html>
```

# Finding Common Alphabet Between Two Names.

We have two names, say “AMITABH BACHCHAN ” and “RAJNIKANTH”. Our work is find common alphabet in these two names. The answer would be ‘AITHN’. i have written my code, if you find your code, more easier than mine, please do write in comment box. So lets go!

If you are looking for the solution in C/C++. Please visit Here .

```using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace commonAlpha
{
class Program
{
static void Main(string[] args)
{
char[] name1 = {'A','M','I','T','A','B','H','B','A','C','H','C','H','A','N'};
char[] name2 = { 'R', 'A', 'J', 'N', 'I', 'K', 'A', 'N', 'T', 'H' };
StringBuilder s1 = new StringBuilder();
for (int i = 0; i&lt;name1.Count(); i++)
{
for (int j = 0; j &lt; name2.Count(); j++)
{
//compareing two char from both string
if (name1[i] == name2[j])
{
char temp = name2[j];
if (s1.Length != 0)
{
int flag = 0;
//checking whether its already in s1 or not. If yes, flag will be greater than 0 or if not flag=0
for (int k = 0; k &lt; s1.Length; k++)
{
if (s1[k] == temp)
flag++;
}
//confirm that temp is not in s1
if (flag == 0)
{
s1.Append(temp);
}
}
else
s1.Append(temp);
}
}
}
for (int i = 0; i &lt; s1.Length; i++)
Console.Write(s1[i]);
}
}
}
```