« first day (60 days earlier)      last day (590 days later) » 

1:22 AM
@edwinksl you're here ?
 
1:43 AM
just back from outside
what's up
 
well I actually recode a few things to keep stuff fresh in my head and just did the collatz function,
my result is this:
def collatz(value):
    counter = 0
    while value != 1:
        if value % 2 == 0:
            value /= 2
        else:
            value = value * 3 + 1
        counter += 1
        print("Step: " + str(counter) + " Value: " + str(value))
    print("After " + str(counter) + "steps value is 1")
whell the if part i would write in c++ ilke this:
 
that looks ok
 
value = value % 2 == 0 ? value / 2 : value * 3 + 1;
 
did you eventually reach 1
 
is there something like that in python?
i did
 
so it would be:
value = value / 2 if value % 2 == 0 else value * 3 + 1
?
yes seems so
just tested it
 
yup that's correct
 
/usr/bin/python3.5 /home/michael/python/learning/collatz.py 50
Step: 1 Value: 25.0
Step: 2 Value: 76.0
Step: 3 Value: 38.0
Step: 4 Value: 19.0
Step: 5 Value: 58.0
Step: 6 Value: 29.0
Step: 7 Value: 88.0
Step: 8 Value: 44.0
Step: 9 Value: 22.0
Step: 10 Value: 11.0
Step: 11 Value: 34.0
Step: 12 Value: 17.0
Step: 13 Value: 52.0
Step: 14 Value: 26.0
Step: 15 Value: 13.0
Step: 16 Value: 40.0
Step: 17 Value: 20.0
Step: 18 Value: 10.0
Step: 19 Value: 5.0
Step: 20 Value: 16.0
Step: 21 Value: 8.0
Step: 22 Value: 4.0
 
some people don't like it because the order seems unintuitive
 
yeah kinda, the c++ one makes more sense
 
1:52 AM
to each his/her own
some will prefer the if else
eg thomas w prefers explicit if else
 
well depends sometimes its easier to write a ternary operator for readability
well now lets see if i can remember the greatest common divisor solutions
 
2:22 AM
def gcd_bruteforce(value_one, value_two):
    if value_one > value_two:
        divisor = value_two
    else:
        divisor = value_one
    while value_one % divisor != 0 or value_two % divisor != 0:
        divisor -= 1
    print("The gratest common divisor of " + str(value_one) + " and " + str(value_two) + " is " + str(divisor))
now only two left euklid version and the quick euklid version
 
you could use python to finish project euler ;D
 
:p
well like i said this is only to keep stuff memorized
after that bubble sort and tree sort
 
only requires slightly modification of what you had
probably should use memoization to speed it up
 
2:29 AM
yeah sure needs a store of all results
 
if not, i think it runs in decent time, no big deal
 
and this would be a big big database at the end
and to prove euler right would mean to cover the whole number room we deem worthy as solution and that would be more than one googol
imagine theres even a boinc project for that
and they are not done yet and it runs since years already
The Collatz conjecture is a conjecture in mathematics named after Lothar Collatz, who first proposed it in 1937. The conjecture is also known as the 3n + 1 conjecture, the Ulam conjecture (after Stanisław Ulam), Kakutani's problem (after Shizuo Kakutani), the Thwaites conjecture (after Sir Bryan Thwaites), Hasse's algorithm (after Helmut Hasse), or the Syracuse problem; the sequence of numbers involved is referred to as the hailstone sequence or hailstone numbers (because the values are usually subject to multiple descents and ascents like hailstones in a cloud), or as wondrous numbers. The...
 
3:02 AM
if you're succeeding to prove collatz right, youre a rich man :) 5 million dollars richer than before
its one of the millennium problems
 
not worth it :D
unfortunately mathematics is not a field where novices can actually luck out and beat the experts
it simply doesn't happen
 
yep
but i love maths tho
still i not studied it
 
3:30 AM
but my solution for this problem nr 14 on euler.net i got this:
def collatz(value):
    start = value
    counter = 0
    while value != 1:
        if value % 2 == 0:
            value /= 2
        else:
            value = value * 3 + 1
        counter += 1
    return [start, counter]

if __name__ == "__main__":
    max_steps = [0, 0]
    for number in range(1, 1000000):
        result = collatz(number)
        if result[1] > max_steps[1]:
            max_steps = result
    print("The number below 1,000,000 which took the most steps to calculate is:")
    print(str(max_steps[0]) + " with " + str(max_steps[1]) + "steps.")
999994 : 113
999995 : 258
999996 : 113
999997 : 113
999998 : 258
999999 : 258
The number below 1,000,000 which took the most steps to calculate is:
837799 with 524steps.
 
3:53 AM
is that the correct answer?
 
well according to my script yes
 
what does project euler say :P
 
dunno im not registred there
and i cant find anything wrong in my script
it iterates over all numbers from 1 to 999999 and only if it finds a result with a higher step count it gets saved
 
4:13 AM
oh lord
i was half-expecting that video
 
lol
i have no clue but it seems the right answer tho
 
didnt even take long to compute
 
hope you watched that video
i died laughing
 
yes i did
 
4:17 AM
gnomegnomegnomegnomegnome
 
:p
lets ask serg ?
 
it appears i did solve #14 a long time ago lmao
 
and ?
 
Answer:
837799
 
ok so my script was right :)
The number below 1,000,000 which took the most steps to calculate is:
837799 with 524steps.
 
4:31 AM
i honestly can't remember when i did this
 
lol
did you study informatics ?
 
no
 
ok because collatz is mostly used in the basic programming lesson (1st semester)
 
your favorite user is back askubuntu.com/questions/796879/…
this is like his 7th hbase question
 
looks good for a normal ubuntu user and is a correct output, unless you watch it from my viewpoint then it is outdated
im on the proposed branch ;)
but a good thing to go through, this euler.net page
at least its better as solving cross-words for getting your brain in action
 

« first day (60 days earlier)      last day (590 days later) »