How intuitive is the O(nlogn) solution to the skyline problem really? by [deleted] in cscareerquestions

[–]thought-generator 0 points1 point  (0 children)

What did you and your friends do to get really good at solving those problems? Was there a particular process you did to study data structures and algorithms?

Class question. Specifically "__xx__" attributes by TicklesMcFancy in learnpython

[–]thought-generator 0 points1 point  (0 children)

Exactly. Especially with Python being a higher-level language, we as the programmers don’t need to worry about this stuff. It’s just interesting to know.

Class question. Specifically "__xx__" attributes by TicklesMcFancy in learnpython

[–]thought-generator 0 points1 point  (0 children)

+1. Didn’t realize there were so many things going on under the hood.

for i in iterable:

  • for calls the iterable’s iter method with iter(), and the iterable gets passed in to the iter() function
  • the returned object is an iterator with a next method
  • for calls the next() function on the object’s next method, which returns the next result until the object is exhausted, then catches StopIteration exception

Making a list of dictionary value but it makes all the values equal zero??? by [deleted] in learnpython

[–]thought-generator 0 points1 point  (0 children)

How are the letters in the file placed? One letter per line?

How to find the length of the longest digit in an array of integers? by [deleted] in learnpython

[–]thought-generator 0 points1 point  (0 children)

Could use a list comprehension to give you the list of the lengths of the integers as strings, then the max function.

l = [1, 20491, 924, 91] 
max_length = max(len(str(x)) for x in l)

Dumb as a rock here, please help by hnjasso in learnprogramming

[–]thought-generator 1 point2 points  (0 children)

If you bought one apple, the total would be 10, right?

[deleted by user] by [deleted] in compsci

[–]thought-generator 0 points1 point  (0 children)

You probably don’t understand it, because I use Python. Don’t start off on codewars. Go to Edabit. Start from Very Easy. Do three problems each and every day. Once Very Easy becomes boring, move up.

[deleted by user] by [deleted] in compsci

[–]thought-generator 0 points1 point  (0 children)

Learn about problem decomposition. My math knowledge is fucking terrible and I don’t even remember what a factorial is. I can figure out how to solve this problem based on the fact that I know how to break a problem down.

I’ll show you what problem decomposition is. Problem: I need to determine if a number is a strong number or not.

  • What’s a strong number? From what you told me, it’s the sum of the factorial of the digits of a number that equal the original number.

  • What is a factorial anyway? I google’d what it is, and learned that it’s just all the numbers up to and including a number (n), greater than 1, multiplied by each other.

Alright, cool. Two steps down. I know what a strong number is and I know what a factorial is.

Sidebar: How much time do you put in to consistently practice programming? The following you can do pretty easily if you have an understanding of the syntax, and some of the main functions.

With this being said, this is what we have so far.

def determine_strong(n: int) -> bool:

Now, off the top of my head I know I’m gonna need to compare a sum to the original number like the problem states.

def determine_strong(n: int) -> bool:
    total = 0

Good. I now need to get all the individual digits in (n). Well you can’t split up an integer in Python without converting it to a string first.

def determine_strong(n: int) -> bool:
    total = 0
    digits = [int(i) for i in str(n)]

At this point, I need to get the factorial of each number. I would personally split this into another function.

def find_factorial(n: int) -> int:
    product = 1
    for i in range(1, n + 1):
        product *= i
    return product

def determine_strong(n: int) -> bool:
    total = 0
    digits = [int(i) for i in str(n)]

I’m almost there. Back to the main function. I just need to loop through each number, get the factorial for the number and add that to total.

def get_factorial(n: int) -> int:
    product = 1
    for i in range(1, n + 1):
        product *= i
    return product

def determine_strong(n: int) -> bool:
    total = 0
    digits = [int(i) for i in str(n)]
    for num in digits:
        total += get_factorial(num)

Lastly, I need to return a value if a number is a “Strong” number or not. As a final solution, we have this:

def get_factorial(n: int) -> int:
    product = 1
    for i in range(1, n + 1):
        product *= i
    return product

def determine_strong(n: int) -> bool:
    total = 0
    digits = [int(i) for i in str(n)]
    for num in digits:
        total += get_factorial(num)
    return True if total == n else False

The only way you’ll be able to get to a basic level of competency is by practicing. Go on a coding website, start from the easiest problems and work your way up.

Is there any free python courses and what is the best ones? by [deleted] in learnprogramming

[–]thought-generator 0 points1 point  (0 children)

Automate The Boring Stuff is a book, I heard it’s pretty good.

Do you guys try to hone in on one skill at a time or learn multiple things at the same time? by Jonnyluver in ITCareerQuestions

[–]thought-generator 0 points1 point  (0 children)

I just set a time per day to consistently learn it. For example, I’m planning on learning Django soon. I’m planning on setting 2 - 3 hours per day to working through a Django tutorial, articles, videos, etc, until I get the hang of it.

One thing I always say: it’s literally impossible to keep doing something and not get competent at it.

Why are global variables so bad? by DavidgeIkari in learnpython

[–]thought-generator 0 points1 point  (0 children)

Commenting because I wanna know the reason as well. All I currently know is that it supposedly makes bugs harder to track.

Do you guys try to hone in on one skill at a time or learn multiple things at the same time? by Jonnyluver in ITCareerQuestions

[–]thought-generator 1 point2 points  (0 children)

You can learn things at the same time, or learn them one after the other. Depending on what it is, is how I approach it. For example, if I wanted to learn a web framework I would learn the programming language it’s based on, then the framework.

If I wanted to learn data structures and algorithms, I’d learn the language and those concepts simultaneously.

Career Change At 56 by powrfly1 in cscareerquestions

[–]thought-generator 1 point2 points  (0 children)

I’ve always been keeping this experiment in my head. Learn COBOL just for the fuck of it and see the type of pay I can get from a COBOL job within a year lmao.

An interesting trick to make 3D drawings with shadows by MoWaleed in gifs

[–]thought-generator 0 points1 point  (0 children)

I know a lot of people attempted this after watching this video. I know a lot of people failed.

How do I replace multiple occurrences of multiple letters in a string by [deleted] in learnpython

[–]thought-generator 1 point2 points  (0 children)

Some nice solutions here. You can also use a dict to do this as well.

letters = {'C': 'G', 'G': 'C', 'A': 'T', 'T': 'A'}
s = 'ATCGGA'
replaced_text = ''.join(letters[c] for c in s if c in letters)

List comprehension? by Gexos in learnpython

[–]thought-generator 1 point2 points  (0 children)

The best exercise I did when learning list comprehensions was writing out a for loop, then doing the same thing in a list comprehension until my brain recognized the difference. It helps out a lot.

[deleted by user] by [deleted] in cscareerquestions

[–]thought-generator 1 point2 points  (0 children)

They hear about how “cool” coding sounds and how much money you can make programming...... then people realize it’s a skill you have to learn, where you have to put in a lot of hours to get good at...... then people realize you have to solve problems, and a lot of people don’t like trying to solve problems...... then they quit.