Berapa banyak Mana yang saya butuhkan?


33

Dungeon Master adalah salah satu game role-time pertama yang pernah dimainkan, awalnya dirilis pada tahun 1987 di Atari ST. Di antara hal-hal menarik lainnya untuk saat ini, ia menawarkan sistem mantra yang agak canggih berdasarkan rune.

Tugas Anda hari ini adalah menulis program atau fungsi yang mengevaluasi jumlah poin Mana yang diperlukan untuk melemparkan mantra yang diberikan dalam Dungeon Master.

Tangkapan layar Dungeon Master

Sistem 'spell cast' adalah kotak cyan kanan atas pada gambar di atas.

Mantra, rune, dan Mana

Mantra Master Penjara Bawah Tanah terdiri dari 2 hingga 4 rune, dipilih di antara kategori berikut, dalam urutan yang tepat ini:

  1. Kekuasaan (wajib)
  2. Elemental Influence (wajib)
  3. Formulir (opsional)
  4. Kelas / Alignment (opsional)

Itu berarti mantra yang valid adalah:

  • Power + Elemental Pengaruh
  • Kekuatan + Pengaruh Elemen + Bentuk
  • Kekuatan + Pengaruh Elemental + Bentuk + Kelas / Alignment

Setiap kategori berisi 6 rune, dan setiap rune memiliki biaya Mana dasar terkait:

=============================================================================
| Power               | Rune      |   Lo |   Um |   On |   Ee |  Pal |  Mon |
|                     +-----------+------+------+------+------+------+------+
|                     | Base cost |    1 |    2 |    3 |    4 |    5 |    6 |
=============================================================================
| Elemental Influence | Rune      |   Ya |   Vi |   Oh |  Ful |  Des |   Zo |
|                     +-----------+------+------+------+------+------+------+
|                     | Base cost |    2 |    3 |    4 |    5 |    6 |    7 |
=============================================================================
| Form                | Rune      |  Ven |   Ew | Kath |   Ir |  Bro |  Gor |
|                     +-----------+------+------+------+------+------+------+
|                     | Base cost |    4 |    5 |    6 |    7 |    7 |    9 |
=============================================================================
| Class / Alignment   | Rune      |   Ku |  Ros | Dain | Neta |   Ra |  Sar |
|                     +-----------+------+------+------+------+------+------+
|                     | Base cost |    2 |    2 |    3 |    4 |    6 |    7 |
=============================================================================

Mengevaluasi biaya Mana

Biaya Mana dari mantra adalah jumlah dari biaya Mana semua rune:

  • Biaya Rune daya selalu sama dengan biaya dasarnya (dari 1 hingga 6).

  • Untuk rune lainnya, rumus berikut ini berlaku:

    biaya = lantai ((power + 1) * base_cost / 2)

    di mana daya adalah biaya dasar Rune daya.

Contohnya

Spell: Lo Ful
Cost : 1 + floor((1 + 1) * 5 / 2) = 1 + 5 = 6

Spell: Um Ful
Cost : 2 + floor((2 + 1) * 5 / 2) = 2 + 7 = 9

Spell: Pal Vi Bro
Cost : 5 + floor((5 + 1) * 3 / 2) + floor((5 + 1) * 7 / 2) = 5 + 9 + 21 = 35

Klarifikasi dan aturan

  • Input Anda akan terdiri dari 2 hingga 4 string yang menunjuk rune mantra. Anda dapat mengambilnya dalam format apa pun yang wajar, seperti 4 parameter berbeda, array string (mis. ['Lo', 'Ful']), Atau hanya satu string dengan pemisah satu karakter pilihan Anda (mis 'Lo Ful'.). Silakan tentukan format input yang dipilih dalam jawaban Anda.
  • Tanda dijamin valid.
  • Urutan kategori harus dihormati. Kategori yang tidak digunakan dapat hilang atau diganti dengan nilai falsy.
  • Anda dapat menerima rune dalam format berikut: 1. Huruf kapital diikuti dengan huruf kecil ( 'Ful') 2. Semua huruf kecil ( 'ful') 3. Semua huruf besar ( 'FUL'). Tetapi Anda tidak dapat mencampur format yang berbeda.
  • Jelas sekali, kami tidak peduli untuk mengetahui apakah mantra itu benar-benar memiliki efek dalam permainan (untuk mantra yang ingin tahu dan berguna tercantum di sini .)
  • Ini adalah , jadi kode terpendek dalam byte menang.
  • Dan ingat: Lord Chaos memperhatikanmu!

