Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

https://www.hackerrank.com/challenges/kangaroo/problem #877

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ it will be redirected to the actual problem page)
- Add and commit the changes. (Please do not make changes in any other file, but if you want to work on bug/improvement then add an issue first)
- Don't forget to add your name, image url, country and the language used in contributors table in the README.md file
- Generate a Pull Request (Optional: add problem name in the title and url to the problem in description)
- That's it, you have successfully completed your 1 out of 5 PRs. Well Done!
- That's it, you have successfully completed your 1 out of 4 PRs. Well Done!


# How to Sync Forked Repo from Upstream Repo
Expand Down
19 changes: 19 additions & 0 deletions Hackerrank/kangaroo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/python3
import os

# Complete the kangaroo function below.
def kangaroo(x1, v1, x2, v2):
if v1 == v2: return "NO" # parallel lines never cross
n = (x2 - x1)/(v1- v2) # number of steps where lines intersect
return "YES" if n.is_integer() and n>=0 else "NO" # if intersect is a natural number

if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
x1V1X2V2 = input().split()
x1 = int(x1V1X2V2[0])
v1 = int(x1V1X2V2[1])
x2 = int(x1V1X2V2[2])
v2 = int(x1V1X2V2[3])
result = kangaroo(x1, v1, x2, v2)
fptr.write(result + '\n')
fptr.close()
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Hacktoberfest
# Hacktoberfest

[![Contribution Open](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/ows-ali/Hacktoberfest/blob/master/CONTRIBUTING.md)
[![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/ows-ali/Hacktoberfest/issues)
Expand Down Expand Up @@ -102,6 +102,7 @@ In this repository, you can find the solutions (as source code) for the problems
| [Nauman Chaudhary](https://github.com/nauman-chaudhary) <br> <img src="https://github.com/nauman-chaudhary.png" width="100" height="100"> | Pakistan | Python | |
| [Gourav Rusiya](https://github.com/GouravRusiya30) <br> <img src="https://github.com/GouravRusiya30.png" width="100" height="100"> | India | Java | https://www.hackerrank.com/gouravrusiya786 |
| [Trushita Maurya](https://github.com/trushita23) <br> <img src="https://github.com/trushita23.png" width="100" height="100"> | India | Java
| [Justin Giffard](https://github.com/justingiffard) <br> <img src="https://github.com/justingiffard.png" width="100" height="100"> | South Africa | Python | https://www.hackerrank.com/justingiffard |
### License

[![MIT Licence](https://badges.frapsoft.com/os/mit/mit.svg?v=103)](https://github.com/ows-ali/Hacktoberfest/blob/master/LICENSE)