Skip to content

Commit 4f8d9bb

Browse files
AkshitAggarwalMadhavBahl
authored andcommitted
Day05: Patterns in C++ (#273)
* Day 1 Problem 1 C++ Implementation of Day 1 has been uploaded * Day 2 Problem A * Cpp solution to Day 2, Problem 2 Solves the Palindrome problem, wether an entered string is Palindrome or not. * C++ Implementation of the Hamming Distance Problem * C++ implementation of Vowel count. * C++ Code for all patterns in one file. * Add @AkshitAggarwal as a contributor * C++ code for Day06 Problems * Recurrsion Problem #4
1 parent 822b123 commit 4f8d9bb

File tree

11 files changed

+403
-2
lines changed

11 files changed

+403
-2
lines changed

.all-contributorsrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,16 @@
241241
"doc",
242242
"code"
243243
]
244+
},
245+
{
246+
"login": "AkshitAggarwal",
247+
"name": "Akshit Aggarwal",
248+
"avatar_url": "https://avatars1.githubusercontent.com/u/40717067?v=4",
249+
"profile": "https://github.com/AkshitAggarwal",
250+
"contributions": [
251+
"doc",
252+
"code"
253+
]
244254
}
245255
]
246256
}

CONTRIBUTORS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![All Contributors](https://img.shields.io/badge/all_contributors-23-orange.svg?style=flat-square)](#contributors)
1+
[![All Contributors](https://img.shields.io/badge/all_contributors-24-orange.svg?style=flat-square)](#contributors)
22

33
## Contributors
44

@@ -10,7 +10,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
1010
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
1111
| [<img src="https://avatars0.githubusercontent.com/u/39827514?v=4" width="100px;" alt="Ashwek Swamy"/><br /><sub><b>Ashwek Swamy</b></sub>](https://github.com/ashwek)<br />[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=ashwek "Documentation") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=ashwek "Code") | [<img src="https://avatars1.githubusercontent.com/u/32368107?v=4" width="100px;" alt="Dhruv Gupta"/><br /><sub><b>Dhruv Gupta</b></sub>](https://github.com/dhruv-gupta14)<br />[💻](https://github.com/CodeToExpress/dailycodebase/commits?author=dhruv-gupta14 "Code") | [<img src="https://avatars0.githubusercontent.com/u/30969577?v=4" width="100px;" alt="Aadit Kamat"/><br /><sub><b>Aadit Kamat</b></sub>](https://sg.linkedin.com/in/aadit-kamat-12a5a8140)<br />[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=aaditkamat "Documentation") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=aaditkamat "Code") | [<img src="https://avatars1.githubusercontent.com/u/20285786?v=4" width="100px;" alt="Shashank jain"/><br /><sub><b>Shashank jain</b></sub>](http://www.myshashank.tech)<br />[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=Shashankjain12 "Documentation") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=Shashankjain12 "Code") | [<img src="https://avatars3.githubusercontent.com/u/22260031?v=4" width="100px;" alt="Moulik Aggarwal"/><br /><sub><b>Moulik Aggarwal</b></sub>](https://github.com/moulikcipherX)<br />[💬](#question-moulikcipherX "Answering Questions") [📝](#blog-moulikcipherX "Blogposts") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=moulikcipherX "Code") [📖](https://github.com/CodeToExpress/dailycodebase/commits?author=moulikcipherX "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/21277179?v=4" width="100px;" alt="Prateek Surana"/><br /><sub><b>Prateek Surana</b></sub>](http://prateeksurana.me)<br />[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=prateek3255 "Documentation") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=prateek3255 "Code") | [<img src="https://avatars2.githubusercontent.com/u/43927436?v=4" width="100px;" alt="shivank86"/><br /><sub><b>shivank86</b></sub>](https://github.com/shivank86)<br />[💻](https://github.com/CodeToExpress/dailycodebase/commits?author=shivank86 "Code") |
1212
| [<img src="https://avatars2.githubusercontent.com/u/25405726?v=4" width="100px;" alt="Vishal Shirke"/><br /><sub><b>Vishal Shirke</b></sub>](https://github.com/vishalshirke7)<br />[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=vishalshirke7 "Documentation") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=vishalshirke7 "Code") | [<img src="https://avatars1.githubusercontent.com/u/25369498?v=4" width="100px;" alt="profgrammer"/><br /><sub><b>profgrammer</b></sub>](https://github.com/profgrammer)<br />[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=profgrammer "Documentation") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=profgrammer "Code") | [<img src="https://avatars1.githubusercontent.com/u/26656036?v=4" width="100px;" alt="divyakhetan"/><br /><sub><b>divyakhetan</b></sub>](https://github.com/divyakhetan)<br />[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=divyakhetan "Documentation") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=divyakhetan "Code") | [<img src="https://avatars0.githubusercontent.com/u/36483814?v=4" width="100px;" alt="Spreeha Dutta"/><br /><sub><b>Spreeha Dutta</b></sub>](https://github.com/Spreeha)<br />[💻](https://github.com/CodeToExpress/dailycodebase/commits?author=Spreeha "Code") [📖](https://github.com/CodeToExpress/dailycodebase/commits?author=Spreeha "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/26464695?v=4" width="100px;" alt="Chaitanya Bhojwani"/><br /><sub><b>Chaitanya Bhojwani</b></sub>](https://github.com/chaitanya-bhojwani)<br />[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=chaitanya-bhojwani "Documentation") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=chaitanya-bhojwani "Code") | [<img src="https://avatars0.githubusercontent.com/u/22885912?v=4" width="100px;" alt="Manaswini Das"/><br /><sub><b>Manaswini Das</b></sub>](https://www.linkedin.com/in/manaswini-das/)<br />[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=manaswinidas "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/25549847?s=460&v=4" width="100px;" alt="Anirudh Jwala"/><br /><sub><b>Anirudh Jwala</b></sub>](https://www.linkedin.com/in/anirudh-jwala-533859135/)<br />[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=anirudh-jwala "Documentation") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=anirudh-jwala "Code") |
13-
| [<img src="https://avatars0.githubusercontent.com/u/2049543?v=4" width="100px;" alt="Willian Taiguara Baliza Moura"/><br /><sub><b>Willian Taiguara Baliza Moura</b></sub>](https://github.com/willianwt)<br />[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=willianwt "Documentation") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=willianwt "Code") | [<img src="https://avatars3.githubusercontent.com/u/33730790?v=4" width="100px;" alt="Rajashree Parhi"/><br /><sub><b>Rajashree Parhi</b></sub>](https://github.com/rajashree23)<br />[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=rajashree23 "Documentation") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=rajashree23 "Code") |
13+
| [<img src="https://avatars0.githubusercontent.com/u/2049543?v=4" width="100px;" alt="Willian Taiguara Baliza Moura"/><br /><sub><b>Willian Taiguara Baliza Moura</b></sub>](https://github.com/willianwt)<br />[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=willianwt "Documentation") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=willianwt "Code") | [<img src="https://avatars3.githubusercontent.com/u/33730790?v=4" width="100px;" alt="Rajashree Parhi"/><br /><sub><b>Rajashree Parhi</b></sub>](https://github.com/rajashree23)<br />[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=rajashree23 "Documentation") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=rajashree23 "Code") | [<img src="https://avatars1.githubusercontent.com/u/40717067?v=4" width="100px;" alt="Akshit Aggarwal"/><br /><sub><b>Akshit Aggarwal</b></sub>](https://github.com/AkshitAggarwal)<br />[📖](https://github.com/CodeToExpress/dailycodebase/commits?author=AkshitAggarwal "Documentation") [💻](https://github.com/CodeToExpress/dailycodebase/commits?author=AkshitAggarwal "Code") |
1414
<!-- ALL-CONTRIBUTORS-LIST:END -->
1515

1616
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind are welcome!

Day1/C++/Day01.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*This program prints a pattern of numbers 1 to n, wherein
2+
every multiple of 3 is Fizz, Every multiple of 5 is Buzz
3+
and every multiple of 3 and 5 both is replaced by Fizzbuzz*/
4+
5+
#include<iostream>
6+
7+
using namespace std;
8+
9+
int main()
10+
{
11+
int n;
12+
cout<<"\n===FIZZBUZZ===";
13+
cout<<"\nEnter a number: ";
14+
cin>>n;
15+
16+
for(int i = 1; i <= n; i++)
17+
{
18+
if(i % 3 ==0 && i % 5 == 0) cout<<" FIZZBUZZ ";
19+
20+
else if(i % 3 == 0) cout<<" FIZZ ";
21+
22+
else if(i % 5 == 0) cout<<" BUZZ ";
23+
24+
else cout<<i<<" ";
25+
}
26+
27+
return 0;
28+
}

Day2/C++/Day02-A.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/* @author : AkshitAggarwal */
2+
3+
#include<iostream>
4+
#include<string.h>
5+
6+
using namespace std;
7+
8+
9+
string strRev(string s)
10+
{
11+
int str_len = s.size();
12+
cout<<str_len;
13+
int last = str_len;
14+
char temp;
15+
for(int i = 0; i < str_len/2; i++)
16+
{
17+
temp = s[i];
18+
s[i] = s[last - 1];
19+
s[last -1] = temp;
20+
last--;
21+
}
22+
23+
return s;
24+
}
25+
int main()
26+
{
27+
string str;
28+
29+
cout<<"\nEnter string to be reversed: ";
30+
getline(cin, str);
31+
string rev = strRev(str);
32+
cout<<'\n'<<rev;
33+
34+
return 0;
35+
}

Day2/C++/Day02-B.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* @author : AkshitAggarwal
2+
Date : 24/01/2019 */
3+
4+
#include<iostream>
5+
#include<string.h>
6+
7+
using namespace std;
8+
9+
string palindrome(string s)
10+
{
11+
int len = s.length();
12+
int ptr = 0;
13+
14+
for(int i = 0, j = len -1; i < len/2; i++, j--)
15+
{
16+
if(s[i] == s[j]) ptr++;
17+
}
18+
19+
if(ptr == len/2) return "Yes";
20+
else return "No";
21+
22+
}
23+
24+
int main()
25+
{
26+
string str;
27+
cout<<"\nEnter String : ";
28+
getline(cin, str);
29+
string ans = palindrome(str);
30+
cout<<ans;
31+
return 0;
32+
}
33+

Day3/C++/Day03.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/* @author : AkshitAggarwal
2+
Date : 28/01/2019
3+
Hamming Distance Problem*/
4+
5+
#include<iostream>
6+
#include<string.h>
7+
8+
using namespace std;
9+
10+
int hammingDistance(string s1, string s2)
11+
{
12+
int len1 = s1.length();
13+
int len2 = s2.length();
14+
int ptr = 0;
15+
int n = len1;
16+
17+
if(len1 > len2)
18+
{
19+
ptr = len1 - len2;
20+
n = len2;
21+
}
22+
else if(len2 > len1)
23+
{
24+
ptr = len2 - len1;
25+
n = len1;
26+
}
27+
28+
for(int i = 0; i < n; i++)
29+
if(s1[i] != s2[i]) ptr++;
30+
31+
return ptr;
32+
}
33+
34+
int main()
35+
{
36+
string str1, str2;
37+
cout<<"\nEnter String 1 : ";
38+
getline(cin, str1);
39+
cout<<"\nEnter String 2 : ";
40+
getline(cin, str2);
41+
int ans = hammingDistance(str1, str2);
42+
cout<<ans;
43+
return 0;
44+
}

day16/C++/Day16

12.9 KB
Binary file not shown.

day16/C++/Day16.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
@author: AkshitAggarwal
3+
@date: 15/03/2019
4+
*/
5+
6+
#include<iostream>
7+
8+
using namespace std;
9+
10+
int towerOfHanoi(int n, char barFrom, char barTo, char barAuxillary)
11+
{
12+
if(n == 1)
13+
{ cout<<"\nMove disk 1 from "<<barFrom<<" to "<<barTo;
14+
return 1;
15+
}
16+
towerOfHanoi(n - 1, barFrom, barAuxillary, barTo);
17+
cout<<"\nMove disk "<< n <<" from "<<barFrom<<" to "<<barTo;
18+
towerOfHanoi(n - 1, barAuxillary, barTo, barFrom);
19+
}
20+
21+
int main()
22+
{
23+
int disks;
24+
cout<<"\nEnter number of Disks: ";
25+
cin>>disks;
26+
towerOfHanoi(disks, 'A', 'C', 'B');
27+
return 0;
28+
}

day4/C++/Day04-A.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* @author : AkshitAggarwal
2+
Date : 28/01/2019
3+
Counting the Vowels*/
4+
5+
#include<iostream>
6+
7+
using namespace std;
8+
9+
int vowelCount(string s)
10+
{
11+
int ctr = 0;
12+
for(int i = 0, n = s.length(); i < n; i++)
13+
if(s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u') ctr++;
14+
15+
return ctr;
16+
}
17+
int main()
18+
{
19+
string str;
20+
getline(cin, str);
21+
cout<<"\nNo. of vowels in this word are :"<<vowelCount(str);
22+
23+
return 0;
24+
}

0 commit comments

Comments
 (0)