Ortaçağ yazımı


9

Görev

Göreviniz bir metni ortaçağ yazımına dönüştürmektir.

ayrıntılar

  1. jdönüştürülür ive Jetmek I.
  2. uve Ukelimelerin başında dönüştürülür vve Vsırasıyla.
  3. vve Vsözcüklerin başında dışında herhangi bir yere de dönüştürülür uve Usırasıyla.
  4. sſsözcüğün sonunda veya bir başkası olmadan önce (U + 017F) biçimine dönüştürülür s.

gözlük

  • Bir kelime, içindeki harf dizisi olarak tanımlanır abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.
  • Tüm kelimelerin en az iki harfi olacaktır.
  • Giriş yalnızca yazdırılabilir ASCII karakterlerinden (U + 0020 - U + 007E) oluşacaktır .
  • Art arda ikiden fazla olay olmaz s. Yani, sssgirdinin bir alt dizesi olmayacaktır.

testcases

Tekil kelimeler:

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_

Bütün paragraf:

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 son testcase çıkışının karma:

5641899e7d55e6d1fc6e9aa4804f2710e883146bac0e757308afc58521621644

feragat

Medievall ortografisi bu bağlamda değildir. Farklı bir ortografiye sahip olde kitaplarını doldurursanız lütfen şikayet etmeyin.


1
"Çıktıda ſ yerine f kullanabilirsiniz." Bu nedenle, daha fazla bayt gerektirdiğinden, temelde inc kullanımı için bir teşvik yoktur.
13'te ölümcül

1
@Fatalize fuar noktasını. Bunu kaldırdım.
Leaky Nun

@LeakyNun O zaman ſ1 bayt olarak sayabilir miyiz ?
R. Kap

algorith kullanılmamışsa ff'nin bazı algoritmalarda fs olarak değiştirilmesi şeklinde bir teşvik vardır
Tahrip

1
Gerekmiyor Super-visehaline Super-viſe?
R. Kap

Yanıtlar:


3

SED, 144140111 Bayt

NoOneIsHere sayesinde 29 bayt tasarruf etti

-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
Sen cesur, cesur ruh.
Alexander - Monica'yı eski

Yalnızca 1'i kullanarak birçok bayt kesebilirsiniz -e. ;S inbetween ifadelerini kullanın .
NoOneIsHere

Bunu yapabileceğini bilmiyordum. Teşekkürler!!
Riley

2

Piton 3 ( 128 126 bayt)

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)tek karakterli bir karakter dizisine aşırı hitap ediyor ama belki gerçek bir Pythonista bir golf önerebilir. Ancak, ^3değiş tokuş etmek için yeterli i <-> jve u <-> v.

Not Burada Python 3 gerektiren tek şey Unicode karakteridir: Python 2 şikayet eder Non-ASCII character '\xc5' <snip> but no encoding declared.


Sen kullanmamalısınız \bçünkü \bkullanımlara rakam ve alt çizgi içeren bir kelimenin tanımını.
Leaky Nun

@LeakyNun, hmm. Bir düzeltme ararken, lütfen bazı test senaryoları ekleyebilir misiniz?
Peter Taylor

R.Kap @. (?i).
Peter Taylor

@PeterTaylor Bekle, bu ne işe yarar?
R. Kap

@ R.Kap, normal ifadeyi büyük / küçük harfe duyarsız hale getirir.
Peter Taylor


1

Python 3.5, 124 116 111 118 125 144 142 bayt:

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)

Bu, düzenli ifadeler için mükemmel bir iş gibi görünüyor !


1
Bunun J|jyerine kullanabilirsiniz[Jj]
Leaky Nun

1

JavaScript (ES6), 154

Alfabetik karakterleri tanımlamak için parseInt kullanma. Not: raslantı ama neyse ki 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``

Daha az golf

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``

Ölçek

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

JavaScript (ES6), 111 bayt

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

Açıklama: JavaScript regexp'in herhangi bir geriye bakışı olmadığından, dizeyi sözcüklere ayırıyorum, bu da daha sonra kullanmamı ^ve \Bnegatif ve pozitif mektup bakışları olarak kullanmamı sağlıyor . ssayrı ayrı eşleştirmeyle, yalnızca ilk karakterin değiştirilmesinden cveya sher iki dizeye fazladan eklenmesinden ve eşleşen alt dizeyi kullanmaktan daha az bayt alan biraz garip değiştirme ifadesiyle ilgilenilir .


c=>"iIvVuUſ"["jJuUvVs".search(c)]||"ſs"Güzel. --🏻
Ürdün

0

CJam ( 89 88 bayt)

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

Çevrimiçi demo

CJam'ın neden regex'leri olmadığını hiç anlamadım, ama burada onları kullanmayan bir çözüm yok.


0

Yakut, 85 + 1 = 86 bayt

ruby -p( pBayrak için +1 bayt ) ile çalıştırın . Stdin üzerine girdi alır.

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

İdeone üzerinde testleri yapın (ideone'ye bayrak veremediğiniz için orada bir lambda içine sarılmış): http://ideone.com/AaZ8ya

Sitemizi kullandığınızda şunları okuyup anladığınızı kabul etmiş olursunuz: Çerez Politikası ve Gizlilik Politikası.
Licensed under cc by-sa 3.0 with attribution required.