Many languages are best learnt by practice and thought. A lot of people want programming challenges to help exercise their programming knowledge. I thought i would share a website which currently contains 448 consecutive programming challenges, ranging from beginner to advanced.
http://projecteuler.net/
"Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems."
The challenges on that website are not specific to any particular language, you should be able to solve most with any good programming language. But in undertaking these problems, i suggest that you stick to a higher-performance language for the large mathematical tasks. i stongly recommend Haskell to you, its tutorial is found here:
http://learnyouahaskell.com/chapters
Hope this is helpful and interesting to everyone 🤝
Shit, I hate to bump 3 year old threads but I found these challenges to be helpful with exercising my critical thinking and mathematical skills. Nice share.
I don't middleman any deals on- or off-site. Please don't message me requesting my past services and certainly don't fall for anybody who claims to be me.
DO NOT DEAL WITH THIS MEMBER
Aug 19, 2016 03:31 PM
(This post was last modified: Aug 19, 2016 03:32 PM by Mr.Motivation.)
(Aug 19, 2016 06:05 AM)minimalist Wrote: Shit, I hate to bump 3 year old threads but I found these challenges to be helpful with exercising my critical thinking and mathematical skills. Nice share.
Thanks! :D
Didnt know how much slower if statements make your code, noticed it on one of the challenges.
problem: 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
i did it first like this
Code #include "Includes.h"
int smallNumber = 20;
int divider = 1;
int main()
{
while (true)
{
if (smallNumber % divider != 0)
{
smallNumber += 20;
divider = NULL;
}
if (divider <= 20)
{
divider++;
}
else if (divider == 20)
{
cout << "smallest positive number that is evenly divisible by all of the numbers from 1 to 20: " << smallNumber << endl;
break;
}
}
}
it takes forever to get to the right number.
but if you do it like this
Code int i = 20;
while (i % 2 != 0 || i % 3 != 0 || i % 4 != 0 || i % 5 != 0 ||
i % 6 != 0 || i % 7 != 0 || i % 8 != 0 || i % 9 != 0 ||
i % 10 != 0 || i % 11 != 0 || i % 12 != 0 || i % 13 != 0 ||
i % 14 != 0 || i % 15 != 0 || i % 16 != 0 || i % 17 != 0 ||
i % 18 != 0 || i % 19 != 0 || i % 20 != 0) {
i += 20;
}
it takes less than a second lol
(Aug 19, 2016 03:31 PM)Mr.Motivation Wrote: Thanks! :D
Didnt know how much slower if statements make your code, noticed it on one of the challenges.
problem: 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
i did it first like this
Code #include "Includes.h"
int smallNumber = 20;
int divider = 1;
int main()
{
while (true)
{
if (smallNumber % divider != 0)
{
smallNumber += 20;
divider = NULL;
}
if (divider <= 20)
{
divider++;
}
else if (divider == 20)
{
cout << "smallest positive number that is evenly divisible by all of the numbers from 1 to 20: " << smallNumber << endl;
break;
}
}
}
it takes forever to get to the right number.
but if you do it like this
Code int i = 20;
while (i % 2 != 0 || i % 3 != 0 || i % 4 != 0 || i % 5 != 0 ||
i % 6 != 0 || i % 7 != 0 || i % 8 != 0 || i % 9 != 0 ||
i % 10 != 0 || i % 11 != 0 || i % 12 != 0 || i % 13 != 0 ||
i % 14 != 0 || i % 15 != 0 || i % 16 != 0 || i % 17 != 0 ||
i % 18 != 0 || i % 19 != 0 || i % 20 != 0) {
i += 20;
}
it takes less than a second lol
It's not the if statements that are slow, it's the fact that you are looping may more times in the first code that in the second. The second code is not particularly elegant though, and isn't easily modified to other numbers. The problem is really just looking for the lowest common multiple of all the numbers.
But nice work, good to see some more members taking interest :)
I love programming challenges. I have a list of other coding related challenges as well.
You have the StockFighter challenge set, which has two different challenges. You have StockFighter Jailbreak, which focuses on lower level stuff. Then you have StockFighter trading, which involves coding challenges centered around using a fake stock trading API to make certain things work. Both can be found here: https://www.stockfighter.io/
Then you have the Eudyptula challenge, which focuses on the Linux Kernel and other fun Kernel stuff. http://eudyptula-challenge.org/
Lastly, you also have crypto pals, which is a programming and cryptography challenge set aimed at teaching crypto. http://cryptopals.com/
DO NOT DEAL WITH THIS MEMBER
(Aug 19, 2016 04:48 PM)SIM-2015410 Wrote: It's not the if statements that are slow, it's the fact that you are looping may more times in the first code that in the second. The second code is not particularly elegant though, and isn't easily modified to other numbers. The problem is really just looking for the lowest common multiple of all the numbers.
But nice work, good to see some more members taking interest :)
oh yeah didnt notice that :P
makes sense now, ty for info 🤝
DO NOT DEAL WITH THIS MEMBER
Wow, finally one interesting thread.
I've been practicing on www.hackerrank.com in my spare time. They have thousands of challenges. Usually the easy ones are extremely hard.
I would recommend you guys check it out and see how it works.
You earn Hackos by solving challenges. And each code submitted has up to 20 test cases. If you cannot figure out which one is failing and why, you can buy that test case using your earned Hackos and see why it's failing.
Various topics and they just keep adding and adding stuff and have so many languages to choose from.
(Aug 20, 2016 03:30 PM)Steve Miller Wrote: Wow, finally one interesting thread.
I've been practicing on www.hackerrank.com in my spare time. They have thousands of challenges. Usually the easy ones are extremely hard.
I would recommend you guys check it out and see how it works.
You earn Hackos by solving challenges. And each code submitted has up to 20 test cases. If you cannot figure out which one is failing and why, you can buy that test case using your earned Hackos and see why it's failing.
Various topics and they just keep adding and adding stuff and have so many languages to choose from.
Sounds Cool.
The site I currently use for training for competitive programming contests is open.kattis.com which is also very good
DO NOT DEAL WITH THIS MEMBER
I will check it out. hackerrank also also has competitions (some big ones too, I won't even attempt the small ones yet even), it even suggests some new challenges for you based in what you were practicing last.
Thanks.
|