Skip to content

Instantly share code, notes, and snippets.

@Cooops
Last active April 8, 2019 18:49
Show Gist options
  • Save Cooops/b6ea05ff275fb0e444f91673f8ba4d56 to your computer and use it in GitHub Desktop.
Save Cooops/b6ea05ff275fb0e444f91673f8ba4d56 to your computer and use it in GitHub Desktop.
"""
Asha and Kelly are programming, but Asha practices more than Kelly. Not wanting to fall behind, Kelly resolves to practice more.
They each solve a number of problems in a day. Asha has already solved more problems than Kelly. What is the minimum number of days
it will take for Kelly to have solved more problems than Asha?
For example, if Asha is 5 problems ahead of Kelly and they solve 3 and 5 problems a day, Asha will be ahead by only 3 after the first day,
1 after the second, and Kelly will pass Asha on day 3.
------------------------------------------------------------------------------------------------------------------------------------------
Your task is to write a program which:
- calculates the number of days needed by Kelly to catch up
- return -1 if it's impossible
------------------------------------------------------------------------------------------------------------------------------------------
Sample Input:
def minNum(A, K, P):
...
minNum(A=8, K=9, P=2)
Sample Output:
"it would take her 3 days"
Sample Input:
def minNum(A, K, P):
...
minNum(A=8, K=8, P=2)
Sample Output:
"-1"
"""
Your task is to write a program which:
- accepts as input a C, C++ or Java Program on multiple lines of text
- ouputs only the comments from those programs
Ex:
// this is a single line comment
int x =1; // a single line comment after the code
/* This is one way of writing comments */
/* This is a multi-line comment.
It spans several lines.
This is often more convenient for the programmer. */
/*
* This is also multi-line
*/
Precautions:
- Do not add any leading or trailing spaces.
- Do not alter the line break structure of multi-line comments (e.g by collapsing multiple lines into one)
- You should, however, remove any white-space characters that precede a comment.
Constraints:
- The source code will have no more than 200 lines of text.
Output:
- From the program given to you, remove everything other than the comments.
------------------------------------------------------------------------------------------------------------------------------------------
Sample Input:
/* This program does nothing and is just an example. */
# include <stdio.h>
int main()
{
printf('does nothing') // more comments here
}
/* These are the final comments. We want to strip everything that isn't a comment. */
Sample Output:
/* This program does nothing and is just an example. */
// more comments here
/* These are the final comments. We want to strip everything that isn't a comment. */
"""
@rkcts
Copy link

rkcts commented Apr 8, 2019

I want solution for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment