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

Organized, a few details added in competitive #5

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Organized, a few details added in competitive #5

wants to merge 6 commits into from

Conversation

diveshuttam
Copy link
Member

No description provided.

@sharmaeklavya2
Copy link
Member

Thanks for working on this.

However, I see several issues with your pull request. I think you should have talked to me before beginning work on it. But don't worry, we'll improve your pull request. You also have too many commits. I was expecting around 5 to 10 commits. I'll shortly begin review. After you fix all issues I point out, squash your commits into a few meaningful commits.

@sharmaeklavya2
Copy link
Member

Your pull request also seems incomplete, as can be seen in intro.md where you have included headings like backend, competitive, linux, etc. but you haven't given any links to them.

I have no problem with you trying to do everything in a single pull request, but usually people split their work across various pull requests depending on the type of work and submit them one by one. You could have, for example, submitted work on competitive programming in one pull request, work on organizing tools, adding license, etc. in another pull request.

@sharmaeklavya2
Copy link
Member

I don't think we need a verbatim copy of a license in a LICENSE file. Just stating the licenses in readme.md and linking to them seems enough to me. Also, the license you have included is GPLv3, while we currently don't have any code which can be covered by it. I suggest you remove the LICENSE file.

@sharmaeklavya2
Copy link
Member

All file and directory names should be lowercase and hyphen-separated.
So for example, Competitive Programming should be changed to competitive-programming.

This is needed because these file and folder names will be part of URLs and it is a best practice to keep URL names lowercase (so that they are easily memorizable). URLs shouldn't have spaces between them, otherwise we'll have to use ugly %20s everywhere. Underscores are okay for URLs but they cause trouble when writing URLs in markdown, so avoid underscores as well.

@sharmaeklavya2
Copy link
Member

I'm not convinced that we need a TC to GCC porting guide. We should just tell them that TC is not standards-compliant and they should look at code written for GCC to find out what all changes do they need. There aren't many changes except those related to IO and standard libraries, and people should look up docs for them anyways (because they have a lot of important information), whether they used TC previously or not.

I too used non-standard C++ (Visual C++ 1998) in school, but switching was easy once I looked at one or two GCC-targeted programs.

@sharmaeklavya2
Copy link
Member

sharmaeklavya2 commented Sep 22, 2017

I'm sorry to say that you have done a bad job at writing English. Your sentences have many grammatical and typographical errors. You have not used or incorrectly used punctuation. Your sentences are sometimes too long and need to be split. Please be vigilant and avoid making such mistakes in the future. I'm not just referring to these articles, but anything you write in the future.

Copy link
Member

@sharmaeklavya2 sharmaeklavya2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have completed my review. Reviewing took a lot of time, since you had a lot of new material and there are lot of issues to be addressed. It's great that you took out the time to write a C to C++ porting guide.

I think you are a bit verbose. I'm not sure whether what you have written can be written in lesser words, but try to do it if possible.

Please take care of your spelling and grammar. Before sending any pull requests, do a critical proofreading to ensure that no mistakes have crept in.

If you disagree with anything I have said, feel free to mention it and we'll discuss what the right solution can be.

I didn't check, but if you have written parts of the article in a personal tone (like using words like 'I', 'me', etc.) please mention yourself as the author in the beginning of the article.

