매주 도전081

이것은 곤스란드의 공휴일이기 때문에 매주 도전전을 앞당겨 끝내는 것만큼 좋은 것은 없다.
this week's
작업 #1 › 공통 기본 문자열
일부 CPAN 모듈은 이를 할 수 있지만, 나는 TWC에서 CPAN 모듈을 사용하지 않는다. List::Util (Perl core에서) 을 제외하고는.
이 임무를 완수하기 위해서 나는 한 번에 알파벳을 순환한다.만약 기초 문자열이 전체 문자열과 일치하도록 한 번 또는 여러 번 반복된다면, 이 문자열은 두 문자열의 기초 문자열로 간주될 수 있다.

예.
» ./ch-1.pl abcdabcd abcdabcdabcdabcd
abcd abcdabcd

» ./ch-1.pl aaa aa
a

작업 #2 › 주파수 정렬
이 작업은 다음 단계로 나눌 수 있습니다.
  • 입력이 파일이고 읽을 수 있는지 확인합니다.
  • 파일을 읽고 문자열로 읽습니다.
  • 제외할 문자를 삭제합니다.
  • 단어(빈칸\s+로 구분)를 주파수 산열에 넣는다.
  • 주파수에 대해 숫자 정렬을 한다.
  • 주파수와 일치하는 문자열을 순서대로 표시합니다.

  • 예.
    » ./ch-2.pl input.txt 
    1 But City It Jet Juliet Latino New Romeo Side Story Their Then West York adaptation any anything at award-winning away become before begin best classic climactic coexist control dance do doesn't end ending escalates families feuding form former friend gains gangs goes happened hatred heartbreaking highway hoping in know love lovers meet meeting neither no one plan planning point romantic rumble run secret sends sister streets strikes terribly their two under understanding until violence warring what when where white whoever wins with wrong younger
    
    2 Bernardo Jets Riff Sharks The by it led tragedy
    
    3 Maria Tony a can of stop
    
    4 to
    
    9 and the
    

    좋은 웹페이지 즐겨찾기