Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 130 additions & 0 deletions C++/many_pattern.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
#include<iostream>

using namespace std;

int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int rows, columns;
cin>>rows>> columns;

cout<<"Pattern 1 :- Rectangle\n"<< endl;
for(int i = 1 ; i <= rows; i++)
{
for(int j = 1 ; j <= columns; j++ )
{
cout<<"* ";
}
cout<<endl;
}

cout<<"\nPattern 2 :- Hollow Rectangle\n"<<endl;
for(int i = 1 ; i <= rows; i++)
{
for(int j = 1 ; j <= columns; j++ )
{
if(j == 1 || j == columns || i == 1 || i == rows)
cout<<"* ";
else{
cout<<" ";
}

}
cout<<endl;
}

cout<<"\nPattern 3 :- Inverted half Pyramid\n"<<endl;
for(int i = rows ; i >= 1; i--)
{
for(int j = 1 ; j <= i; j++ )
{
cout<<"* ";
}
cout<<endl;
}

cout<<"\nPattern 4 :- half Pyramid after 180 deg rotation\n"<<endl;
for(int i = rows ; i >= 1; i--)
{
for(int j = 1 ; j <= rows; j++ )
{
if(j < i)
cout<<" ";
else
cout<<"* ";
}
cout<<endl;
}

cout<<"\nPattern 5 :- Half Pyramid using numbers\n"<<endl;
for(int i = 1 ; i <= rows; i++)
{
for(int j = 1 ; j <= i; j++ )
{
cout<<i<<" ";
}
cout<<endl;
}

cout<<"\nPattern 6 :- Butterfly pattern\n"<<endl;
for(int i = 1 ; i <= rows * 2; i++)
{
for(int j = 1 ; j <= rows * 2; j++ )
{
if((j <= i || j > (rows * 2)- i) && i <= rows)
cout<<"* ";

else if ((j >= i || j <= (rows * 2)- (i - 1)) && i > rows)
cout<<"* ";

else
cout<<" ";
}
cout<<endl;
}

cout<<"\nPattern 7 :- Inverted half Pyramid using numbers\n"<<endl;
for(int i = rows ; i >= 1; i--)
{
for(int j = 1 ; j <= i; j++ )
{
cout<<j<<" ";
}
cout<<endl;
}

cout<<"\nPattern 8 :- Half Pyramid using 0/1\n"<<endl;
for(int i = 1 ; i <= rows; i++)
{
for(int j = 1 ; j <= i; j++ )
{
if ((i + j) % 2 == 0)
cout<<"1 ";

else
cout<<"0 ";
}
cout<<endl;
}

cout<<"\nPattern 9 :- Rombus\n"<<endl;
for(int i = 1 ; i <= rows; i++)
{
for(int j = 1 ; j <= rows - i; j++ )
{
cout<<" ";
}
for(int j = 1; j <= rows; j++ )
{
cout<<"* ";
}
cout<<endl;
}


return 12;

}
83 changes: 83 additions & 0 deletions C++/minimum_time_to_make_a_rope_colourfull.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#include<iostream>
#include<string.h>

using namespace std;

// int balloon_color_check(char[], int[], int);

// int main(){
// int n;
// cin>>n;


// char colourfull_balloons[n];
// for(int i = 0; i<n ; i++){
// cin>>colourfull_balloons[i];
// }
// int time_taken[n];
// for (int i = 0; i < n; i++)
// {
// cin>>time_taken[i];
// }

// int min_time = balloon_color_check(colourfull_balloons, time_taken, n);
// cout<<min_time;


// }

// int balloon_color_check(char colourfull_balloons[], int time_taken[], int n){
// int min_time = 0;
// for(int i = 0; i<n; i++){
// if(colourfull_balloons[i] == colourfull_balloons[i+1]){
// if(time_taken[i] > time_taken[i+1]){
// min_time += time_taken[i+1];
// }
// else{
// min_time += time_taken[i];
// }
// }
// }
// return min_time;
// }

int balloon_color_check(string, int[], int);

int main(){
int n;
cin>>n;


string colourfull_balloons;
cin>>colourfull_balloons;

int time_taken[n];
for (int i = 0; i < n; i++)
{
cin>>time_taken[i];
}

int min_time = balloon_color_check(colourfull_balloons, time_taken, n);
cout<<min_time;


}

int balloon_color_check(string colourfull_balloons, int time_taken[], int n){
int min_time = 0;
for(int i = 0; i<n; i++){
if(colourfull_balloons[i] == colourfull_balloons[i+1]){
if(time_taken[i] > time_taken[i+1]){
min_time += time_taken[i+1];
}
else{
min_time += time_taken[i];
}
}
}
return min_time;
}


//Done
//https://leetcode.com/problems/minimum-time-to-make-rope-colorful/
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ Its ~~october~~(hackctober month) ...add your codes and contribute to open sourc
- OverLord
- Kuroko No Basuke
- Bleach
- One Piece
- Hunter x Hunter
- Jujutsu Kaisen



Expand Down Expand Up @@ -122,4 +125,4 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d

<!-- ALL-CONTRIBUTORS-LIST:END -->

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