diff --git a/Flood_FIll_Algo.py b/Flood_FIll_Algo.py new file mode 100644 index 0000000..a73ca4b --- /dev/null +++ b/Flood_FIll_Algo.py @@ -0,0 +1,104 @@ +# Python3 implementation of the approach + +# Function that returns true if +# the given pixel is valid +def isValid(screen, m, n, x, y, prevC, newC): + if x<0 or x>= m\ + or y<0 or y>= n or\ + screen[x][y]!= prevC\ + or screen[x][y]== newC: + return False + return True + + +# FloodFill function +def floodFill(screen, + m, n, x, + y, prevC, newC): + queue = [] + + # Append the position of starting + # pixel of the component + queue.append([x, y]) + + # Color the pixel with the new color + screen[x][y] = newC + + # While the queue is not empty i.e. the + # whole component having prevC color + # is not colored with newC color + while queue: + + # Dequeue the front node + currPixel = queue.pop() + + posX = currPixel[0] + posY = currPixel[1] + + # Check if the adjacent + # pixels are valid + if isValid(screen, m, n, + posX + 1, posY, + prevC, newC): + + # Color with newC + # if valid and enqueue + screen[posX + 1][posY] = newC + queue.append([posX + 1, posY]) + + if isValid(screen, m, n, + posX-1, posY, + prevC, newC): + screen[posX-1][posY]= newC + queue.append([posX-1, posY]) + + if isValid(screen, m, n, + posX, posY + 1, + prevC, newC): + screen[posX][posY + 1]= newC + queue.append([posX, posY + 1]) + + if isValid(screen, m, n, + posX, posY-1, + prevC, newC): + screen[posX][posY-1]= newC + queue.append([posX, posY-1]) + + + +# Driver code +screen =[ +[1, 1, 1, 1, 1, 1, 1, 1], +[1, 1, 1, 1, 1, 1, 0, 0], +[1, 0, 0, 1, 1, 0, 1, 1], +[1, 2, 2, 2, 2, 0, 1, 0], +[1, 1, 1, 2, 2, 0, 1, 0], +[1, 1, 1, 2, 2, 2, 2, 0], +[1, 1, 1, 1, 1, 2, 1, 1], +[1, 1, 1, 1, 1, 2, 2, 1], + ] + +# Row of the display +m = len(screen) + +# Column of the display +n = len(screen[0]) + +# Co-ordinate provided by the user +x = 4 +y = 4 + +# Current color at that co-ordinate +prevC = screen[x][y] + +# New color that has to be filled +newC = 3 + +floodFill(screen, m, n, x, y, prevC, newC) + + +# Printing the updated screen +for i in range(m): + for j in range(n): + print(screen[i][j], end =' ') + print() diff --git a/Pouring Water ICPC.cpp b/Pouring Water ICPC.cpp new file mode 100644 index 0000000..7b988db --- /dev/null +++ b/Pouring Water ICPC.cpp @@ -0,0 +1,68 @@ +#include +#define GREEN "\033[32m" +#define MAGENTA "\033[35m" +#define RESET "\033[0m" +#define all(x) begin(x),end(x) +#define sz(x) (int)(x).size() +using namespace std; +#ifdef BCDBG +#define tcT template ostream& operator<<(ostream& os,const pair& p) {return os<<"("<::value,typename T::value_type>::type> ostream& operator<<(ostream &os,const T &v) +{os<<"\n{";string sep;for(const U &x:v)os< void debug_help(T t,U... u) {cout< void debug_fill(T t,U... u) {debug_dms[debug_md++]=t;debug_fill(u...);} +tcT> void debug_arr(T x,int d) {cout< void debug_arr(T* arr,int d) +{cout<<"\n{";string sep;for(int i=0;i> a >> b >> c; + if (c % __gcd(a, b) || (c > a && c > b)) { + cout << -1 << df; + return; + } + cout << min(go(a, b, c), go(b, a, c)) << df; +} +signed main() { + ios_base::sync_with_stdio(false); + cin.tie(nullptr); + int tt = 1; + cin >> tt; + for (int i = 1; i <= tt; i++) { + solve(); + } + return 0; +} +Python +import math \ No newline at end of file diff --git a/README.md b/README.md index 7caf73e..52d40cf 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,129 @@ -# HacktoberFest -Send merge request for the HAcktoberFests +[https://github.com/open-for-everyone/hacktoberfest2021/discussions/747](https://github.com/open-for-everyone/hacktoberfest2021/discussions/747) + +

+ + + +

+ +

Hacktoberfest 2021 🎉

+ FREE FOR ALL , LEARNING and CELEBRATING OPEN SOURCE, This Hacktoberfest project exists to help you submit your first Pull Request! +Skip to content +Search or jump to… +Pull requests +Issues +Marketplace +Explore + +/ +Hacktoberfest-1 +Public +0 +0 +528 +Code +Pull requests +Actions +Projects +Wiki +Security +Insights +Settings +Hacktoberfest-1 +/ +README.md +in +master + + + + +## Your First Pull Request - Hacktoberfest +I created this project in the spirit of hacktoberfest so that you can do a very simple pull request and in the process you learn how to contribute to a project :smiley: +Note that this repository exists as a learning tool for new contributors to open-source, and pull requests to this won’t count toward Hacktoberfest! PR requests won't be accepted/merged. + +### What is Hacktoberfest? +[Hacktoberfest](https://hacktoberfest.digitalocean.com/) is a month-long celebration of open source software. You have to register and make five pull requests to any github repo (including this one!) in the month of october. If you do that you get a tshirt :tshirt: and stickers for your laptop :computer: . Sounds interesting? Let's do it then! + +### Wait...what is github?! + +I get it. You are new to this whole thing. But don't worry, here is a great [guide](https://guides.github.com/activities/hello-world/) to help you understand. + +### Contribution Guide + +To Contribute in a proper way so that I can merge the pull request: + +1. Star the repo! :star: + +2. Fork it. (Important!) [What is that?](https://help.github.com/articles/fork-a-repo/) + +3. Edit the README.md file. + +4. Copy the below code and replace with your github user name. Add after the last one in the file. + + * [yourusernamehere](https://github.com/yourusernamehere) + +5. Commit with a message. ( Or write "ALL IS WELL!") + +6. Make a pull request. [What is that?](https://help.github.com/articles/creating-a-pull-request-from-a-fork/) + +7. Done! Welcome to the dark side! + + +## How to contribute to this project +## Choose from these tasks +### 1. Add your name +Add your name to the `CONTRIBUTORS.md` file using the below convention: + +```markdown +#### Name: [YOUR NAME](GitHub link) +- Place: City, State, Country +- Bio: Who are you? +- GitHub: [GitHub account name](GitHub link) +``` + + +### 2. Create a A 'CODE' / Script in any Language +Add a `hello_world_yourusername.xx` script to the `scripts` directory in any language of your choice! Here is an example: + +```Javascript +// LANGUAGE: Javascript +// ENV: Node.js +// AUTHOR: Alice Chuang +// GITHUB: https://github.com/AliceWonderland + +console.log('Hello, World!'); + +``` + + +### 3. Add a profile page to the `profiles` directory + + + +#### Choose one or all 3, make a pull request for your work and wait for it to be merged! + +#### Happy Learning & Hacktoberfest ::: +No file chosen +Attach files by dragging & dropping, selecting or pasting them. + +Commit changes +Commit summary +Create README.md +Optional extended description +Add an optional extended description… + Commit directly to the master branch. + Create a new branch for this commit and start a pull request. Learn more about pull requests. + +© 2021 GitHub, Inc. +Terms +Privacy +Security +Status +Docs +Contact GitHub +Pricing +API +Training +Blog +About diff --git a/logo.png b/logo.png new file mode 100644 index 0000000..ede5946 Binary files /dev/null and b/logo.png differ