{"id":5497,"date":"2020-02-04T05:30:42","date_gmt":"2020-02-04T03:30:42","guid":{"rendered":"http:\/\/www.glc.us.es\/~jalonso\/exercitium\/?p=5497"},"modified":"2020-02-11T09:16:31","modified_gmt":"2020-02-11T07:16:31","slug":"maximo-numero-de-consecutivos-iguales-al-dado","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/maximo-numero-de-consecutivos-iguales-al-dado\/","title":{"rendered":"M\u00e1ximo n\u00famero de consecutivos iguales al dado"},"content":{"rendered":"<p>Definir la funci\u00f3n<\/p>\n<pre lang=\"text\">\n   maximoConsecutivosIguales :: Eq a => a -> [a] -> Int\n<\/pre>\n<p>tal que (maximoConsecutivosIguales x xs) es el mayor n\u00famero de elementos consecutivos en xs iguales a x. Por ejemplo,<\/p>\n<pre lang=\"text\">\n   maximoConsecutivosIguales 'b' \"abbcccbbbd\"    ==  3\n   maximoConsecutivosIguales 'b' \"abbbbcccbbbd\"  ==  4\n   maximoConsecutivosIguales 'e' \"abbcccbbbd\"    ==  0\n<\/pre>\n<h4>Soluciones<\/h4>\n<pre lang=\"haskell\">\nimport Data.List (group)\n\nmaximoConsecutivosIguales :: Eq a => a -> [a] -> Int\nmaximoConsecutivosIguales x = maximum\n                            . (0:)\n                            . map length\n                            . filter ((== x) . head)\n                            . group\n<\/pre>\n<h4>Otras soluciones<\/h4>\n<ul>\n<li>Se pueden escribir otras soluciones en los comentarios.\n<li>El c\u00f3digo se debe escribir entre una l\u00ednea con &#60;pre lang=\u00bbhaskell\u00bb&#62; y otra con &#60;\/pre&#62;\n<\/ul>\n<h4>Pensamiento<\/h4>\n<blockquote><p>\n\u00abLa programaci\u00f3n de computadoras es un arte, porque aplica el conocimiento<br \/>\nacumulado al mundo, porque requiere habilidad e ingenio, y especialmente<br \/>\nporque produce belleza. Un programador que subconscientemente se ve<br \/>\na s\u00ed mismo como un artista disfrutar\u00e1 con lo que hace y lo har\u00e1 mejor.\u00bb <\/p>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Donald_Knuth\">Donald Knuth<\/a>.\n<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Definir la funci\u00f3n maximoConsecutivosIguales :: Eq a => a -> [a] -> Int tal que (maximoConsecutivosIguales x xs) es el mayor n\u00famero de elementos consecutivos en xs iguales a x. Por ejemplo, maximoConsecutivosIguales &#8216;b&#8217; \u00ababbcccbbbd\u00bb == 3 maximoConsecutivosIguales &#8216;b&#8217; \u00ababbbbcccbbbd\u00bb == 4 maximoConsecutivosIguales &#8216;e&#8217; \u00ababbcccbbbd\u00bb == 0 Soluciones import Data.List (group) maximoConsecutivosIguales :: Eq a&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"footnotes":"","_jetpack_memberships_contains_paid_content":false},"categories":[4],"tags":[38,13,71,28,10,15,11],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/posts\/5497"}],"collection":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/comments?post=5497"}],"version-history":[{"count":5,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/posts\/5497\/revisions"}],"predecessor-version":[{"id":5544,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/posts\/5497\/revisions\/5544"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/media?parent=5497"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/categories?post=5497"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/tags?post=5497"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}