@@ -30,10 +30,12 @@ If you know only C, you can easily start.
But at some point of time (especially when you reach advanced stages),
you'll need features which most languages have but C does not.
Learning C++ is very easy if you know C.
If you already know C, you should start competitive programming in C and learn C++ in parallel.
If you already know C, you should start competitive programming in C and learn C++ in parallel. You may refer to [C to C++ for Competetive](c2cpp.md) after you solve [a few basic problems](#making-the-first-step) for a brief intro and resources .
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be changed to

You may refer to C to C++ for Competitive Programming for a brief intro and resources after you solve a few basic problems using C.

Also, avoid using too long lines in markdown. This sentence should come in the next line and not in the same line as 'If you already know C, ...'.

Competitive programming is also a good way to practice a new language you have learned.
Competitive programming is also a good way to practice a new language you have learned.

If you have no prior knowledge you can begin with [CS50 2016](http://cs50.tv/2016/fall/) (week 0 to week 5) (it teaches c which anyways is useful as its part of BITS Curriculum)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/its/it's (It means replace its by it's).
s/it teaches c which anyways is useful/it teaches C, which is anyways useful
s/Curriculum/curriculum

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split sentence into multiple lines. Preferably less than 80 to 100 characters per line.

@@ -78,7 +80,9 @@ If you have never before solved a problems on an online judge, you can begin by
the easiest problem on Codechef - [Life, the Universe, and Everything](https://www.codechef.com/problems/TEST).
You will have to read the [Input/Output tutorial](http://blog.codechef.com/2009/02/24/54/) to solve the problem.
If you face problems, you can refer to [Eklavya's solutions](https://www.codechef.com/status/TEST,sharmaeklavya2).
He has submitted code in many languages, so you'll most likely find a solution in the language of your choice.
He has submitted code in many languages, so you'll most likely find a solution in the language of your choice.
Also codechef has [screencasts](https://www.youtube.com/playlist?list=PLi0ZM-RCX5ntfqwXRirwA_pcufHinjllG) explaining this problem in c,c++ and java
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Also/Also,

Split sentence into multiple lines.

s/c,c++ and java/C, C++ and Java.
Use title-case for language names.
Always end a sentence with a full stop.
Add a space after a comma.

He has submitted code in many languages, so you'll most likely find a solution in the language of your choice.
He has submitted code in many languages, so you'll most likely find a solution in the language of your choice.
Also codechef has [screencasts](https://www.youtube.com/playlist?list=PLi0ZM-RCX5ntfqwXRirwA_pcufHinjllG) explaining this problem in c,c++ and java
After this you can move on to more problems from [codechef beginner section](https://www.codechef.com/problems/school?sort_by=SuccessfulSubmission&sorting_order=desc) these problems mostly require only basic knowledge of programming(arrays, strings, loops) and math/logic. The ones with the code like FLOW??? are particularly very easy and can help you get aquainted with submissions on online judges.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this line a new paragraph and split it into multiple lines.

s/) these problems/). These problems
s/programming(arrays/programming (arrays

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is FLOW????

@@ -130,12 +134,12 @@ and he got AIR 7 in a Codechef Long challenge!

## Compiler

One frequently asked question is what compiler or IDE to use.
One frequently asked question is what [compiler or IDE](#diff) to use.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does #diff link to?


int main()
{
int t;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please indent your code.

return 0;
}
```
To compile this program on linux use `gcc --std=c++11 filename.cpp -o example` to run use `./example`. For codeblocks use build and run in build menu.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/build and run/'build and run'

}
```

the line cin>>a>>b>>c; is es exactly same as cin>>a; cin>>b; cin>>c; this is known as cascading of `>>` operator similarly we have the next line where `<<` operator is cascaded.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surround in-line code by backticks.

To compile this program on linux use `gcc --std=c++11 filename.cpp -o example` to run use `./example`. For codeblocks use build and run in build menu.

# NEW in CPP (useful for competitive)
## easier IO (cin and cout)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know about C++ IO being slower? I think it's worth mentioning that, since beginners will have no idea why they're getting TLE otherwise.

intro.md Outdated
@@ -0,0 +1,7 @@
This file has an intro for various articles in this repository

## Backend
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you forgot to add links.

@sharmaeklavya2
Copy link
Member

When you want me to review it again, inform me by posting a comment on this thread.

@diveshuttam
Copy link
Member Author

I am still working on this. Will update soon.

@diveshuttam
Copy link
Member Author

Thanks for a detailed review, I have tried to incorporate the suggested changes. I also need guidance in improving C to C++ guide. Please tell if you want any material to be added/ removed. I too feel that it is getting a bit comprehensive.

@sharmaeklavya2 sharmaeklavya2 dismissed their stale review September 25, 2017 17:02

There has been a force push and it's difficult to track whether these issues were addressed or not.

@sharmaeklavya2
Copy link
Member

I think you should remove your second snippet and everything after that and before (but not including) the point about <iostream> being slow. That's because you don't need to give a detailed explanation about what <iostream> does. Just tell people that cin works like scanf and cout works like printf and your first snippet explains cin and couts interface, which is probably the only thing different between them and scanf/printf.

Copy link
Member

@sharmaeklavya2 sharmaeklavya2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CP1.md looks good except for a few issues I have pointed out and that you should split long lines.

c2cpp.md still has long lines and occasional lexical issues, in addition to issues I have explicitly commented on.

@@ -31,10 +31,14 @@ But at some point of time (especially when you reach advanced stages),
you'll need features which most languages have but C does not.
Learning C++ is very easy if you know C.
If you already know C, you should start competitive programming in C and learn C++ in parallel.
> You may refer to [C to C++ for Competitive Programming](c2cpp.md) for a brief intro and resources after you solve [a few basic problems](#making-the-first-step) using C.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should remove the > symbol from the beginning of the line.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split this sentence into 2 lines.

@@ -135,14 +144,14 @@ One frequently asked question is what compiler or IDE to use.
If you have Linux or Mac, it is best to use:

* gcc for C
* g++ for C++
* javac for Java (both oracle and openjdk are good)
* gcc/g++ for C++
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although it's possible to compile C++ code using gcc, it's much more convenient to use g++. I think you should change 'gcc/g++' to 'g++', since this article is aimed at beginners and we don't want to trouble/confuse them by making them try gcc to compile C++ code.

1) Porting C's code to C++
2) A couple of things new/different in C++ w.r.t C and are useful for competitive.

## Prerequisite
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change it to 'Prerequisites'.


We require that you are aware of at least the following concepts in C:

* Basic Syntax of C
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything in this list (loops, arrays, functions) is 'Basic Syntax of C', so remove this point and make 'Basic Input and Output' and 'Operators' first-level points.

We will be using the line `#include<bits/stdc++.h>` in our code to resolve all issues at once.
`<bits/stdc++.h>` is basically a header file containing all the standard C++ header files (header files for C/C++ , most STL files etc.).
Though it's not a good development practice to include unnecessary headers. It is pretty common in competitive,
as judges use runtime for the time limit and this only increases my compile time and not my runtime.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove 'my's from this sentence. <bits/stdc++.h> increases everyone's compile time, not just yours.

int main()
{
int a,b;
char Str[10];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should set a good example for others by not beginning variable names with an uppercase character. Identifiers which begin with an uppercase character are generally used as class names. Identifiers in which all characters are uppercase are generally macros or constants.

1 2
Hello World
```
In the real scenario, I will press 1 'space' 2 'enter' Hello 'space' World 'enter'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to explain this?

c=Hello
```
Note:
1. Though the input is broken at whitespaces, `cin>>something;` is not executed while you are typing the input. It is only executed after pressing enter.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what you mean by this. something isn't defined in your snippet above so I think you're talking about using cin in general. If the input buffer doesn't contain everything cin wants, it will perform a read system call. The system call will block unless you type something and press enter. So technically, while the user is typing, cin>>something is being executed.

Note:
1. Though the input is broken at whitespaces, `cin>>something;` is not executed while you are typing the input. It is only executed after pressing enter.
That makes us type in `Hello world` without reaching `return 0;`.
2. Multiple whitespaces between the input are ignored while using cin.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to explain points like this, because cin takes input in exactly the same way as scanf afaik.

To compile this program on linux, use `gcc --std=c++11 filename.cpp -o example` to run use `./example`.
For Code::Blocks use `build and run` in the build menu.

## New in C++ (useful for competitive)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should change 'New' to 'Extra', since C++ is a fairly old language.

@diveshuttam
Copy link
Member Author

Just for the update:
I have been a bit busy for the last week. I will rectify these by the end of next week.

@sharmaeklavya2
Copy link
Member

I'll probably be busy till midsems, so take your time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants