-
Notifications
You must be signed in to change notification settings - Fork 156
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
Conversation
There was a problem hiding this 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.
* 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' |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
string s; | ||
cin>>s; | ||
int t=s[s.size()-1]-'0'; // last digit of the string | ||
if(t%2==0) |
There was a problem hiding this comment.
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.
@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:
To be honest, I am not too keen about the second proposal I made, partly because the list of subdirs in |
@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
later we want to add acm-icpc problems as well, so we can extend in this way. for dimikoj the folder structure should be
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 |
@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. |
Just wanted know should i change directory or folders or anything .Or should i wait |
@walleeva2018 I will wait until the infrastructure is ready to support this PR. |
https://lightoj.com/problem/dimik-even-odd-1