셰익스피어 스크립트 분할


13

윌리엄 셰익스피어는 연극을 썼습니다. 많은 놀이. 그의 작품 하나 하나가 들어있는 이 타르볼 에서 그의 작품 하나 하나는 긴 파일입니다.
무대 제작을 위해 장면으로 분할해야합니다. 액터가 참을성이 없기 때문에 코드는 가능한 짧아야합니다.

직무:

당신의 임무는 이 파일 에 포함 된 연극 을 개별 파일 로 분할하는 프로그램이나 기능을 작성하는 것 1입니다. 모든 공백과 제목을 유지해야합니다.

입력:

입력은을 통한 단일 재생 stdin또는 파일 이름을 매개 변수로 사용합니다. 선택할 수 있습니다. 연극은 다음과 같습니다.

 TITUS ANDRONICUS


    DRAMATIS PERSONAE


SATURNINUS  son to the late Emperor of Rome, and afterwards
    declared Emperor.

BASSIANUS   brother to Saturninus; in love with Lavinia.

TITUS ANDRONICUS    a noble Roman, general against the Goths.

MARCUS ANDRONICUS   tribune of the people, and brother to Titus.


LUCIUS  |
    |
QUINTUS |
    |  sons to Titus Andronicus.
MARTIUS |
    |
MUTIUS  |


Young LUCIUS    a boy,
[...]
ACT I



SCENE I Rome. Before the Capitol.


    [The Tomb of the ANDRONICI appearing; the Tribunes
    and Senators aloft. Enter, below, from one side,
    SATURNINUS and his Followers; and, from the other
    side, BASSIANUS and his Followers; with drum and colours]

SATURNINUS  Noble patricians
[...]
ACT I



SCENE II    A forest near Rome. Horns and cry of hounds heard.


    [Enter TITUS ANDRONICUS, with Hunters, &c., MARCUS,
    LUCIUS, QUINTUS, and MARTIUS]

TITUS ANDRONICUS    The hunt is up, the morn is bright and grey,
    The fields are
[...]
ACT II



SCENE I Rome. Before the Palace.


    [Enter AARON]

AARON   Now climbeth Tamora
[...]

산출:

출력은 다음과 같아야합니다.

내가 행동



장면 I 로마. 국회 의사당 전에.


    [안드로 니치의 무덤이 나타납니다. 재판소
    상원 의원들이 많이 있습니다 아래에서 한쪽부터 입력하십시오.
    SATURNINUS와 그의 추종자; 그리고 다른 쪽에서
    측면, BASSIANUS와 그의 추종자; 드럼과 색상으로]

SATURNINUS 귀족 귀족들 ...
내가 행동



장면 II 로마 근처의 숲. 사냥개의 뿔과 외침이 들렸다.


    [헌터, & c., MARCUS와 함께 TITUS ANDRONICUS 입력,
    LUCIUS, QUINTUS 및 MARTIUS]

TITUS ANDRONICUS 사냥이 시작되고 아침이 밝고 회색입니다.
    필드는 ...
행동 II



장면 I 로마. 궁전 앞.


    [AARON 입력]

에 이런은 이제 타 모라를 등반 ...

기타

번호가 매겨진 파일로 또는 stdout선택한 deliminator 를 사용하여 스트림 (함수를 반환)으로 출력합니다.

보너스 :

  • 10 % Act 1 이전의 비트를 파일에 저장하면 0. 참고 : Act 1 이전의 비트가 비어 있으면 중단되지 않아야합니다.
  • 15 % stdin및 파일 경로 매개 변수 입력 을 모두 취할 수있는 경우
  • 20 % 파일과 출력 stdout/ 출력 모두를 출력 할 수있는 경우 .
  • 가장 작은 SPL 프로그램을 만들 수 있다면 200 명성 . 이 현상금이 수여되었습니다.

리더 보드

다음은 일반 리더 보드와 언어 별 수상자 개요를 생성 하는 스택 스 니펫 입니다.

답변이 표시되도록하려면 다음 마크 다운 템플릿을 사용하여 헤드 라인으로 답변을 시작하십시오.

# Language Name, N bytes

N제출물의 크기는 어디에 있습니까 ? 당신이 당신의 점수를 향상시킬 경우에, 당신은 할 수 있습니다 를 통해 눈에 띄는에 의해, 헤드 라인에 오래된 점수를 유지한다. 예를 들어 :

# Ruby, <s>104</s> <s>101</s> 96 bytes

헤더에 여러 개의 숫자를 포함 시키려면 (예 : 점수가 두 파일의 합이거나 인터프리터 플래그 페널티를 별도로 나열하려는 경우) 실제 점수가 헤더 의 마지막 숫자 인지 확인하십시오 .

# Perl, 43 + 2 (-p flag) = 45 bytes

언어 이름을 링크로 만들어 리더 보드 스 니펫에 표시 될 수도 있습니다.

# [><>](http://esolangs.org/wiki/Fish), 121 bytes

body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table><script>var QUESTION_ID=68997,OVERRIDE_USER=43394;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?([\d\.]+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;</script>


16
첫 번째 유효한 셰익스피어 프로그래밍 언어 제출에 +200 현상금을 제공합니다.
고양이

3
자, 누구나 CodeGolfs가 빠르지 않다는 것을 알고 있습니다. "타르볼이 이미 가득 차서 코드가 최대한 짧아야한다"고 말하지 않겠습니까?
J_F_B_M

1
@trichoplax 제품. 나는 그것이 모두가 한 일이라고 생각했습니다! 노트북에서 밖으로
wizzwizz4


2
@cat-열어 둔다; 내 것보다 작은 셰익스피어 솔루션이 확신합니다. 내 큰 큰 고양이와 고양이의 합계만큼 뚱뚱합니다.
Robert Fraser

답변:


38

셰익스피어 프로그래밍 언어 1.2.1 , 930 895 887-10 % = 798.3 바이트

G.Ajax,a.Puck,a.Page,a.Ford,a.Act I:a.Scene I:a.[Enter Ajax and Puck]Puck:Open thy mind.Ajax:Open thy mind.[Exit Puck][Enter Page]Ajax:Open thy mind.SCENE II:b.[Exeunt][Enter Puck and Ajax]Ajax:Am I as fat as the sum of the cube of a big big cat and a cat?Puck:If not,let us return to scene III.Am I as fat as the sum of you and a big cat?[Exit Puck][Enter Page]Page:If not,let us return to scene III.Am I as fat as the sum of the sum of the cube of a big big cat and a big big big big cat and a big big cat?[Exit Page][Enter Ford]Ajax:If not,let us return to scene III.You is a big big big big big big cat.Speak thy mind.Scene III:c.[Exeunt][Enter Ajax and Puck]Puck:Speak thy mind.You is as fat as I.[Exit Ajax][Enter Page]Page:You is as fat as I.Puck:Open thy mind.Is you as fat as a hog?[Exit Page][Enter Ajax]Puck:If not,let us return to Scene II.Speak thy mind.Ajax:Speak thy mind.

Sharkspearean 언어로 언 골프 및 재 작성 :

Four Gentlemen of Verona.

Ajax, a master code-golfer with years of experience.
Puck, a young Java programmer and a strong believer in object-oriented design patterns.
Page, a rapscallion of ill repute.
Ford, a car manufacturer.

Act I: A one-act masterpiece.

Scene I: In which many minds are opened, possibly via the consumption of psychadelic drugs.
[Enter Ajax and Puck]
Puck: Open thy mind.
Ajax: Open thy mind.
[Exit Puck]
[Enter Page]
Ajax: Open thy mind.

SCENE II: In which things are compared.
[Exeunt]
[Enter Puck and Ajax]
Ajax: Am I as hairy as the sum of the cube of a furry purple chihuahua and a summer's day?
Puck: If not, let us proceed to scene III. Am I as half-witted as the sum of you and a cunning squirrel?
[Exit Puck]
[Enter Page]
Page: If not,let us proceed to scene III. Am I as delicious as the sum of the sum of the cube of a warm healthy hamster and a proud handsome charming noble nose and a big old aunt?
[Exit Page]
[Enter Ford]
Ajax: If not, let us proceed to scene III. You are the cube of a tiny small pony. Speak thy mind.

Scene III: In which minds are spoken.
[Exeunt]
[Enter Ajax and Puck]
Puck: Speak thy mind. You are as smelly as I.
[Exit Ajax]
[Enter Page]
Page: You are as oozing as I.
Puck: Open thy mind. Are you as disgusting as a Microsoft?
[Exit Page]
[Enter Ajax]
Puck: If not,let us return to Scene II. Speak thy mind.
Ajax:Speak thy mind.

C와 유사한 psuedocode에서 :

Scene_I:
    Ajax = getchar()
    Puck = getchar()
    Page = getchar()
Scene_II:
    if(Ajax != 'A')
        goto Scene_III
    if(Puck != 'C')
        goto Scene_III
    if(Page != 'T')
        goto Scene_III
    Ford = '@'
    putchar(Ford)
Scene_III:
    putchar(Ajax)
    Ajax = Puck
    Puck = Page
    Page = getchar()
    if(Page != -1)
        goto Scene_II
    putchar(Ajax)
    putchar(Puck)

입력 파일에 3 자 이상이 필요합니다. "@"를 구분 기호로 사용하고 결과를 stdout에보고합니다. 위의 Martin Büttner의 솔루션과 마찬가지로 첫 번째 장면이 첫 번째 "@"앞에 있기 때문에 10 % 보너스를 받고 있습니다.

작동하는 방식은 "ACT"문자가 연속으로 표시되면 "@"를 넣는 것입니다. 이는 "ENACTED"가 "EN @ ACTED"로 변환됨을 의미합니다. 이것은 수백 바이트의 비용으로 고칠 수 있지만 운 좋게도 주어진 연극의 모든 "ACT"(적어도 내가 확인한 몇 개)가 장면의 시작 인 것처럼 보입니다.

위에 링크 된 1.2.1 SPL로 테스트했습니다. 웹 인터프리터에서 작동하는지 확실하지 않습니다. 테스트에 사용 된 스크립트는 다음과 같습니다.

#!/bin/bash
set -e
SCRIPT_DIR=`dirname "$0"`
cd "$SCRIPT_DIR"
spl/bin/spl2c <splits.spl >splits.c
gcc -O2 -Wall -Wno-unused -I./spl/include -L./spl/lib -lm -lspl -o splits splits.c
./splits <measureforemeasure >measure.split.txt

구문을 지나면 SPL의 "비밀 한"부분은 "stage"에서 변수를 섞는 것 (일반적으로 한 번에 두 개의 문자 만 갖기를 원함)과 상수의 표현입니다. 분포와 함께 제공되는 수입 단어 목록에는 양의 형용사, 중립 형용사, 음의 형용사, 양의 명사, 중립 명사 및 음의 명사가 있습니다. 양수 / 중립 명사 (예 : 매화 또는 돌담)는 1이고 음수 명사 (예 : flirt-gill 또는 Microsoft)는 -1입니다. 양수 / 중립 형용사 (즉, 자수 또는 밑이없는)는 숫자에 2를 곱하고, 음용 형용사 (즉, 뚱뚱한 신장 또는 아버지가없는)에는 -2를 곱합니다. 단어 목록은 슬프게도 제한되어 있으며 각 항목은 10-20 개입니다.

다음 회의에서는 스칼라보다 훨씬 표현력이 뛰어나 모든 생산 코드를 셰익스피어로 옮길 것을 제안합니다.


2
당신이 할 수있는 한 이것을 골프. 부디!
wizzwizz4

1
성스러운 고양이, 나는 누군가가 실제로 그렇게 생각하지 않았다! 24 시간 안에이 보너스를 수여합니다. 가능한 빨리 :)
cat

