Forums - Open Redstone Engineers
Project Euler Solutions - Printable Version

+- Forums - Open Redstone Engineers (https://forum.openredstone.org)
+-- Forum: Off-Topic (https://forum.openredstone.org/forum-4.html)
+--- Forum: Programming (https://forum.openredstone.org/forum-8.html)
+--- Thread: Project Euler Solutions (/thread-2749.html)

Pages: 1 2


RE: Project Euler Solutions - Legofreak - 07-06-2015

I tried this for the first time today... I don't know any programming languages so I used scratch...

problem #1
[Image: euler%201_zpsw5injp9l.png]

I have a feeling I won't be solving any more of these...

edit:

took me long enough to figure out how to determine if something is even or odd...
problem #2
[Image: euler%202_zps2u5dn4uv.png]

and I figured out problem #5 on a calculator


RE: Project Euler Solutions - jxu - 07-10-2015

(07-06-2015, 09:25 PM)Legofreak Wrote: I used scratch

jesus it's probably better to use a calculator than this (i'm sure the first 20 are possible with only calculator)


RE: Project Euler Solutions - jxu - 10-18-2015

I can't stop doing these problems

They're just too interesting, too intriguing


RE: Project Euler Solutions - Hastumer - 11-10-2015

So I found myself installing Python and Sublime Text again to revive my Project Euler account. Project one solution:

Code:
x = 1
sol = 0
while x < 1000:
    m = x % 3
    if m == 0:
        sol += x
    else:
        m = x % 5
        if m == 0:
            sol += x
    x += 1
print(sol)
Pretty tiny for me actually! Only 12 lines of code! I bet you can do it with less, but that's actually fine for me!


RE: Project Euler Solutions - Hastumer - 11-10-2015

And I made the second one first try!

Code:
x = 1
y = 1
s = 0
while x + y < 4000000 and x + y * 2 < 4000000:
    x += y
    if x % 2 == 0:
        s += x
    y += x
    if y % 2 == 0:
        s += y
if x + y < 4000000:
    x += y
    if x % 2 == 0:
        s += x
    print(s)
else:
    print(s)



RE: Project Euler Solutions - VoltzLive - 11-12-2015

#1 in Python
Code:
sum([ x for x in range 1000 if (x % 3==0) | (x % 5 == 0)])

edit: even smaller


RE: Project Euler Solutions - jxu - 01-24-2016

Reduce is unnecessary (and deprecated in Python 3). sum() does the trick


RE: Project Euler Solutions - Chibill - 01-25-2016

Dang you Snh1