Skip to content

Added Tutorial for Even Odd 1 #414

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

Closed
wants to merge 1 commit into from

Conversation

walleeva2018
Copy link
Contributor

Copy link
Member

@rebornplusplus rebornplusplus left a comment

Choose a reason for hiding this comment

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

Good efforts. Check my comments.

Comment on lines +6 to +12
* for each test case take the number as a string
* Check the last character of the string
* make it integer
* If its divisible by 2
* its a even number so print 'even'
* if its not divisible by 2
* its a odd number so print 'odd'
Copy link
Member

Choose a reason for hiding this comment

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

Lose the list and summarize it in a few sentences. (You shouldn't need much)
Additionally, you don't need to go all the way to taking the input as a string and checking the last character and all that.
The intended and easier approach would be to divide the number by 2 and checking the remainder. If the remainder is zero, then the number is even; otherwise, odd.

**C++ Implementation**

```
#include<bits/stdc++.h> // includes everything
Copy link
Member

Choose a reason for hiding this comment

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

Lose the comment. bits/stdc++.h doesn't necessarily include everything.

Comment on lines +26 to +29
string s;
cin>>s;
int t=s[s.size()-1]-'0'; // last digit of the string
if(t%2==0)
Copy link
Member

Choose a reason for hiding this comment

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

Change approach. As I mentioned earlier, this is not the simplest of ways.

@rebornplusplus
Copy link
Member

@faiyaz26 where do you want to keep these tutorials of problems with the dimik category? They don't have a number identifier associated with them. Is there any ongoing process to assign them a numerical identifier? If not, I propose the following paths:

  1. /dimik/<str:problem-identifer>
  2. /<str:problem-identifer>

To be honest, I am not too keen about the second proposal I made, partly because the list of subdirs in / is going to look a bit weird with numbers and strings (at least to me, it does 🤷‍♂️ ). But 2 does keep up with the consistency of lightoj problem links, which are of https://lightoj.com/problem/<number-or-string-identifier>.

@faiyaz26
Copy link
Member

@rebornplusplus we need to pause dimik oj problem tutorial addition, the crawler which automatically ingests tutorials from the repo needs some changes to support dimik oj problems. I am thinking to move all the LightOJ problem tutorials under

lightoj directory
and all the dimikoj problems are dimikoj directory.

later we want to add acm-icpc problems as well, so we can extend in this way.

for dimikoj the folder structure should be

dimikoj/[problem-handle]

so for this problem: https://lightoj.com/problem/dimik-even-odd-1

the tutorial should be in this folder:

dimikoj/dimik-even-odd-1/en.md

@rebornplusplus
Copy link
Member

@faiyaz26 Alright, sounds like a good plan. Please let me know when the crawler is ready. I will update the current structure and the README after that.

@walleeva2018
Copy link
Contributor Author

Just wanted know should i change directory or folders or anything .Or should i wait

@rebornplusplus
Copy link
Member

@walleeva2018 I will wait until the infrastructure is ready to support this PR.

@rebornplusplus rebornplusplus added the wontfix This will not be worked on label Feb 4, 2023
@rebornplusplus rebornplusplus added future-work We will be doing this sometime in future. and removed wontfix This will not be worked on labels Jun 21, 2023
@faiyaz26 faiyaz26 closed this Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
future-work We will be doing this sometime in future.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants