Skip to content

Instantly share code, notes, and snippets.

@klebervirgilio
Created September 26, 2010 02:57
Show Gist options
  • Save klebervirgilio/597539 to your computer and use it in GitHub Desktop.
Save klebervirgilio/597539 to your computer and use it in GitHub Desktop.
data = [
215211,
218166,
221817,
224000,
226665,
228260,
230059,
235005,
239554,
243644,
244229,
248724,
250621,
253107,
257840,
260397,
263290,
266246,
268191,
271923,
276703,
279468,
281109,
283918,
288607,
292758,
295530,
295718,
299530,
304426,
307449,
310744,
313820,
316042,
320876,
322091,
324893,
326415,
326509,
327771,
330306,
332677,
335087,
339759,
340919,
343180,
343762,
344373,
347172,
351216,
352446,
354891,
357937,
362084,
362136,
366963,
368557,
372634,
377302,
381532,
384369,
389128,
391507,
393302,
395625,
398687,
400993,
403942,
408525,
412100,
412603,
413878,
415473,
416377,
417988,
422406,
425364,
426990,
431462,
432372,
435207,
440165,
444635,
446404,
448530,
450169,
450285,
453539,
456968,
459076,
460354,
461168,
465994,
468758,
472479,
475137,
478789,
483067,
483790,
485178,
489976,
490061,
492556,
493807,
494142,
499124,
501400,
503539,
507825,
511505,
512553,
515160,
516716,
518349,
521650,
526589,
531188,
532627,
536248,
537679,
541852,
542395,
545451,
545586,
550170,
553326,
556350,
556975,
559800,
562676,
564271,
567283,
571098,
573670,
577077,
580834,
584396,
584929,
588909,
593169,
593702,
594157,
598596,
602804,
603334,
605451,
608559,
611557,
612271,
617173,
619290,
621506,
625161,
628991,
629690,
632358,
632778,
633607,
634525,
639207,
639902,
641316,
645022,
648391,
648776,
651371,
654495,
657165,
660159,
663456,
666792,
668091,
669828,
674566,
678329,
680238,
680775,
683102,
685970,
689648,
693116,
698041,
702015,
706025,
709427,
712393,
715228,
718906,
721200,
724987,
725968,
727817,
730538,
732390,
735769,
740369,
740791,
743480,
744848,
748253]
result = []
data.each do |bit|
unless bit.to_s =~ /(11|22|33|44|55|66|77|88|99|00)/
result << bit if bit.to_s.each_char.map{|item| item.to_i}.inject(:+) % 2 != 0
end
end
p result.size
#One line...
p data.select{|bit| bit if (bit.to_s.each_char.map{|item| item.to_i}.inject(:+) % 2 != 0) and !(bit.to_s =! /(11|22|33|44|55|66|77|88|99|00)/) }.size
@klebervirgilio
Copy link
Author

Carakas qria ver em python....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment