JavaScript is required to use Bungie.net

자유 게시판

자유롭게 대화를 나누어보세요.
작성자: Euler 5/15/2013 3:58:08 PM
1

Python Question - Recursion or not?

So I've got this problem that I think requires a recursive function Distilling it down - basically I'm provided with this humongous list of translations (7000+) from various languages to other languages, and a query. I'm supposed to determine the amount of languages each word in query needs to be translated to before it returns to its original language - (e.g. Bird translated to serbian is [i]ptica[/i] and [i]ptica[/i] is translated back into English as [i]Flier[/i] - a total distance of 3 languages (ENG to SER and back to ENG again), and do a bunch of stuff from there, but that's the most important bit. My only hang-up is runtime. Is it feasible to use recursion here (I've got limited runtime) or should I just stick with the iterative method? (i'm hopeless at Python if you haven't figured that out already.)

게시물 작성 언어:

 

다른 사용자들을 존중해주세요. 게시물을 제출하기 전에 한 숨 돌리고 운영 정책을 검토하세요. 취소 수정 화력팀 생성하기 게시

모든 주제 보기
  • If I'm interpreting what you're saying that you want to do correctly, I would say go with recursion, because an iterative solution would probably get pretty messy.

    게시물 작성 언어:

     

    다른 사용자들을 존중해주세요. 게시물을 제출하기 전에 한 숨 돌리고 운영 정책을 검토하세요. 취소 수정 화력팀 생성하기 게시

회원님은 해당 콘텐츠를 볼 수 없습니다.
;
preload icon
preload icon
preload icon