Maths and programming

Discuss, argue, whine, talk but not about Elma.

Moderator: Moporators

Post Reply
User avatar
Mawane
Kuski
Posts: 3299
Joined: 15 Apr 2007, 01:05
Team: SV
Contact:

Maths and programming

Post by Mawane »

I found an interesting website that some of you maybe already know.
https://projecteuler.net/problem=36
It gives maths programming challenges and I'd be interested on you you guys solve them and explain here. I don't know much about programming, but I'm looking forward to see your solutions explained!

Code: Select all

The decimal number, 585 = 10010010012 (binary), is palindromic in both bases.

Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2.

(Please note that the palindromic number, in either base, may not include leading zeros.)
Another one, this one cannot be pasted here with format:
https://projecteuler.net/problem=225

Post your own challenges too, hoping for something I can solve lol.
Website || TT:41:45:64 || Team Image
Image[url=steam://friends/add/76561198025490048]Image[/url]
User avatar
ElrondMcBong
Kuski
Posts: 230
Joined: 10 Aug 2004, 18:45

Re: Maths and programming

Post by ElrondMcBong »

I am studying Mathematics in 5th semester now and didn't know about this site :oops:

The "challanges" are rather simple, but there is lot of potential to optimize the runtime.
Maybe when i have some spare time i can solve some of them :)
User avatar
anpdad
38mins club
Posts: 933
Joined: 6 Nov 2003, 06:04
Location: Russia

Re: Maths and programming

Post by anpdad »

Well, the point is exactly in optimizing the runk time im think. Imo it good siteik, prety usful, so if you have enough willpower to force you to solve stuff on a regular basis, it'll be helpful in polishing you're skils xDxD

I think i lasted two days (and like 40 problemiks) before i got tired and got bak to wasting time playing video gams 24/7.
User avatar
Tigro
Kuski
Posts: 2198
Joined: 6 Jan 2009, 13:08
Location: Srdcom vychodniar
Contact:

Re: Maths and programming

Post by Tigro »

to MW's problem: Trying half a million numbers with brute force doesn't take so much time... (exclude all even numbers)
Image
User avatar
Mawane
Kuski
Posts: 3299
Joined: 15 Apr 2007, 01:05
Team: SV
Contact:

Re: Maths and programming

Post by Mawane »

yeah, but later in problems, bruteforce isnt an option unless you want to wait couple years xD anyway, thats the ez way, there should be a smarter way I guess
Website || TT:41:45:64 || Team Image
Image[url=steam://friends/add/76561198025490048]Image[/url]
User avatar
anpdad
38mins club
Posts: 933
Joined: 6 Nov 2003, 06:04
Location: Russia

Re: Maths and programming

Post by anpdad »

Bruteforcik works for most problems on that site, and if you solve the problem by any means, you can access a detailed answer (at least that's how it used to be couple years ago, dunno now) that usually describes several more and more optimized solutions. It kinda destroys all the fun and doesn't improve your skills much, so imo should always avoid bruteforce.
User avatar
Stini
39mins club
Posts: 202
Joined: 5 Dec 2002, 22:15
Team: ICE
Location: Helsinki, Finland

Re: Maths and programming

Post by Stini »

I think I've solved a bit over 100 problems from projecteuler, but the site doesn't allow logging in atm so I can't check for sure. I much prefer ICPC type of problems though, where the emphasis is on programming rather than math (check eg. http://uva.onlinejudge.org/ dunno if this is the best source for problems though).

Here's a stupid and ugly one-liner for 36

Code: Select all

print sum([x for x in xrange(1000000) if bin(x)[2::] == bin(x)[:1:-1] and str(x) == str(x)[::-1]])
User avatar
Zweq
34mins club
Posts: 4055
Joined: 28 Nov 2002, 15:54
Location: suo mesta

Re: Maths and programming

Post by Zweq »

Stini told me about this site couple of years ago when I was a complete beginner. For example I tried to solve the problem #1 without knowing what modulo is :D. Nowadays I have around 80 problems solved, can't say for sure because the website seems to have been hacked. I haven't solved any problems for a year or so though : -( I usually just did brute force solutions in python. I liked the process of understanding a problem and making own idiot solution for it, without caring about efficiency, and receiving the rewarding congratulations! -message. (ofc good fun also to see pro mans elegant solutions on the forums)
Image
badyl
37mins club
Posts: 175
Joined: 12 Sep 2010, 20:41

Re: Maths and programming

Post by badyl »

Have a go on this:

(Not sure about the translation correctness)
Some numbers have the property of "power sum":
If we take n-digit long number and add the n-th powers of all digits we get that number.
For example 153 has this property: 153=1^3+5^3+3^3
There are 7 prime number which have this property. Find them.

I got it from IT University lecturer. He said it was possible in time under 1 minute on usual PC.
Image
Post Reply