Uji kasus

Spell          | Output
---------------+-------
Lo Ful         | 6
Um Ful         | 9
On Ya          | 7
Lo Zo Ven      | 12
Pal Vi Bro     | 35
Ee Ya Bro Ros  | 31
On Ful Bro Ku  | 31
Lo Zo Kath Ra  | 20
On Oh Ew Sar   | 35
Ee Oh Gor Dain | 43
Mon Zo Ir Neta | 68
Mon Des Ir Sar | 75

1
Tangensial - tetapi untuk orang yang menyukai sistem ini, The Magical Land of Wozz adalah gim SNES Jepang (tersedia dalam bahasa Inggris) yang menerapkan sistem yang hampir sama - di mana untaian huruf apa saja menjadi mantra. google.co.jp/webhp?ie=UTF-8#q=magical+land+of+wozz
Coty Johnathan Saxman

Saya memiliki memori yang samar-samar melihat seseorang bermain Dungeon Master (saya tidak berpikir itu ada di ST). Mereka telah melengkapi salah satu pejuang mereka dengan kalung ajaib, dan sesekali mereka akan memeriksa apakah itu mengisi ulang dan jika demikian melemparkan rune lain dari apa yang saya pikir adalah mantra penghasil cahaya semacam itu, sehingga pejuang mampu melemparkan mantra ini setiap sepuluh menit atau lebih, dan akhirnya memperoleh level sihir.
Neil

@Neil Kalung ini mungkin adalah Moonstone (+3 Mana) atau Pendant Feral (+1 Wizard Skill). Semua item tercantum di sini .
Arnauld

skrip ini akan menampilkan semua kemungkinan kombinasi input
NieDzejkob

Jawaban:


6

SOGL V0.12 , 110 78 byte

θKKι"LUOEPM”;W:A≤{B"⁶Μ↓§QΕņj“L─"¶Ζq«╝γDyΜ2¶S◄Μ$‘č¹I6nēwι{_Cb:ƧRA=┌*ΚKι=?aIc*»+

Coba Di Sini!

Mungkin bisa golf satu atau dua byte dari mengulang semuanya

Penjelasan:

θ            split on spaces
 K           pop the 1st item
  K          pop from the string the 1st character
   ι         remove the original string from stack
    "”;W     get the chars index in "LUOEPM"
        :A   save a copy to variable A
          ≤  put the power (used as the mana) on the bottom of the stack (with the thing above being the input array)

