September 23, 2024, 08:32:44 PM

1,531,321 Posts in 46,731 Topics by 1,523 Members
› View the most recent posts on the forum.


I decided to step up to Guff's challenge

Started by ncba93ivyase, January 19, 2009, 11:18:13 PM

previous topic - next topic

0 Members and 3 Guests are viewing this topic.

Go Down

Gladjaframpf

So I've been working with MIPS assembly recently and you've inspired me to try some of the PE problems with it. I solved the first two, but I've run into a bit of a problem in that the assembler I'm using doesn't actually have all the MIPS opcodes built into it and I'd really like to be able to use bitwise logic operations so I might have to find a new assembler.

guff

oh shit of course he has to show up

at least i can still beat lawlz and jmv  baddood;

Daddy

so im on problem 3 and i think i did it right after some help on factorization and lists since i never used them.

now my code is taking a long time to run i hope it works ^___^

guff


Gladjaframpf

Quote from: andré the giant on January 23, 2009, 05:57:33 PM
oh shit of course he has to show up

at least i can still beat lawlz and jmv  baddood;


You've solved like twice as many PE problems as I have. akudood;

guff

Quote from: Gladjaframpf on January 23, 2009, 06:10:54 PM
You've solved like twice as many PE problems as I have. akudood;
yeah but i've had an account for a while now and i'm not using assembly language

Daddy

QuoteOverflowError: long int too large to convert to int

akudood; akudood; akudood; akudood;

Daddy

Code Select
#!/usr/bin/python
# Filename : Euler_003.py
# The prime factors of 13195 are 5, 7, 13 and 29.
# What is the largest prime factor of the number 600851475143?
EUL = 600851475143
#Function for finding primes
def isPrime(n):
import math
if n<2:
  return False #Negative Numbers, 0, and 1 are not prime.
elif n==2:
  return True #2 is Prime
elif n%2==0:
  return False #Even numbers, other than 2, are not prime.
else:
  for i in range(3, int(math.sqrt(n))+1,2):
   if n%i==0:
    return False #Number is composite
  else:
   return True  #All others are prime
#Find Factors
factor_list = []
primeFactors = []
i = 3
while True:
if EUL%i==0:
  while EUL % i == 0:
   EUL /= i
   factor_list.append(i)
if EUL == 1:
  break
i+=2 
#Take the list of factors and keep only the prime factors.
for factor in factor_list:
if isPrime(factor):
  primeFactors.append(factor)
print max(primeFactors)
giggle;

Gladjaframpf

Quote from: andré the giant on January 23, 2009, 06:13:15 PM
yeah but i've had an account for a while now and i'm not using assembly language


I actually did most of the problems I've done sometime last fall in Scheme.

Assembly isn't that bad for the easier ones, but it gets really messy when you need anything complicated. Function calls are horrible because you have to handle all the memory allocation manually.

ncba93ivyase


Quote from: ncba93ivyase on June 18, 2014, 07:58:34 PMthis isa great post i will use it in my sig

Daddy

Quote from: Pancake Persona on January 24, 2009, 02:11:30 AM
i think anyone can goonish
because lack of actually doing the programs because I don't care enough = lack of ability. psyduck;

guff

Quote from: Pancake Persona on January 24, 2009, 02:11:30 AM
i think anyone can goonish
jmv is actually doing okay for a beginner but what's your excuse  akudood;

ncba93ivyase

Quote from: andré the giant on January 24, 2009, 10:40:52 AM
jmv is actually doing okay for a beginner but what's your excuse  akudood;
laziness and the vidya and a highly irregular sleep schedule  that keeps me from ever being able to focus and apply myself to anything

And if anything, JMV should be the "professional" here since he is (or was) studying to be a computer scientist. I just slowly picked up Python over the summer. :O

Quote from: ncba93ivyase on June 18, 2014, 07:58:34 PMthis isa great post i will use it in my sig

Daddy

January 24, 2009, 11:04:23 AM #43 Last Edit: January 24, 2009, 11:09:52 AM by JMV
Just did problem 48  n_u
Code Select
#!/usr/bin/python
# Filename : Euler_048.py
#Find the last ten digits of the series, 1**1 + 2**2 + 3**3 + ... + 1000**1000
result = 0
for i in range(1,1001):
result+= i**i
print str(result)[-10:]



Quote from: Pancake Persona on January 24, 2009, 10:58:02 AMAnd if anything, JMV should be the "professional" here since he is (or was) studying to be a computer scientist. I just slowly picked up Python over the summer. :O
Because knowing one language makes you a professional in every programming language.
Write a compiler for Java so you don't have to use the JVM, since you know python and that makes you a professional in any language.
Also, as you said, my problem is:
Quote
laziness and the vidya and a highly irregular sleep schedule  that keeps me from ever being able to focus and apply myself to anything


ncba93ivyase

Quote from: JMV on January 24, 2009, 11:04:23 AM
Because knowing one language makes you a professional in every programming language.
when did i say we had to solve these in python

Quote from: ncba93ivyase on June 18, 2014, 07:58:34 PMthis isa great post i will use it in my sig

Go Up