2
@ wizzwizz4-확실히; :-) 할 실제 작업이 없으면 샷을 줄 것입니다. 마치 마치 바드 자신이 쓴 것처럼 간결 할 것입니다
Robert Fraser

2
이제 무대에서이 작업을 수행하기 위해 누구를 고용 할 수 있습니까?
고양이

3
@ 고양이-몸무게가 불안한 세 사람을 데리고 고양이 사진을 보여주세요.
Robert Fraser

12

망막 , 9-10 % = 8.1 바이트

바이트 수는 ISO 8859-1 인코딩을 가정합니다.

¶ACT 
=$0

줄 바꿈 앞에 공백이 오는 =모든 앞에 앞에 (구분 기호로)를 삽입합니다 ACT.

온라인으로 사용해보십시오! 그러나 크기 때문에 입력 내용을 직접 복사해야합니다.


69000의 답변을 축하합니다 (공유 링크에 따름).
J_F_B_M

@J_F_B_M Post 69000. 질문 답변입니다.
wizzwizz4

4

awk, 51 * .9 * .85 * .8 = 31.2

여러 파일로 분할합니다. 로 stdout분리하여 출력 합니다 =.

/^ACT/{f++;$0="="$0}{system("echo \""$0"\">>"f*1)}1

+1 이제해야 할 일은 모든 파일을 stdout특정 문자 로 분리 하여 출력 하는 것입니다.
wizzwizz4

