\
  The most prestigious law school admissions discussion board in the world.
BackRefresh Options Favorite

Best python learning resource on the internet, by FAR

http://xoxohth.com/thread.php?thread_id=3675303&mc=26&am...
Jeff Tezos [1-0 in Proj Euler challenges](socatoa)
  07/14/17
That was very helpful ty. I take it "map" is ju...
"'"
  07/14/17
Yes, it is a built-in. 0xA0a22836Dce4Eb20C73Ff15520F8abE7...
Jeff Tezos [1-0 in Proj Euler challenges](socatoa)
  07/14/17
1. names = ["Alice", "Bob", "Carol...
Evan39's Chad
  07/15/17
In the future you should indent. 1. Good work. An even...
Jeff Tezos [1-0 in Proj Euler challenges](socatoa)
  07/15/17
1. ty 2. lol i didnt know that built in feature existed 3....
Evan39's Chad
  07/15/17
That will be 0.05 ETH 0xA0a22836Dce4Eb20C73Ff15520F8abE7F...
Jeff Tezos [1-0 in Proj Euler challenges](socatoa)
  07/15/17
lol fma
Evan39's Chad
  07/15/17


Poast new message in this thread



Reply Favorite

Date: July 14th, 2017 11:52 PM
Author: Jeff Tezos [1-0 in Proj Euler challenges](socatoa)

http://xoxohth.com/thread.php?thread_id=3675303&mc=26&forum_id=2#33777686

socatoa's lessons

(http://www.autoadmit.com/thread.php?thread_id=3675368&forum_id=2#33777921)



Reply Favorite

Date: July 14th, 2017 11:55 PM
Author: "'"

That was very helpful ty.

I take it "map" is just a built in python function/method?

Haven't had a chance to finish reading but will do so soon

(http://www.autoadmit.com/thread.php?thread_id=3675368&forum_id=2#33777941)



Reply Favorite

Date: July 14th, 2017 11:56 PM
Author: Jeff Tezos [1-0 in Proj Euler challenges](socatoa)

Yes, it is a built-in.

0xA0a22836Dce4Eb20C73Ff15520F8abE7FBe8bA47

Understanding map is a key conceptual building block to understanding comprehensions, which are the killer feature of Python.

(http://www.autoadmit.com/thread.php?thread_id=3675368&forum_id=2#33777949)



Reply Favorite

Date: July 15th, 2017 12:51 AM
Author: Evan39's Chad

1.

names = ["Alice", "Bob", "Carol"]

def length_string(x):

return len(x)

result = map(length_string,names)

print(list(result))

2.

numbers = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ]

def sum_nums(x):

return x[0]+x[1]+x[2]

result = map(sum_nums,numbers)

print(list(result))

3.num = [2, 3, 4, 5, 6, 7, 8, 9, 10]

def check_prime(x):

y = 2

if x <= 3:

return "true"

while x / y >= 2:

if x % y == 0:

return "false"

y = y + 1

return "true"

result = map(check_prime,num)

print(list(result))



(http://www.autoadmit.com/thread.php?thread_id=3675368&forum_id=2#33778329)



Reply Favorite

Date: July 15th, 2017 1:05 AM
Author: Jeff Tezos [1-0 in Proj Euler challenges](socatoa)

In the future you should indent.

1. Good work.

An even better solution would be map(len, names).

No need to write a wrapper function around len, when there is already a built-in len function that does the job itself!

2. A better solution than yours:

numbers = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ]

def sum_nums(lst):

... return sum(lst)

Your solution would only add arrays of length 3.

Or better yet, just write: map(sum, numbers)

No need to define a sum function when you can just leverage the built-in one!

3.

-- You should use the boolean types True and False, since that is what is required by the result.

-- According to your prime function, 1 and all negative numbers are prime. That might seem like an insignificant mistake, but it would likely come back to haunt you if, for example, you wrote some recursive function that relied on checking results for smaller primes.

--Your solution is extremely inefficient in doing a division in the "while loop" check. Division is hundreds of times more expensive than addition or multiplication for computers. A far more efficient check would be "while x >= 2*y"

--Your solution is a little inefficient in that you can stop once y exceeds sqrt(x) in value.

def check_prime(x):

....y = 2

....if x <= 3:

........return True

....while x / y >= 2:

........if x % y == 0:

............return False

........y = y + 1

....return True

(http://www.autoadmit.com/thread.php?thread_id=3675368&forum_id=2#33778419)



Reply Favorite

Date: July 15th, 2017 1:09 AM
Author: Evan39's Chad

1. ty

2. lol i didnt know that built in feature existed

3.a. i was going to google how to output boolean but was lazy lol

b. prime #s was one of the few euler type problems that i am good with just banging it out but u are 100% correct

tyty for the feedback. great lesson man.

(http://www.autoadmit.com/thread.php?thread_id=3675368&forum_id=2#33778441)



Reply Favorite

Date: July 15th, 2017 1:08 AM
Author: Jeff Tezos [1-0 in Proj Euler challenges](socatoa)

That will be 0.05 ETH

0xA0a22836Dce4Eb20C73Ff15520F8abE7FBe8bA47

(http://www.autoadmit.com/thread.php?thread_id=3675368&forum_id=2#33778434)



Reply Favorite

Date: July 15th, 2017 1:09 AM
Author: Evan39's Chad

lol fma

(http://www.autoadmit.com/thread.php?thread_id=3675368&forum_id=2#33778443)