본문 바로가기

파이썬

(25)
[Project Euler]24. Lexicographic permutations [문제] A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, we call it lexicographic order. The lexicographic permutations of 0, 1 and 2 are: 012 021 102 120 201 210 What is the millionth lexicographic permutation of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and..
[궁금] pandas에서 inplace를 사용하는 이유는 무엇일까? 올해 목표를 위해 pandas 공부를 하고 있다 공부를 하다가 드는 의문.. 몇 가지가 있었고 궁금한 건 참을 수 없어서 다 해봤다! (공식 문서에 다 나와있겠지만... 그래도 해보면 기억에 더 잘 남는다!) 1. inplace 옵션을 아예 주지 않으면 어떻게 될까? ㄴ 변수가 갱신되지 않는다. (Default가 False) 2. inplace 옵션을 False로 주면 어떻게 될까? ㄴ 변수가 갱신되지 않는다. 근데 이쯤에서 또 궁금한 것은.. 왜 inplace 옵션을 쓰는 것일까??????? 이유를 찾기 위해 pandas 공식 문서를 찾아보았다! inplace = False로 주면 원본이 갱신되지 않으며, 사본을 반환해준다. pandas는 데이터를 다루는 lib니까 원본 데이터를 그대로 유지한 채 데이..
[Project Euler]22. Names scores [문제] Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its alphabetical position in the list to obtain a name score. For example, when the list is sorted into alphabetical order, COLIN, which is worth 3 + 1..
[Project Euler]21. Amicable numbers [문제] Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n). If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b are called amicable numbers. For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110; therefore d(220) = 284. The proper divisors of 284 are 1, 2, 4, 71 and 142; so..
[Project Euler]20. Factorial digit sum [문제] n! means n × (n − 1) × ... × 3 × 2 × 1 For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800, and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27. Find the sum of the digits in the number 100! [풀이] ''' def fac(n): if n
[Project Euler]19. Counting Sundays [문제] You are given the following information, but you may prefer to do some research for yourself. 1 Jan 1900 was a Monday. Thirty days has September, April, June and November. All the rest have thirty-one, Saving February alone, Which has twenty-eight, rain or shine. And on leap years, twenty-nine. A leap year occurs on any year evenly divisible by 4, but not on a century unless it is divisible..
[Project Euler]18. 못풀었음 [문제] By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23. 3 7 4 2 4 6 8 5 9 3 That is, 3 + 7 + 4 + 9 = 23. Find the maximum total from top to bottom of the triangle below: 75 95 64 17 47 82 18 35 87 10 20 04 82 47 65 19 01 23 75 03 34 88 02 77 73 07 63 67 99 65 04 28 06 16 70 92 41 41 26 56 83 40 80 70 33 41 48 ..
[Project Euler]17. Number letter counts [문제] If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used? NOTE: Do not count spaces or hyphens. For example, 342 (three hundred and forty-two) contains 23 letters and 115 (one hundred and fifteen..