끝난. 보너스로 거의 같은 길이입니다.
Rainer P.

+2 ... +2 ........ +2 ............ 아니요. 시스템에서 허용하지 않습니다 :-( 그러나 문자로 분리하는 것이 좋습니다. 즉 더 적은 . | 일반적인 같은 ¬ 또는
wizzwizz4

3

자바 스크립트 ES6, 28-10 % = 25.2 바이트

s=>s.replace(/\nACT/g,"=$&")

JS 쉘조차 파일 I / O를 가지고 있지 않기 때문에 -20 % 보너스를받을 수 없습니다

여기에서 온라인으로 시도하십시오 (입력 내용을 직접 붙여 넣어야 함)


나는 당신이 T1 바이트를 절약 할 수 있다고 생각합니다 .
Mama Fun Roll

교체하지 않아도 ACT 라인이 제거됩니까?
wizzwizz4

나는이 있기 때문에 @ wizzwizz4 $&그것은하지 않습니다
Downgoat

@ Doᴡɴɢᴏᴀᴛ 당신은 매일 새로운 것을 배웁니다!
wizzwizz4

3

Perl, 66-10 %-20 % = 47.52 바이트

BEGIN{open(S,">0");}++$?,open(S,">$?"),print"=\n"if/^ACT/;print S

-p옵션에 하나를 추가했습니다 .


1

루비, 30-10 %-15 % = 23.715 22.95 바이트

에 입력을 분할합니다 $. Ruby $<는 파일 ARGV이 제공되거나 제공 STDIN되지 않은 경우 기본적으로 전달 된 파일을 가리 키도록 경로 재 지정하므로 15 % 보너스가 적용됩니다 .

gsub@Downgoat ES6 솔루션과 유사하게 -1 바이트 이지만 여전히 ACTACT 레이블에만 나타나고 다른 단어에는 표시되지 않는다는 희망을 활용하고 있습니다.

$><<$<.read.gsub("ACT","$ACT")

또한 파일 출력도하는 41.004 (원래 67) 바이트 솔루션. 루비에서 each명령이 바이트를 절약 할 수있는 유일한 시간은 아마도 블록과 달리 블록을 실행 한 후 전달되지 않은 배열을 반환 map하기 때문 입니다.eachmap

i=-1;$><<$<.read.split(/(?=ACT)/).each{|s|open("#{i+=1}",?w)<<s}*?$
당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.