{            for the leftover items in the input do
 B             save the current name on B
  "..“         push 456779223467234567
      L─       base-10 decode it (yes, silly, but it converts it to an array of digits)
        ".‘    push "VEKIBGKRDN-SYVOFDZ"

      č        chop to characters
       ¹       create an array of those two
        I      rotate clockwise
         6n    group to an array with sub-arrays of length 6 (so each array in the array contains 3 items, corresponding to the categories, each with 6 arrays with the runes 1st letter (or "-" in the case of Ra) and base cost)
           ē   push variable e (default = user input number, which errors and defaults to 0) and after that increase it (aka `e++`)
            w  get that item in the array (the array is 1-indexed and the variable is not, so the array was created shifted (which somehow saves 0.9 ≈ 1 byte in the compression))

 ι             remove the original array
  {            for each in that (current category) array
   _             dump all contents on stack (so pushing the runes name and then base cost)
    C            save pop (base cost) on variable B
     b:          duplicate the name
       ƧRA=      push if pop = "RA"
           ┌*    get that many (so 0 or 1) dashes
             Κ   prepend the "" or "-" to the name
              K  pop the 1st letter of the name
               ι remove the modified name, leaving the 1st letter on the stack

         =?      if top 2 are equal (one of the dumped items and the 1st letter of the current inputs)
           a       push variable A (the power)
            I      increase it
             c     push variable C (the current base cost)
              *    multiply
               »   floor-divide by 2
                +  add that to the power

2
itulah yang membuatnya lebih menarik
Walfrat

Bisakah Anda menambahkan penjelasan?
CalculatorFeline

@CalculatorFeline Agak lupa tentang jawaban ini. Mungkin akan bermain golf & kemudian menambahkan penjelasan
dzaima

17

Python 2 , 135 119 115 byte

b=[int('27169735 2  4567 435262'[int(x,36)%141%83%50%23])for x in input()]
print b[0]+sum(a*-~b[0]/2for a in b[1:])

Cobalah online!

Input adalah daftar string dari stdin


Outgolfed ...>. <
Mr. Xcoder

Saya telah menyalin metode input TIO Anda ke jawaban saya juga, harap Anda tidak keberatan.
Tn. Xcoder

@ Mr.Xcoder Sekarang saya sudah memasukkan semua test case. Anda dapat menyalinnya jika Anda ingin
ovs

Oo, baik dilakukan pada pengindeksan - pikiran jika saya meminjamnya untuk solusi JS saya?
Shaggy

11

05AB1E , 83 82 byte

.•Y<εΔ•¹нk©.•M₄P畲нkÌ.•Jrû •³нkD(i\ë4 3‡4+}.•A1Δ#•I4èkD(i\ë3LJ012‡Ì})ćsv®>y*;(î(+

Cobalah online!

-1 terima kasih kepada Emigna .

SOOOOOOO ungolfed :(

Penjelasan:

.•Y<εΔ•¹нk©.•M₄P畲нkÌ.•Jrû •³нkD(i\ë4 3‡4+}.•A1Δ#•I4èkD(i\ë3LJ012‡Ì})ćsv®>y*;(î(+ Accepts four runes as separate lines, lowercase. Use Ø for missing runes.
.•Y<εΔ•¹нk©                                                                        Index first letter of first rune into "aluoepm" ("a" makes 1-indexed)
           .•M₄P畲нkÌ                                                             Index first letter of second rune into "yvofdz", 2-indexed.
                      .•Jrû •³нkD(i\ë4 3‡4+}                                       Index first letter of third rune into "vekibg", 0-indexed, if it's not there pop, else, if index is 4 replace with 3, else keep as-is, then increment by 4.
                                            .•A1Δ#•I4èkD(i\ë3LJ012‡Ì}              Index fourth letter (modular wrapping) of fourth rune into "kodnra", if it's not there pop, else, if index is one of 1, 2 or 3, replace with 0, 1 or 2 respectively, else keep as-is, then increment by 2.
                                                                     )ćs           Wrap all numbers into a list, keeping the power rune behind.
                                                                        v          For each
                                                                         ®>y*;(î(   Apply the formula
                                                                                 +  Add to total sum

Satu golf kecil adalah bahwa jika Anda membuat indeks .•Y<εΔ•di awal, Anda tidak perlu menambah indeks.
Emigna

@Emigna Ooh belum sempat mencobanya ...
Erik the Outgolfer

11

JavaScript (ES6), 157 156 116 112 100 99 97 byte

Mengambil input sebagai array string.

a=>a.map(c=>t+=(v=+`27169735020045670435262`[parseInt(c,36)%141%83%50%23],+a?a*v+v>>1:a=v),t=0)|t
  • Menyimpan 44 byte secara besar-besaran dengan meminjam trik pengindeksan dari solusi Python ovs - jika Anda memperbaiki jawaban ini, harap unduh juga jawaban itu.
  • Disimpan 13 byte berkat Arnauld menunjukkan apa yang seharusnya menjadi peluang yang jelas untuk menggunakan ternary.

Cobalah secara Online!


Penjelasan

Hoo, nak, ini akan menyenangkan - penjelasan saya untuk solusi sepele menyedot pada saat terbaik! Mari kita coba ...

a=>

Fungsi anonim mengambil array sebagai argumen melalui parameter a.

a.reduce((t,c)=>,0)

Kurangi elemen dalam array dengan melewati masing-masing fungsi; yang tparameter adalah total berjalan, cparameter adalah string saat ini dan 0merupakan nilai awal t.

parseInt(c,36)

Konversi elemen saat ini dari string base 36 ke integer desimal.

%141%83%50%23

Lakukan beberapa operasi modulo di atasnya.

+`27169735 2  4567 435262`[]

Ambil karakter dari string pada indeks itu dan ubah menjadi angka.

v=

Tetapkan nomor itu ke variabel v.

+a?

Periksa apakah variabel aadalah angka. Untuk elemen pertama aadalah array string, mencoba mengubahnya menjadi angka akan kembali NaN, yang merupakan falsey. Pada setiap operan berikutnya, aakan menjadi bilangan bulat positif, yang benar.

a*v+v>>1

Jika aadalah angka maka kita kalikan dengan nilai v, tambahkan nilai vdan geser bit hasil 1 bit ke kanan, yang memberikan hasil yang sama seperti membaginya dengan 2 dan lantai.

:a=v

Jika abukan angka, kita memberikan nilai vuntuk itu, yang juga akan memberi kita a 0untuk menambah total kita pada pass pertama.

t+

Akhirnya, kami menambahkan hasil dari ternary di atas ke total berjalan kami.


Asli, 156 byte

a=>a.reduce((t,c)=>t+(p+1)*g(c)/2|0,p=(g=e=>+`123456234567456779223467`["LoUmOnEePaMoYaViOhFuDeZoVeEwKaIrBrGoKuRoDaNeRaSa".search(e[0]+e[1])/2])(a.shift()))

Anda dapat menyimpan satu byte lagi dengan menggunakan kembali: a=>a.reduce((t,c)=>t+(v=+'27169735020045670435262'[parseInt(c,36)%141%83%50%23],+a?a*v+v>>1:a=v),0)(EDIT: menghapus komentar yang tidak relevan tentang bilangan bulat yang diteruskan dalam input - sepertinya saya tidak memahami tantangan saya dengan sangat baik ^^)
Arnauld

Trik yang rapi, terima kasih, @Arnauld. Mencoba membuat perhitungan yang akan memberi saya angka yang kami indekskan dalam byte lebih sedikit saat ini tetapi tidak memiliki banyak keberuntungan.
Shaggy

6

JavaScript, 212 210 207 206 byte

Algoritma pencarian straight-forward, string pencarian hanya berkontribusi pada total byte.

Kode

s=>eval('p=q=+(e=s.map(r=>"1 2 3 4 5  6  2 3 4 5  6  7 4  5 6   7 7  9  2 2  3   4   6 7"["LoUmOnEePalMonYaViOhFulDesZoVenEwKathIrBroGorKuRosDainNetaRaSar".search(r)])).shift();e.map(c=>p+=((q+1)*c)>>1);p')

Masukkan format

Array string, setiap item adalah string huruf kapital pertama. Contoh: ["Sen", "Zo", "Ir", "Neta"]

Penjelasan

e=s.map(r=>"1 2 3 4 5  6  2 3 4 5  6  7 4  5 6   7 7  9  2 2  3   4   6 7"["LoUmOnEePalMonYaViOhFulDesZoVenEwKathIrBroGorKuRosDainNetaRaSar".search(r)])

Ini menanyakan biaya dasar.

p=q=+(/*blah*/).shift() 

Menginisialisasi 2 variabel dengan item pertama dari hasil array di atas, dan menghapus item itu. Harus dilemparkan ke nomor pertama, jika tidak maka akan dianggap sebagai penggabungan string di bagian selanjutnya.

e.map(c=>p+=((q+1)*c)>>1);

Menambahkan biaya rune non-daya ke daya dasar. Pergeseran digunakan bukan lantai (bla) / 2.

eval(/*blah*/;p)

Evaluasi hasil terakhir. (Kredit: Langkah Hen)

Uji Kasus

Lo Ful | 6
Um Ful | 9
On Ya | 7
Lo Zo Ven | 12
Pal Vi Bro | 35
Ee Ya Bro Ros | 31
On Ful Bro Ku | 31
Lo Zo Kath Ra | 20
On Oh Ew Sar | 35
Ee Oh Gor Dain | 43
Mon Zo Ir Neta | 68
Mon Des Ir Sar | 75

Sunting 1: 212> 210 - Menghapus sepasang kawat gigi

Sunting 2: 210> 207 - Terima kasih Langkah Hen untuk pengingat pada aturan JS dan beberapa petunjuk tentang penggunaan fungsi eval (). Karena AS3 melarang penggunaan eval () saya belum menggunakannya untuk waktu yang lama

Sunting 3: 207> 206 - Terima kasih Shaggy untuk gagasan mengganti indexOf () dengan pencarian ()


1
Kecuali Anda memanggil gbagian dalam g, kami mengizinkan jawaban JS untuk menghapus g=. Selain itu, Anda dapat menyimpan beberapa byte dengan mengalihkannya ke eval dan menghapus return: Fiddle
Stephen

@StepHen Terima kasih atas ide eval () dan aturan JS, karena AS3 melarang eval () saya pikir saya tidak dapat menggunakannya lagi
Shieru Asakoto

Yah, masih berfungsi, dan kami mendefinisikan bahasa dengan implementasinya: P
Stephen

1
searchakan menghemat lebih banyak byte indexOf.
Shaggy

@Shaggy Berhasil, terima kasih atas ide pencariannya;)
Shieru Asakoto

3

Haskell , 159 156 148 133 130 127 byte

k(p:y)=sum$floor<$>c p:map(\x->c x*(c p+1)/2)y
c s=read["3764529516342767"!!(foldl(\c n->c*94+fromEnum n-9)0s%7086%17)]
(%)=mod

Cobalah online!


3

Python 2 , 320 318 314 311 307 byte

Format Input - Daftar String. Program lengkap:

i=input()
t=[x.split()for x in"Lo Um On Ee Pal Mon|Ya Vi Oh Ful Des Zo|Ven Ew Kath Ir Bro Gor|Ku Ros Dain Neta Ra Sar".split('|')]
c=t[0].index(i[0])+1;r=c+1;s=c+r*(t[1].index(i[1])+2)/2
if len(i)>2:s+=r*(t[2].index(i[2])+4-(i[2]=='Bro'))/2
if len(i)>3:s+=r*(t[3].index(i[3])+1+(i[3]in'KuRaSar'))/2
print(s)

Cobalah online!


1
Saya agak menyerah bermain golf ini, jadi siapa pun yang memiliki ide golf dipersilakan untuk mengeditnya sendiri .
Tn. Xcoder

3

Excel, 339 byte

Input dimasukkan A1melalui D1. Formula di sel lain mana pun.

=CHOOSE(MOD(CODE(A1),12),2,,,1,6,,3,5,4)+INT((CHOOSE(MOD(CODE(A1),12),2,,,1,6,,3,5,4)+1)*CHOOSE(MOD(CODE(B1),12),,3,,,2,7,4,6,,5)/2)+INT((CHOOSE(MOD(CODE(A1),12),2,,,1,6,,3,5,4)+1)*CHOOSE(MOD(CODE(C1),12),7,4,6,,,7,,,5,,9)/2)+INT((CHOOSE(MOD(CODE(A1),12),2,,,1,6,,3,5,4)+1)*CHOOSE(MOD(CODE(SUBSTITUTE(D1,"Ra","E")),11),4,3,6,,2,7,,,2,0)/2)

Atau, mengimpor sebagai CSV:

Excel & CSV, 228 byte

,,,
=CHOOSE(MOD(CODE(A1),12),2,,,1,6,,3,5,4)+1
=A2-1+INT(A2*CHOOSE(MOD(CODE(B1),12),,3,,,2,7,4,6,,5)/2)+INT(A2*CHOOSE(MOD(CODE(C1),12),7,4,6,,,7,,,5,,9)/2)+INT(A2*CHOOSE(MOD(CODE(SUBSTITUTE(D1,"Ra","E")),11),4,3,6,,2,7,,,2,0)/2)

Input dimasukkan di baris pertama, SPACEuntuk nol. Hasilnya ditampilkan dalam A3.


2

SCALA, 1106 karakter, 1106 byte

Ini cukup lama, mungkin dapat dioptimalkan, tapi itu menyenangkan untuk dilakukan :)

Format input : rune yang dipisahkan ruang dalam sebuah string. Jika hanya ada 2 input (seperti "Lo Ful") kode saya melengkapinya while(k.length<4)k:+=""(jadi saya bisa menghemat 24 byte dengan mengubah parameter, jika saya memerlukannya menjadi "ABC D").

def n(i:Int,p:String):Int={Math.floor(i*((""+p(0)).toInt+1)/2).toInt}
def m(s:String):Int={var k=s.split(' ')

while(k.length<4)k:+=""

k match{case Array(p,i,f,a)=>{p match{case "Lo"=>1+m(1+"/ "+i+" "+f+" "+a)
case "Um"=>2+m(2+"/ "+i+" "+f+" "+a)
case "On"=>3+m(3+"/ "+i+" "+f+" "+a)
case "Ee"=>4+m(4+"/ "+i+" "+f+" "+a)
case "Pal"=>5+m(5+"/ "+i+" "+f+" "+a)
case "Mon"=>6+m(6+"/ "+i+" "+f+" "+a)
case _ if p.contains("/")=>i match{case "Ya"=>n(2,p)+m(p+" / "+f+" "+a)
case "Vi"=>n(3,p)+m(p+" / "+f+" "+a)
case "Oh"=>n(4,p)+m(p+" / "+f+" "+a)
case "Ful"=>n(5,p)+m(p+" / "+f+" "+a)
case "Des"=>n(6,p)+m(p+" / "+f+" "+a)
case "Zo"=>n(7,p)+m(p+" / "+f+" "+a)
case _ if p.contains("/")=>f match{case "Ven"=>n(4,p)+m(p+" / "+"/ "+a)
case "Ew"=>n(5,p)+m(p+" / "+"/ "+a)
case "Kath"=>n(6,p)+m(p+" / "+"/ "+a)
case "Ir"=>n(7,p)+m(p+" / "+"/ "+a)
case "Bro"=>n(7,p)+m(p+" / "+"/ "+a)
case "Gor"=>n(9,p)+m(p+" / "+"/ "+a)
case _ if p.contains("/")=>a match{case "Ku"=>n(2,p)
case "Ros"=>n(2,p)
case "Dain"=>n(3,p)
case "Neta"=>n(4,p)
case "Ra"=>n(6,p)
case "Sar"=>n(7,p)
case _=>0}
case _=>0}
case _=>0}
case _=>0}}}}

Terima kasih atas tantangan luar biasa ini. Cobalah online!


@Arnauld Saya baru saja memperhatikan sesuatu tentang kode saya: tidak benar-benar memeriksa apakah ada! Maksud saya, jika saya memasukkan "Lo Whoo Gor" hasilnya 5! Apakah itu oke? Atau haruskah saya memperbaiki ini?
V. Courtois

Itu bagus karena "rune dijamin valid" (aturan ke-2).
Arnauld

Oh benar :) Saya melakukannya tanpa berpikir jadi saya lupa aturan ini. Terima kasih lagi.
V. Courtois

2

Bahasa Pemrograman Shakespeare , 4420 byte

,.Ajax,.Ford,.Page,.Puck,.Romeo,.Act I:.Scene I:.[Enter Romeo and Page]Page:You big big big big big big cat.[Exit Romeo][Enter Ajax]Page:Open thy mind!Ajax:Open thy mind!Open thy mind!You is the sum of Romeo and the sum of a big big cat and a cat.Am I as big as you?If not,let us return to Scene V.Page:You is the sum of a big big cat and a cat.Let us return to Act V.Scene V:.Ajax:You is the sum of you and the sum of a big big big cat and a pig.Am I as big as you?If not,let us return to Scene X.Page:You big cat.Let us return to Act V.Scene X:.Ajax:You is the sum of you and the sum of a big cat and a cat.Am I as big as you?If not,let us return to Scene L.Page:You big big cat.Let us return to Act V.Scene L:.Ajax:You is the sum of you and the sum of a big big cat and a big cat.Am I as big as you?If not,let us return to Scene C.Page:You is the sum of a big cat and a cat.Let us return to Act V.Scene C:.Ajax:Am I as big as the sum of you and a big big big pig?Page:You is the sum of a big big cat and a big cat.If so,you is the sum of you and a cat.Ajax:Open thy mind!Act V:.Scene I:.[Exit Ajax][Enter Ford]Page:Open thy mind!Ford:Open thy mind!Open thy mind!You is the sum of Romeo and the sum of a big big big big cat and a pig.Am I as big as you?If not,let us return to Scene V.Page:You big big cat.Let us return to Act X.Scene V:.Ford:You is the sum of you and the sum of a big big big cat and a pig.Am I as big as you?If not,let us return to Scene X.Page:You is the sum of a big cat and a cat.Let us return to Act X.Scene X:.Ford:You is the sum of you and a big big cat.Am I as big as you?If not,let us return to Scene L.Page:You is the sum of a big big big cat and a pig.Let us return to Act X.Scene L:.Ford:Am I as big as the sum of you and a pig?If not,let us return to Scene C.Page:You big cat.Let us return to Act X.Scene C:.Ford:Am I as big as the sum of Romeo and a big big cat?Page:You is the sum of a big big cat and a cat.If so,you is the sum of you and a cat.Ford:Open thy mind!Act X:.Scene I:.[Exit Page][Enter Puck]Ford:You is the sum of the sum of Ajax and a pig and the quotient between the product of Ajax and I and a big cat.Puck:Open thy mind!Is you as big as a pig?If so,let us return to Act D.[Exit Puck][Enter Page]Ford:Open thy mind!Open thy mind!You is the sum of Romeo and the sum of a big big cat and a cat.Am I as big as you?If not,let us return to Scene V.Page:You is the sum of a big big cat and a cat.Let us return to Act L.Scene V:.Ford:Am I as big as the sum of you and a big big cat?If not,let us return to Scene X.Page:You is the sum of a big big big cat and a pig.Let us return to Act L.Scene X:.Ford:Open thy mind!Am I as big as the sum of Romeo and a big cat?If not,let us return to Scene L.Page:You is the sum of a big big big cat and a pig.Let us return to Act L.Scene L:.Ford:You is the sum of Romeo and the sum of a big big big cat and a pig.Am I as big as you?If not,let us return to Scene C.Page:You is the sum of a big big big cat and a cat.Let us return to Act L.Scene C:.Ford:Am I as big as the sum of you and a big big cat?If so,let us return to Scene D.Page:You big big cat.Let us return to Act L.Scene D:.Page:Open thy mind!You is the sum of a big big cat and a big cat.Act L:.Scene I:.[Exit Page][Enter Puck]Ford:You is the sum of you and the quotient between the product of Ajax and I and a big cat.Puck:Open thy mind!Is you as big as a pig?If so,let us return to Act D.[Exit Puck][Enter Page]Ford:You is the sum of Romeo and a big big cat.Am I as big as you?If not,let us return to Scene V.Page:You is the sum of a big cat and a cat.Let us return to Act C.Scene V:.Ford:You is the sum of you and the sum of a big big big cat and a pig.Am I as big as you?If not,let us return to Scene X.Page:You big cat.Let us return to Act C.Scene X:.Ford:Am I as big as the sum of you and the sum of a big cat and a cat?If not,let us return to Scene L.Page:You big big cat.Let us return to Act C.Scene L:.Ford:Am I as big as the sum of you and a big big big cat?If not,let us return to Scene C.Page:You is the sum of a big big big cat and a pig.Let us return to Act C.Scene C:.Page:Open thy mind!Is you as big as the sum of Romeo and a cat?You big cat.If so,you is the sum of you and a big big cat.Act C:.Scene I:.[Exit Page][Enter Puck]Ford:You is the sum of you and the quotient between the product of Ajax and I and a big cat.Act D:.Scene I:.Ford:Open thy heart![Exeunt]

Mengambil input sebagai string huruf besar.

Penjelasan akan segera hadir ... Untuk saat ini, Fakta menyenangkan: Microsoft adalah kata benda negatif di SPL. Semua kata diterima lainnya muncul dalam karya Shakespeare.

Cobalah online!


1

Java (OpenJDK 8) , 252 byte

r->{int c[][]={{2,3,4,5,6,7},{4,5,6,7,7,9},{2,2,3,4,6,7}},l=r.length,p="LUOEPM".indexOf(r[0].charAt(0))+1,a=p,i=0;String[]s={"YVOFDZ","VEKIBG","KRDNXS"};for(;i<l-1;)a+=(p+1)*c[i][s[i++].indexOf((l>3?r[i].replace("Ra","X"):r[i]).charAt(0))]/2;return a;}

Cobalah online!

Tanda adalah input sebagai String[](array dariString ), dalam bentuk huruf pertama (huruf pertama adalah huruf besar, sisanya huruf kecil).

Ini adalah "menemukan n-th huruf" metode standar, dengan twist yang baik Rosdan Raada di segmen ke-4. Saya memperlakukannya dengan pengganti inline dan eksplisit Rauntuk X.


1

Retina , 124 123 byte

Gor
9
[ZIBS]\w+
7
Mon|Des|Kath|Ra
6
..l|Ew
5
Ee|Oh|Ven|Neta
4
[OVD]\w+
3
[UYKR]\w+
2
Lo
1
\d
$*
(?<=^(1+) .*1)
$1
\G1
11
11

Cobalah online! Tautan termasuk kasus uji. Membawa rune yang dipisahkan oleh ruang. Penjelasan: Tahap-tahap awal cukup mengkonversi setiap rune menjadi digit, yang kemudian dikonversi ke unary. Angka-angka setelah yang pertama dikalikan dengan satu lebih dari angka pertama, yang diikuti dengan angka pertama digandakan. Integer tahap akhir membagi semua hasil dengan 2 dan mengambil jumlah.


1

C, 274

#define c(p,r,x)(p+1)*b(r[x+1],x*17)/2
i;char*a="& ; $ # 4 %        ; B * 6 $ 8          6 5 - >3  +  A@( .   6 5    ";b(r,s)char*r;{for(i=0;i<17;i++)if(a[i+s]-3==(r[0]^r[1]))return i/2+1;return 0;}main(n,r)char**r;{n=b(r[1],0);printf("%d\n",n+c(n,r,1)+c(n,r,2)+c(n,r,3));}

Lebih ungolfed:

#include<stdio.h>
char*a="& ; $ # 4 %      "
       "  ; B * 6 $ 8    "
       "      6 5 - >3  +"
       "  A@( .   6 5    ";
int b(char*r,int s){
  for(int i=0;i<17;i++)
    if(a[i+s]-3==(r[0]^r[1]))
      return i/2+1;
  return 0;
}
#define c(p,r,i)(p+1)*b(r[i+1],i*17)/2
int main(int n,char**r){
  int x=b(r[1],0);
  printf("%d\n",x+c(x,r,1)+c(x,r,2)+c(x,r,3));
}

Anda perlu menyediakan empat argumen baris perintah - jadi untuk kasus uji pertama yang perlu Anda jalankan ./a.out Lo Ful "" ""



1

Pergi, 205 byte

func c(s []string)int{f,l:=strings.IndexByte,len(s)
p:=f("UOEPM",s[0][0])+3
r:=p-1+p*(f("VOFDZ",s[1][0])+3)/2
if l>2{r+=p*(f("war o",s[2][1])+5)/2}
if l>3{r+=p*(f("it Ra",s[3][len(s[3])-2])+3)/2}
return r}

Ini adalah fungsi yang bisa dipanggil, mengambil rune sebagai sepotong string, misalnya []string{"Um", "Ful"} .

Cobalah di Go Playground .


0

Haskell, 623 byte

Menggunakan ADT bukan voodoo numerik.

CATATAN: Tambahkan 36 untuk {-# LANGUAGE GADTs,ViewPatterns #-}

  • Skor dihitung dengan asumsi bahwa itu dikompilasi / dijalankan dengan -XGADTs -XViewPatterns
data P=Lo|Um|On|Ee|Pal|Mon deriving(Enum,Read,Eq)
data E=Ya|Vi|Oh|Ful|Des|Zo deriving(Enum,Read,Eq)
data F=Ven|Ew|Kath|Ir|Bro|Gor deriving(Enum,Read,Eq)
data C=Ku|Ros|Dain|Neta|Ra|Sar deriving(Enum,Read,Eq)
data S where
  S::P->E->S
  Q::P->E->F->S
  R::P->E->F->C->S
k(a:b:x)=let{p=read a;e=read b}in case x of{[]->S p e;[c]->Q p e(read c);[c,d]->R p e(read c)(read d)}
c,d::Enum a=>a->Int
c=succ.fromEnum
d=(+2).fromEnum
e Bro=7
e x=(+2).d$x
f x|c x`elem`[1,5,6]=d x|2>1=c x
g p f x =(`div`2).(*f x).succ$c p
h(S x y)=c x+g x d y
h(Q x y z)=h(S x y)+g x e z
h(R x y z t)=h(Q x y z)+g x f t
main=print.h.k.words=<<getLine

Input: mantra tunggal sebagai string normal, mis

Lo Ful

Um Ful

Multilining dapat dilakukan dengan mengganti baris terakhir dengan

main=interact$unlines.map(show.h.k.words).lines

Tapi ini akan menambah byte ke hitungan

Dengan menggunakan situs kami, Anda mengakui telah membaca dan memahami Kebijakan Cookie dan Kebijakan Privasi kami.
Licensed under cc by-sa 3.0 with attribution required.