파이썬으로 풀 수 있는 문제들

  • riceluxs1t
    riceluxs1t

    안녕하세요,

    저는 주로 파이썬으로 즐겨 풀고 있는데요, 어떤 문제들은 시간 제한 때문에 애매한 경우가 있더라고요.

    그래서 최소 한분 이상이 먼저 파이썬으로 푼 기록이 있는 문제들 리스트만 python beautifulsoup을 써서 덕지덕지 긁어서 추려 봤습니다. 134문제가 있네요
    WORDCHAIN
    WORDLENGTH
    XHAENEUNG
    YULO
    ZEROONE
    ALLERGY
    ANAGRAM
    ANNIETIBBER
    ANOTHERRPS
    ARCTIC
    ASYMTILING
    AUTOPRODUCTION
    BADUK
    BALLPAINTING
    BASEBALL
    BILLS
    BOARDCOVER
    BOGGLE
    BOOKSTORE
    BRACKETS
    BRACKETS
    BRAVEDUCK
    BRUTEFORCE
    BST
    CCR
    CHRISTMAS
    CIV
    CLOCKSYNC
    CODERS
    COINS
    CONCERT
    CONVERT
    CSBASEBALL
    DARPA
    DECODE
    DIAMOND
    DIAMONDPATH
    DICT
    DICTIONARY
    DIVIS
    DOMINO
    DRAGON
    DRAWRECT
    ELECT
    ENCODING
    ENCRYPT
    ENDIANS
    FANMEETING
    FENCE
    FESTIVAL
    FIX
    FIXPAREN
    FLAPPY
    FORTRESS
    GALLERY
    GOODSET
    GREEDYAINTA
    GRID
    GRIDISLANDS
    HAMMINGCODE
    HELLOWORLD
    HOTSUMMER
    INSERTION
    JAEHACHERRY
    JEONGLIBE
    JOSEPHUS
    JUMP
    JUMPGAME
    KAKURO
    KLIS
    KOOGLE
    KWPATTERN
    LECTURE
    LIS
    LOAN
    LOTTERYGAMES
    LUCKYNUM
    LUNCHBOX
    MAGICPOWER
    MATCHORDER
    MAXSUM
    MAXTACK
    MEETING
    MERCY
    MISPELL
    MMRECT
    MONKEY
    MOON
    MORSE
    MVP
    NASH
    NECKLACE
    NORMDIST
    NPOLY
    NOTE
    NQUEEN
    NUMB
    NUMBERGAME
    OCR
    ORDERING
    PACKING
    PALINDROMIZE
    PCOMPLETE
    PDNA
    PI
    PICNIC
    PINBALL
    POLY
    POPOWERWER
    POTION
    PROGRAMPAINTER
    QUADTREE
    QUANTIZE
    RATIO
    RECAPTCHA
    REPEATLESS
    RUNNINGMEDIAN
    SENTENCE
    SNAIL
    STARCRAFT
    STRJOIN
    TICTACTOE
    TILING
    TRAVERSAL
    TREASURE
    TRIANGLE
    TRIANGLEPATH
    TRIPATHCNT
    TSP
    UBW
    URI
    WEEKLYCALENDAR
    WEIRD
    WILDCARD
    WITHDRAWAL

    import urllib2
    import re
    from bs4 import BeautifulSoup as soup
    
    
    def getProblemName(pageNum):
        page = urllib2.urlopen('https://algospot.com/judge/problem/list/' + pageNum)
        page = page.read()
        problemList = soup(page)
    
    
        problemList = problemList.find_all("table", class_ = 'problem_list')[0]
        problemList = problemList.tbody.find_all('tr')
        names = []
        for eachProblem in problemList:
    
            name = eachProblem.find_all('a')
            res = re.findall(r'"(.*?)"', str(name))
            numPage += 1
            names.append(res[1])
        return names    
    
    #language : '(py)' , '(java)', etc..    
    
    def isPossibleWithPython(link, language):
        page = urllib2.urlopen('https://algospot.com' + link + '/1/')
        page = page.read()
        page = soup(page)
    
        #get # of stat pages    
        lastPageNum = page.find_all("span", class_ = 'step-links')[0].find_all('a')[-1]
        numPage = int(re.findall("\d+", str(lastPageNum))[1])
    
        for i in range(numPage):
            page = urllib2.urlopen('https://algospot.com' + link + '/' + str(i) + '/')
            page = page.read()
            page = soup(page)
    
            solverTable = page.find_all("table", class_ = 'solver_list')[0]
            solverTable = solverTable.tbody.find_all('tr')
            for each in solverTable:
                if language in str(each):
                    return True
    
        return False
    
    
    #there exist 17 pages full of problems.
    problems = []
    for i in range(17):
        problems.extend(getProblemName(str(i)))
    
    """ 
    e.g.
    replace https://algospot.com/judge/problem/read/ALCHEMY
    with     https://algospot.com/judge/problem/stat/ALCHEMY
    """
    for i in range(len(problems)):
        stat = problems[i].replace('read','stat')
        problems[i] = stat
    
    
    f = open('algospotPythonList3.txt', 'w')    
    for i in range(len(problems)):
        if isPossibleWithPython(problems[i], '(py)'):
            f.write(re.findall('[A-Z]+', problems[i])[0] + '\n')
    
    f.close()   
    

    9년 전
3개의 댓글이 있습니다.
  • VOCList
    VOCList

    우왕굳


    9년 전 link
  • shjang956
    shjang956

    멋져요


    5년 전 link
  • allonsy
    allonsy

    와 너무 감사합니다


    5년 전 link
  • 정회원 권한이 있어야 커멘트를 다실 수 있습니다. 정회원이 되시려면 온라인 저지에서 5문제 이상을 푸시고, 가입 후 7일 이상이 지나셔야 합니다. 현재 문제를 푸셨습니다.