Abbreviations, automatic: Difference between revisions
Content deleted Content added
Added Uiua solution |
→{{header|Uiua}}: Improved algorithm |
||
Line 7,798: | Line 7,798: | ||
=={{header|Uiua}}== |
=={{header|Uiua}}== |
||
{{Works with|Uiua|0.12.0-dev.1}} |
{{Works with|Uiua|0.12.0-dev.1}} |
||
[https://uiua.org/pad?src=0_12_0-dev_1__IyBGaW5kIHNob3J0ZXN0IGRpc3RpbmN0IGFiYnJldmlhdGlvbiBwZXIgbGluZQoKTGluZXMg4oaQIHsiU3VuZGF5IE1vbmRheSBUdWVzZGF5IFdlZG5lc2RheSBUaHVyc2RheSBGcmlkYXkgU2F0dXJkYXkiCiAgICAgICAgICJzaW5nX2tlaV95YWh0IHNpbmdfa2VpX3lhdCBzaW5nX2tlaV95ZWUgc2luZ19rZWlfc2FhbSBzaW5nX2tlaV9zaWUgc2luZ19rZWlfbmcgc2luZ19rZWlfbHVrIgogICAgICAgICAiIgogICAgICAgICAiRGl1X3ByaW1hIERpdV9zZXF1aW1hIERpdV90cml0aW1hIERpdV9xdWFydGltYSBEaXVfcXVpbnRpbWEgRGl1X3NleHRpbWEgRGl1X3NhYmJhdGEiCiAgICAgICAgICJzdW5udWRhZ3VyIG3DoW5hZGFndXIgdMO_c2RhZ3V5IG1pa3VkYWd1ciBow7NzZGFndXIgZnJpZ2dqYWRhZ3VyIGxleWdhcmRhZ3VyIgogICAgICAgICAiWWVrX1NoYW0nYmVoIERvX1NoYW0nYmVoIFNlaF9TaGFtJ2JlaCBDaGEnaGFyX1NoYW0nYmVoIFBhbmpfU2hhbSdiZWggSm9tJ2VoIFNoYW0nYmVoIn0KU3BsaXQg4oaQIOKKnOKWoeKKuCjiiaBAICkKUHJlZiDihpAgKzHirJrCrzHiiqLiiprCrOKsmkAg4omh4omNICMgZm9yIHR3byBzdHJpbmdzIGdpdmUgcG9zIG9mIGZpcnN0IGRpZmYgY2hhcgriiaHil4coJnAkIl86IF8iIDovJCJfIF8i4p-cKOKnu-KKoiniiaHil4firJpAIOKGmS_ihqUv4oal4oqe4peHUHJlZi4uU3BsaXQp4pa94oq44omhKD4w4peH4qe7KUxpbmVzCg== Try it in Uiua Pad!] |
|||
Uses experimental `triangle` feature. |
|||
[https://www.uiua.org/pad?src=0_12_0-dev_1__IyBFeHBlcmltZW50YWwhCiMgRmluZCBzaG9ydGVzdCBkaXN0aW5jdCBhYmJyZXZpYXRpb24gbGVuZ3RoIHBlciBsaW5lCgpMaW5lcyDihpAgeyJTdW5kYXkgTW9uZGF5IFR1ZXNkYXkgV2VkbmVzZGF5IFRodXJzZGF5IEZyaWRheSBTYXR1cmRheSIKICAgICAgICAgInNpbmdfa2VpX3lhaHQgc2luZ19rZWlfeWF0IHNpbmdfa2VpX3llZSBzaW5nX2tlaV9zYWFtIHNpbmdfa2VpX3NpZSBzaW5nX2tlaV9uZyBzaW5nX2tlaV9sdWsiCiAgICAgICAgICIiCiAgICAgICAgICJEaXVfcHJpbWEgRGl1X3NlcXVpbWEgRGl1X3RyaXRpbWEgRGl1X3F1YXJ0aW1hIERpdV9xdWludGltYSBEaXVfc2V4dGltYSBEaXVfc2FiYmF0YSIKICAgICAgICAgInN1bm51ZGFndXIgbcOhbmFkYWd1ciB0w79zZGFndXkgbWlrdWRhZ3VyIGjDs3NkYWd1ciBmcmlnZ2phZGFndXIgbGV5Z2FyZGFndXIiCiAgICAgICAgICJZZWtfU2hhbSdiZWggRG9fU2hhbSdiZWggU2VoX1NoYW0nYmVoIENoYSdoYXJfU2hhbSdiZWggUGFual9TaGFtJ2JlaCBKb20nZWggU2hhbSdiZWgifQoKIyBSZXR1cm4gMSttYXhfY29tbW9uX3ByZWZpeApBYmJyZXZMZW4g4oaQICsxL-KGpeKXuSgv4oal4oaYMSniip4oLytc4oan4qyaQCA94oipwrDilqEpLgpTcGxpdCDihpAg4oqc4pah4oq4KOKJoEAgKQpSZW1vdmVFbXB0eSDihpAg4pa94oq4KOKJoSjiiaAw4peH4qe7KSkKIyDiiaHijZoo4oqC4oqCOiI6ICIgOuKfnCjCsOKLlSBBYmJyZXZMZW4gU3BsaXQpKSBSZW1vdmVFbXB0eSBMaW5lcwojIOKJoSZwCkxpbmUg4oaQIOKKguKKgjoiOiAiIMKw4ouVOuKKuCgvKOKKguKKgikgIiAi4omhKOKsmkAg4oaZOsKw4pahKeKKmcKkKeKfnEFiYnJldkxlbiDil4dTcGxpdAriiaHijZpMaW5lIFJlbW92ZUVtcHR5IExpbmVzCuKJoSZwCg== Try it in Uiua Pad!] |
|||
<syntaxhighlight lang="uiua"> |
<syntaxhighlight lang="uiua"> |
||
⚫ | |||
# Experimental! |
|||
⚫ | |||
Lines ← {"Sunday Monday Tuesday Wednesday Thursday Friday Saturday" |
Lines ← {"Sunday Monday Tuesday Wednesday Thursday Friday Saturday" |
||
Line 7,812: | Line 7,809: | ||
"sunnudagur mánadagur tÿsdaguy mikudagur hósdagur friggjadagur leygardagur" |
"sunnudagur mánadagur tÿsdaguy mikudagur hósdagur friggjadagur leygardagur" |
||
"Yek_Sham'beh Do_Sham'beh Seh_Sham'beh Cha'har_Sham'beh Panj_Sham'beh Jom'eh Sham'beh"} |
"Yek_Sham'beh Do_Sham'beh Seh_Sham'beh Cha'har_Sham'beh Panj_Sham'beh Jom'eh Sham'beh"} |
||
# Return 1+max_common_prefix |
|||
AbbrevLen ← +1/↥◹(/↥↘1)⊞(/+\↧⬚@ =∩°□). |
|||
Split ← ⊜□⊸(≠@ ) |
Split ← ⊜□⊸(≠@ ) |
||
Pref ← +1⬚¯1⊢⊚¬⬚@ ≡≍ # for two strings give pos of first diff char |
|||
RemoveEmpty ← ▽⊸(≡(≠0◇⧻)) |
|||
≡◇(&p$"_: _" :/$"_ _"⟜(⧻⊢)≡◇⬚@ ↙/↥/↥⊞◇Pref..Split)▽⊸≡(>0◇⧻)Lines |
|||
Line ← ⊂⊂:": " °⋕:⊸(/(⊂⊂) " "≡(⬚@ ↙:°□)⊙¤)⟜AbbrevLen ◇Split |
|||
≡⍚Line RemoveEmpty Lines |
|||
≡&p |
|||
</syntaxhighlight> |
</syntaxhighlight> |
||
{{out}} |
{{out}} |