{"id":2890,"date":"2017-02-03T06:00:53","date_gmt":"2017-02-03T04:00:53","guid":{"rendered":"http:\/\/www.glc.us.es\/~jalonso\/exercitium\/?p=2890"},"modified":"2021-04-25T16:25:11","modified_gmt":"2021-04-25T14:25:11","slug":"sucesion-de-cantor-de-numeros-innombrables-2015","status":"publish","type":"post","link":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/sucesion-de-cantor-de-numeros-innombrables-2015\/","title":{"rendered":"Sucesi\u00f3n de Cantor de n\u00fameros innombrables"},"content":{"rendered":"<p>Un n\u00famero es <strong>innombrable<\/strong> si es divisible por 7 o alguno de sus d\u00edgitos es un 7. Un juego infantil consiste en contar salt\u00e1ndose los n\u00fameros innombrables:<\/p>\n<pre lang=\"text\">\n   1 2 3 4 5 6 ( ) 8 9 10 11 12 13 ( ) 15 16 ( ) 18 ...\n<\/pre>\n<p>La sucesi\u00f3n de Cantor se obtiene llenando los huecos de la sucesi\u00f3n anterior<br \/>\ncomo se indica a continuaci\u00f3n:<\/p>\n<pre lang=\"text\">\n  1 2 3 4 5 6 (1) 8 9 10 11 12 13 (2) 15 16 (3) 18 19 20 (4) 22 23\n  24 25 26 (5) (6) 29 30 31 32 33 34 (1) 36 (8) 38 39 40 41  (9) 43\n  44 45 46 (10) 48 (11) 50 51 52 53 54 55 (12) (13) 58 59 60 61 62\n  (2) 64 65 66 (15) 68 69 (16) (3) (18) (19) (20) (4) (22) (23) (24)\n  (25) 80 81 82 83 (26) 85 86 (5) 88 89 90 (6) 92 93 94 95 96 (29)\n  (30) 99 100\n<\/pre>\n<p>Definir la sucesi\u00f3n<\/p>\n<pre lang=\"text\">\n   sucCantor :: [Integer]\n<\/pre>\n<p>cuyos elementos son los t\u00e9rminos de la sucesi\u00f3n de Cantor. Por ejemplo,<\/p>\n<pre lang=\"text\">\n   \u03bb> take 100 sucCantor\n   [1,2,3,4,5,6, 1 ,8,9,10,11,12,13, 2, 15,16, 3, 18,19,20, 4,\n    22,23,24,25,26, 5 , 6 ,29,30,31,32,33,34, 1 ,36 , 8 ,38,39,\n    40,41, 9 ,43,44,45,46, 10 ,48, 11 ,50,51,52,53,54,55 , 12 ,\n    13, 58,59,60,61,62, 2 ,64,65,66, 15 ,68,69, 16 , 3 , 18, 19,\n    20, 4, 22, 23, 24 ,25 ,80,81,82,83, 26 ,85,86, 5 ,88,89,90,\n    6, 92,93,94,95,96, 29, 30 ,99,100]\n\n   \u03bb> sucCantor2 !! (5+10^6)\n   544480\n\n   \u03bb> sucCantor2 !! (6+10^6)\n   266086\n<\/pre>\n<h4>Soluciones<\/h4>\n<pre lang=\"haskell\">\n-- 1\u00aa soluci\u00f3n\n-- ===========\n\nsucCantor1 :: [Integer]\nsucCantor1 = map fst $ scanl f (1,0) [2..]\n  where f (a,i) x\n          | esInnombrable x = (sucCantor1 !! i, i+1)\n          | otherwise       = (x,i)\n\n\nesInnombrable :: Integer -> Bool\nesInnombrable x =\n  rem x 7 == 0 || '7' `elem` show x\n\n-- 2\u00aa soluci\u00f3n\n-- ===========\n\nsucCantor2 :: [Integer]\nsucCantor2 = aux 0 1\n  where aux i x\n          | esInnombrable x = sucCantor2 !! i : aux (i+1) (x+1)\n          | otherwise       = x : aux i (x+1) \n<\/pre>\n<h4>Referencia<\/h4>\n<p>Basado en <a href=\"http:\/\/bit.ly\/2kS8usC\">Cantor&#8217;s unspeakable numbers<\/a> de<br \/>\nCodeGolf.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Un n\u00famero es innombrable si es divisible por 7 o alguno de sus d\u00edgitos es un 7. Un juego infantil consiste en contar salt\u00e1ndose los n\u00fameros innombrables: 1 2 3 4 5 6 ( ) 8 9 10 11 12 13 ( ) 15 16 ( ) 18 &#8230; La sucesi\u00f3n de Cantor se obtiene&#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":[26,80,10,11,6,31,78,33],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/posts\/2890"}],"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=2890"}],"version-history":[{"count":3,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/posts\/2890\/revisions"}],"predecessor-version":[{"id":2919,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/posts\/2890\/revisions\/2919"}],"wp:attachment":[{"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/media?parent=2890"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/categories?post=2890"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.glc.us.es\/~jalonso\/exercitium\/wp-json\/wp\/v2\/tags?post=2890"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}