Palindromes

Avec :

url <- "collez ce lien entre les guillemets"
dico <- scan(url, what = "character", sep = "\n")

> length(dico)
[1] 336531

Exécutez ça :

sapply(dico, function(a) {
      paste(rev(strsplit(a, "")[[1]]), collapse = "")
} ) -> ocid

Ce qui nous donne une liste de palindromes:

> dico[which(dico == ocid)]
 [1] "a"         "à"         "alla"      "ana"       "ara"       "aviva"    
 [7] "axa"       "bob"       "cc"        "elle"      "erre"      "essayasse"
[13] "esse"      "été"       "étêté"     "eue"       "gag"       "ici"      
[19] "kayak"     "lebel"     "nanan"     "non"       "pep"       "pop"      
[25] "radar"     "ressasser" "retâter"   "rotor"     "sagas"     "salas"    
[31] "sanas"     "sapas"     "sas"       "sassas"    "selles"    "semâmes"  
[37] "sénés"     "sennes"    "serres"    "ses"       "sexes"     "shahs"    
[43] "sis"       "snobons"   "solos"     "sonos"     "sus"       "tâtât"    
[49] "tôt"       "tut"       "tût"       "y"

... ou une liste d'anacyclique :

> intersect(dico, ocid)
  [1] "a"         "à"         "adoré"     "ados"      "adulé"     "affins"   
  [7] "ah"        "ail"       "ailla"     "aimé"      "air"       "aira"     
 [13] "alevin"    "alla"      "allia"     "alliacé"   "amis"      "an"       
 [19] "ana"       "angor"     "animal"    "annotas"   "annotât"   "annoté"   
 [25] "ara"       "ares"      "aria"      "arum"      "as"        "assit"    
 [31] "aval"      "avaler"    "aviva"     "axa"       "bac"       "bob"      
 [37] "bol"       "bons"      "but"       "cab"       "cal"       "calf"     
 [43] "camus"     "cas"       "casser"    "cc"        "ces"       "cor"      
 [49] "coté"      "crut"      "dus"       "écaffe"     etc...

Aucun commentaire:

Enregistrer un commentaire