중세 직교


9

직무

당신의 임무는 텍스트를 중세 직교로 변환하는 것입니다.

세부

  1. jiJ로 변환됩니다 I.
  2. u그리고 U단어의 시작 부분에 변환됩니다 vV각각.
  3. v그리고 V단어의 시작 부분을 제외하고 어디에서로 변환 u하고 U각각.
  4. sſ단어가 끝나거나 다른 단어가 앞에 있지 않으면 (U + 017F) 로 변환됩니다 s.

명세서

  • 단어는에서 일련의 문자로 정의됩니다 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.
  • 모든 단어는 적어도 두 글자로되어 있습니다.
  • 입력은 인쇄 가능한 ASCII 문자 (U + 0020-U + 007E) 로만 구성됩니다 .
  • 연속 적으로 두 번 이상 발생하지 않습니다 s. 즉 sss, 입력의 하위 문자열이 아닙니다.

테스트 케이스

개별 단어 :

Input       Output
------------------------
Joy         Ioy
joy         ioy
Universe    Vniuerſe
universe    vniuerſe
Success     Succeſs
successfull ſucceſsfull
Supervise   Superuiſe
supervise   ſuperuiſe
Super-vise  Super-viſe
I've        I've
majors      maiors
UNIVERSE    VNIUERSE
0universe   0vniuerſe
0verify     0verify
I0ve        I0ve
_UU_          _VU_
_VV_          _VU_
ss_         ſs_

전체 단락 :

Input:  Christian Reader, I have for thy use collected this small Concordance, with no small labour. For being to comprise much in little roome, I was to make choyse of the most principall and usefull places, and to rank them under such words as I thought most essentiall and materiall in the sentence, because the scant roome allotted unto me, would not permit that I should expresse them under every word in the verse, as it is the manner in large Concordances.

Output: Chriſtian Reader, I haue for thy vſe collected this ſmall Concordance, with no ſmall labour. For being to compriſe much in little roome, I was to make choyſe of the moſt principall and vſefull places, and to rank them vnder ſuch words as I thought moſt eſsentiall and materiall in the ſentence, becauſe the ſcant roome allotted vnto me, would not permit that I ſhould expreſse them vnder euery word in the verſe, as it is the manner in large Concordances.

SHA-256 마지막 테스트 케이스의 출력 해시이다 :

5641899e7d55e6d1fc6e9aa4804f2710e883146bac0e757308afc58521621644

기권

중세의 정설 법은 그런 내용이 아닙니다. 당신이 다른 직교를 가진 오래된 책을 가지고 있다면 기뻐하지 마십시오.


1
"출력에서 ſ 대신 f를 사용할 수 있습니다." 따라서 기본적으로 ſ를 사용하면 더 많은 바이트가 필요하므로 인센티브가 없습니다.
치명적

1
@Fatalize Fair 포인트. 그 하나를 제거했습니다.
Leaky Nun

@LeakyNun 그런 다음 ſ1 바이트 로 계산할 수 있습니까 ?
R. Kap

algorithm를 사용하지 않으면 일부 알고리즘에서 ff가 fs로 변경되는 인센티브가있다
Destructible Lemon

1
Super-vise된다 Super-viſe?
R. Kap

답변:


3

SED, 144140111 바이트

NoOneIsHere 덕분에 29 바이트 절약

-r -e'y/j/i/g;y/J/I/g;s/ u/ v/g;s/ U/ V/g;s/^u/v/g;s/^U/V/g;s/([^s])s(\w)/\1ſ\2/g;s/(\w)v/\1u/g;s/(\w)V/\1U/g'

1
당신은 용감하고 용감한 영혼입니다.
Alexander-복원 자 Monica Monica

1 만 사용하여 많은 바이트를자를 수 있습니다 -e. ;문장 사이에 s를 사용하십시오 .
NoOneIsHere 여기

네가 할 수있는 줄 몰랐어 감사!!
Riley

2

파이썬 3 ( 128 126 바이트)

import re;lambda k:re.sub("(?<!s)s(?=[a-zA-Z])",'ſ',re.sub("(?i)j|(?<![a-z])u|(?<=[a-z])v",lambda c:chr(ord(c.group())^3),k))

chr(ord(c.group())^3)단일 문자 문자열을 xor하기에는 과도한 느낌이지만 실제 Pythonista는 골프를 제안 할 수 있습니다. 그러나 와 ^3교환하기에 매우 편리합니다 .i <-> ju <-> v

NB 여기에 Python 3이 필요한 유일한 것은 유니 코드 문자입니다. Python 2 complains Non-ASCII character '\xc5' <snip> but no encoding declared.


숫자와 밑줄을 포함하는 단어의 정의를 사용 \b하므로 \b사용 하지 않아야 합니다.
Leaky Nun

@LeakyNun, 흠. 수정 프로그램을 찾고있는 동안 테스트 사례를 추가해 주시겠습니까?
피터 테일러

@ R.Kap. (?i).
피터 테일러

@PeterTaylor 잠깐만 요, 그게 뭐죠?
R. Kap

@ R.Kap, 정규 표현식을 대소 문자를 구분하지 않습니다.
피터 테일러


1

파이썬 3.5 124 116 111 118 125 144 142 바이트 :

import re;lambda k:re.sub("J|j|(?<![a-zA-Z])[uU]|(?<=[a-zA-Z])[Vv]|(?<!s)s(?=[a-zA-Z])",lambda g:dict(zip('jJuUvVs','iIvVuUſ'))[g.group()],k)

글쎄, 이것은 정규 표현식에 대한 완벽한 직업처럼 보입니다 !


1
J|j대신 사용할 수 있습니다[Jj]
Leaky Nun

1

자바 스크립트 (ES6), 154

알파벳 문자를 식별하기 위해 parseInt 사용 참고 : 캐주얼하지만 운 parseInt('undefined',36)|0이 <0

s=>[...s].map((c,i)=>((n=v(c))-19?n==31&p>9?'uU':n!=30|p>9?c=='s'&s[i-1]!=c&v(s[i+1])>9?'?':c+c:'vV':'iI')[p=n,c<'a'|0],p=0,v=c=>parseInt(c,36)|0).join``

덜 골프

s=>
  [...s].map(
  (c,i)=>
  ((n=v(c))-19
  ?n==31&p>9
    ?'uU'
    :n!=30|p>9
      ?c=='s'&s[i-1]!=c&v(s[i+1])>9
        ?'ſ'
        :c+c
      :'vV'
  :'iI')[p=n,c<'a'|0],
  p=0,
  v=c=>parseInt(c,36)|0
).join``

테스트

F=
s=>[...s].map((c,i)=>((n=v(c))-19?n==31&p>9?'uU':n!=30|p>9?c=='s'&s[i-1]!=c&v(s[i+1])>9?'ſ':c+c:'vV':'iI')[p=n,c<'a'|0],p=0,v=c=>parseInt(c,36)|0).join``

out=(a,b,c)=>O.textContent+=a+'\n'+b+'\n'+c+'\n\n'

ti='Christian Reader, I have for thy use collected this small Concordance, with no small labour. For being to comprise much in little roome, I was to make choyse of the most principall and usefull places, and to rank them under such words as I thought most essentiall and materiall in the sentence, because the scant roome allotted unto me, would not permit that I should expresse them under every word in the verse, as it is the manner in large Concordances.'
to='Chriſtian Reader, I haue for thy vſe collected this ſmall Concordance, with no ſmall labour. For being to compriſe much in little roome, I was to make choyſe of the moſt principall and vſefull places, and to rank them vnder ſuch words as I thought moſt eſsentiall and materiall in the ſentence, becauſe the ſcant roome allotted vnto me, would not permit that I ſhould expreſse them vnder euery word in the verſe, as it is the manner in large Concordances.'
r=F(ti)
out(to==r?'OK':'KO',ti,r)

test=`Joy         Ioy
joy         ioy
Universe    Vniuerſe
universe    vniuerſe
Success     Succeſs
successfull ſucceſsfull
Supervise   Superuiſe
supervise   ſuperuiſe
Super-vise  Super-viſe
I've        I've
majors      maiors
UNIVERSE    VNIUERSE
0universe   0vniuerſe
0verify     0verify
I0ve        I0ve
_UU_          _VU_
_VV_          _VU_
ss_         ſs_`
.split('\n').map(t=>{
  var [i,o]=t.split(/\s+/),r=F(i)
  out(o==r?'OK':'KO',i,r)
})
#O {width:90%; overflow:auto; white-space: pre-wrap}
<pre id=O></pre>


1

자바 스크립트 (ES6), 111 바이트

s=>s.replace(/[a-z]+/gi,w=>w.replace(/j|J|^u|^U|\Bv|\BV|ss|s(?!$)/g,c=>"iIvVuUſ"["jJuUvVs".search(c)]||"ſs"))

설명 : 자바 스크립트 정규 표현식이 더 lookbehind이 없기 때문에, 내가 대신 다음 날 사용할 수 있습니다 단어에 캐릭터 라인, 헤어 ^\B부정과 긍정적 편지 lookbehinds으로합니다. ss은 첫 번째 문자 만 바꾸 c거나 s두 문자열에 여분 을 추가 하고 일치하는 하위 문자열을 사용하는 것보다 적은 바이트를 사용하는 약간 어색한 대체 표현식으로 개별적으로 일치시켜 처리 합니다.


c=>"iIvVuUſ"["jJuUvVs".search(c)]||"ſs"좋습니다. 👍🏻
요르단

0

CJam ( 89 88 바이트)

{32|_'`>\'{<*}:A;SqS++3ew{_1="jJuUvVs"#[-4_{_0=A!3*}_{_0=A3*}_{_)A\0='s=>268*}W]=~f^1=}%

온라인 데모

CJam에 왜 정규 표현식이 없는지 이해하지 못했지만 여기에 정규 표현식을 사용하지 않는 솔루션이 없기 때문입니다.


0

루비, 85 + 1 = 86 바이트

ruby -p( p플래그에 +1 바이트)로 실행하십시오 . stdin에 입력을받습니다.

gsub(/j|(?<=^|[^a-z])u|(?<=[a-z])v|(?<=^|[^s])s(?=[a-z])/i){$&.tr"jJsUuVv","iIfVvUu"}

ideone에서 테스트를 실행하십시오 (ideone에 플래그를 줄 수 없기 때문에 람다로 싸여 있음) : http://ideone.com/AaZ8ya

당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.