Abbreviations, automatic: Difference between revisions
Content deleted Content added
m added more related tasks. |
|||
Line 2,303:
4 djadomingu djaluna djamars djarason djaweps djabièrnè djasabra
2 Killachau Atichau Quoyllurchau Illapachau Chaskachau Kuychichau Intichau</pre>
=={{header|Nim}}==
====Using a set====
<lang Nim>
import sets
import unicode
type Runes = seq[Rune]
var linenum = 0
for line in lines("days.txt"):
inc linenum
if line.len > 0:
# Extract the day names and store them in a sorted list of sequences of runes.
var days: seq[Runes]
for day in line.splitWhitespace():
days.add(day.toLower.toRunes)
if days.len != 7:
echo "Wrong number of days at line ", linenum
# Build the abbreviations and store them in a set.
var index = 0
while true:
var abbrevs: HashSet[seq[Rune]]
for day in days:
abbrevs.incl(day[0..min(index, day.high)])
if abbrevs.card == 7:
# All abbreviations are different: fine!
break
inc index
echo index + 1, " ", line
else:
echo line
</lang>
====Using a sorted list====
<lang Nim>
import algorithm
import unicode
type Runes = seq[Rune]
var linenum = 0
for line in lines("days.txt"):
inc linenum
if line.len > 0:
# Extract the day names and store them in a sorted list of sequences of runes.
var days: seq[Runes]
for day in sorted(line.toLower.splitWhitespace()):
days.add(day.toRunes)
if days.len != 7:
echo "Wrong number of days at line ", linenum
# Compare the first letters of successive day names, incrementing the upper index if necessary.
var index = 0 # Equal to abbreviation length - 1.
var prevday = days[0]
for idx in 1..days.high:
let currday = days[idx]
if currday == prevday:
echo "Double encountered at line ", linenum
while currday[0..min(index, currday.high)] == prevday[0..min(index, prevday.high)]:
inc index
prevday = currday
echo index + 1, " ", line
else:
echo line
</lang>
{{out}}
<pre>
2 Sunday Monday Tuesday Wednesday Thursday Friday Saturday
2 Sondag Maandag Dinsdag Woensdag Donderdag Vrydag Saterdag
4 E_djelë E_hënë E_martë E_mërkurë E_enjte E_premte E_shtunë
2 Ehud Segno Maksegno Erob Hamus Arbe Kedame
5 Al_Ahad Al_Ithinin Al_Tholatha'a Al_Arbia'a Al_Kamis Al_Gomia'a Al_Sabit
4 Guiragui Yergou_shapti Yerek_shapti Tchorek_shapti Hink_shapti Ourpat Shapat
2 domingu llunes martes miércoles xueves vienres sábadu
2 Bazar_gÜnÜ Birinci_gÜn Çkinci_gÜn ÜçÜncÜ_gÜn DÖrdÜncÜ_gÜn Bes,inci_gÜn Altòncò_gÜn
6 Igande Astelehen Astearte Asteazken Ostegun Ostiral Larunbat
4 Robi_bar Shom_bar Mongal_bar Budhh_bar BRihashpati_bar Shukro_bar Shoni_bar
2 Nedjelja Ponedeljak Utorak Srijeda Cxetvrtak Petak Subota
5 Disul Dilun Dimeurzh Dimerc'her Diriaou Digwener Disadorn
2 nedelia ponedelnik vtornik sriada chetvartak petak sabota
12 sing_kei_yaht sing_kei_yat sing_kei_yee sing_kei_saam sing_kei_sie sing_kei_ng sing_kei_luk
4 Diumenge Dilluns Dimarts Dimecres Dijous Divendres Dissabte
16 Dzeenkk-eh Dzeehn_kk-ehreh Dzeehn_kk-ehreh_nah_kay_dzeeneh Tah_neesee_dzeehn_neh Deehn_ghee_dzee-neh Tl-oowey_tts-el_dehlee Dzeentt-ahzee
6 dy_Sul dy_Lun dy_Meurth dy_Mergher dy_You dy_Gwener dy_Sadorn
2 Dimanch Lendi Madi Mèkredi Jedi Vandredi Samdi
2 nedjelja ponedjeljak utorak srijeda cxetvrtak petak subota
2 nede^le ponde^lí úterÿ str^eda c^tvrtek pátek sobota
2 Sondee Mondee Tiisiday Walansedee TOOsedee Feraadee Satadee
2 s0ndag mandag tirsdag onsdag torsdag fredag l0rdag
2 zondag maandag dinsdag woensdag donderdag vrijdag zaterdag
2 Diman^co Lundo Mardo Merkredo ^Jaùdo Vendredo Sabato
1 pÜhapäev esmaspäev teisipäev kolmapäev neljapäev reede laupäev
7 Diu_prima Diu_sequima Diu_tritima Diu_quartima Diu_quintima Diu_sextima Diu_sabbata
2 sunnudagur mánadagur tÿsdaguy mikudagur hósdagur friggjadagur leygardagur
2 Yek_Sham'beh Do_Sham'beh Seh_Sham'beh Cha'har_Sham'beh Panj_Sham'beh Jom'eh Sham'beh
2 sunnuntai maanantai tiistai keskiviiko torsktai perjantai lauantai
2 dimanche lundi mardi mercredi jeudi vendredi samedi
4 Snein Moandei Tiisdei Woansdei Tonersdei Freed Sneon
2 Domingo Segunda_feira Martes Mércores Joves Venres Sábado
2 k'vira orshabati samshabati otkhshabati khutshabati p'arask'evi shabati
2 Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Samstag
2 Kiriaki' Defte'ra Tri'ti Teta'rti Pe'mpti Paraskebi' Sa'bato
3 ravivaar somvaar mangalvaar budhvaar guruvaar shukravaar shanivaar
6 pópule pó`akahi pó`alua pó`akolu pó`ahá pó`alima pó`aono
7 Yom_rishon Yom_sheni Yom_shlishi Yom_revi'i Yom_chamishi Yom_shishi Shabat
3 ravivara somavar mangalavar budhavara brahaspativar shukravara shanivar
3 vasárnap hétfö kedd szerda csütörtök péntek szombat
2 Sunnudagur Mánudagur ╞riδjudagur Miδvikudagar Fimmtudagur FÖstudagur Laugardagur
2 sundio lundio mardio merkurdio jovdio venerdio saturdio
3 Minggu Senin Selasa Rabu Kamis Jumat Sabtu
2 Dominica Lunedi Martedi Mercuridi Jovedi Venerdi Sabbato
4 Dé_Domhnaigh Dé_Luain Dé_Máirt Dé_Ceadaoin Dé_ardaoin Dé_hAoine Dé_Sathairn
2 domenica lunedí martedí mercoledí giovedí venerdí sabato
2 Nichiyou_bi Getzuyou_bi Kayou_bi Suiyou_bi Mokuyou_bi Kin'you_bi Doyou_bi
1 Il-yo-il Wol-yo-il Hwa-yo-il Su-yo-il Mok-yo-il Kum-yo-il To-yo-il
7 Dies_Dominica Dies_Lunæ Dies_Martis Dies_Mercurii Dies_Iovis Dies_Veneris Dies_Saturni
3 sve-tdien pirmdien otrdien tresvdien ceturtdien piektdien sestdien
2 Sekmadienis Pirmadienis Antradienis Trec^iadienis Ketvirtadienis Penktadienis S^es^tadienis
3 Wangu Kazooba Walumbe Mukasa Kiwanuka Nnagawonye Wamunyi
12 xing-_qi-_rì xing-_qi-_yi-. xing-_qi-_èr xing-_qi-_san-. xing-_qi-_sì xing-_qi-_wuv. xing-_qi-_liù
3 Jedoonee Jelune Jemayrt Jecrean Jardaim Jeheiney Jesam
3 Jabot Manre Juje Wonje Taije Balaire Jarere
5 geminrongo minòmishi mártes mièrkoles misheushi bèrnashi mishábaro
2 Ahad Isnin Selasa Rabu Khamis Jumaat Sabtu
2 sφndag mandag tirsdag onsdag torsdag fredag lφrdag
7 lo_dimenge lo_diluns lo_dimarç lo_dimèrcres lo_dijòus lo_divendres lo_dissabte
4 djadomingo djaluna djamars djarason djaweps djabièrna djasabra
2 Niedziela Poniedzial/ek Wtorek S,roda Czwartek Pia,tek Sobota
3 Domingo segunda-feire terça-feire quarta-feire quinta-feire sexta-feira såbado
2 Domingo Lunes martes Miercoles Jueves Viernes Sabado
2 Duminicª Luni Mart'i Miercuri Joi Vineri Sâmbªtª
2 voskresenie ponedelnik vtornik sreda chetverg pyatnitsa subbota
4 Sunday Di-luain Di-màirt Di-ciadain Di-ardaoin Di-haoine Di-sathurne
2 nedjelja ponedjeljak utorak sreda cxetvrtak petak subota
5 Sontaha Mmantaha Labobedi Laboraro Labone Labohlano Moqebelo
2 Iridha- Sandhudha- Anga.haruwa-dha- Badha-dha- Brahaspa.thindha- Sikura-dha- Sena.sura-dha-
2 nedel^a pondelok utorok streda s^tvrtok piatok sobota
2 Nedelja Ponedeljek Torek Sreda Cxetrtek Petek Sobota
2 domingo lunes martes miércoles jueves viernes sábado
2 sonde mundey tude-wroko dride-wroko fode-wroko freyda Saturday
7 Jumapili Jumatatu Jumanne Jumatano Alhamisi Ijumaa Jumamosi
2 söndag måndag tisdag onsdag torsdag fredag lordag
2 Linggo Lunes Martes Miyerkoles Huwebes Biyernes Sabado
6 Lé-pài-jít Pài-it Pài-jï Pài-sañ Pài-sì Pài-gÖ. Pài-lák
7 wan-ar-tit wan-tjan wan-ang-kaan wan-phoet wan-pha-ru-hat-sa-boh-die wan-sook wan-sao
5 Tshipi Mosupologo Labobedi Laboraro Labone Labotlhano Matlhatso
6 Pazar Pazartesi Sali Çar,samba Per,sembe Cuma Cumartesi
2 nedilya ponedilok vivtorok sereda chetver pyatnytsya subota
8 Chu?_Nhâ.t Thú*_Hai Thú*_Ba Thú*_Tu* Thú*_Na'm Thú*_Sáu Thú*_Ba?y
6 dydd_Sul dyds_Llun dydd_Mawrth dyds_Mercher dydd_Iau dydd_Gwener dyds_Sadwrn
3 Dibeer Altine Talaata Allarba Al_xebes Aljuma Gaaw
7 iCawa uMvulo uLwesibini uLwesithathu uLuwesine uLwesihlanu uMgqibelo
2 zuntik montik dinstik mitvokh donershtik fraytik shabes
7 iSonto uMsombuluko uLwesibili uLwesithathu uLwesine uLwesihlanu uMgqibelo
7 Dies_Dominica Dies_Lunæ Dies_Martis Dies_Mercurii Dies_Iovis Dies_Veneris Dies_Saturni
11 Bazar_gÜnÜ Bazar_ærtæsi Çærs,ænbæ_axs,amò Çærs,ænbæ_gÜnÜ CÜmæ_axs,amò CÜmæ_gÜnÜ CÜmæ_Senbæ
2 Sun Moon Mars Mercury Jove Venus Saturn
2 zondag maandag dinsdag woensdag donderdag vrijdag zaterdag
2 KoseEraa GyoOraa BenEraa Kuoraa YOwaaraa FeEraa Memenaa
5 Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Sonnabend
1 Domingo Luns Terza_feira Corta_feira Xoves Venres Sábado
7 Dies_Solis Dies_Lunae Dies_Martis Dies_Mercurii Dies_Iovis Dies_Veneris Dies_Sabbatum
12 xing-_qi-_tiàn xing-_qi-_yi-. xing-_qi-_èr xing-_qi-_san-. xing-_qi-_sì xing-_qi-_wuv. xing-_qi-_liù
4 djadomingu djaluna djamars djarason djaweps djabièrnè djasabra
2 Killachau Atichau Quoyllurchau Illapachau Chaskachau Kuychichau Intichau
</pre>
=={{header|Objeck}}==
|