This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%matplotlib inline | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import time | |
from PIL import Image | |
# Converting the image to greyscale make it into a simpler matrix and easy to process | |
img = Image.open('panda.jpg') | |
img_gray = img.convert('LA') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
#include <cmath> | |
// Change in the given string itself. So no need to return or print the changed string. | |
void towerOfHanoi(int n, char source, char auxiliary, char destination) { | |
// Power of Recursion | |
if (n == 0){ | |
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
#include <cmath> | |
// Change in the given string itself. So no need to return or print the changed string. | |
void pair(char input[], int size){ | |
if (size < 2){ | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
#include <cmath> | |
int number(char input[], int size){ | |
if (size < 1){ | |
return 0; | |
} | |
int sum = number(input+1, size-1); | |
int i = input[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
void remove(char input[], int size){ | |
if (size < 1){ | |
return; | |
} | |
if (input[0] == 'x'){ | |
int i = 0; | |
for(i;i<=size;i++){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
void replacestring(char input[], int size){ | |
if (size < 2){ | |
return; | |
} | |
if ( input[0] == 'p' && input[1] == 'i'){ | |
int i = size; | |
for(i; i>=0; i--){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int sumOfDigits(int n) { | |
// base case | |
if ( n == 0){ | |
return 0; | |
} | |
// Recursive Call | |
int sum1 = sumOfDigits(n/10); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
bool isPalin(char input[], int si , int ei){ | |
// Base Case | |
if ( si >= ei ){ | |
return true; | |
} | |
// Small Calculation | |
if (input[si] != input[ei]){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int countZeros(int n) { | |
// Base Case and Special case | |
if (n>0 && n<10){ | |
return 0; | |
} | |
if (n == 0){ | |
return 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int firstIndex(int input[], int size, int x) { | |
// Base case | |
if (size == 0){ | |
return -1; | |
} | |
// Small Calculation | |
if (input[0]==x){ |
NewerOlder