ChallengeR #3

Votre dernière mission consistait à compter le nombre de chiffres pairs du vecteur x avec le moins de code possible (étant bien entendu que les espaces, les indentations et les retours à la ligne ne sont pas comptés comme des caractères).

x <- sample(0:9, 100, TRUE)

La meilleure réponse possible était :

sum(! x %% 2)

... et vous êtes 14 à l'avoir trouvée. Dans l'ordre d'arrivée : @thedudeparis, @_antoineb, @_pvictorr, @davidgohel, @loicmolinari, @AlekVladNevski @privefl, @basiliximAb @dickoah, @ClementinC @StephaneOrlins, @claramorganexxx (ahem..), @francois_ls et @After_Eight. Bravo à toutes et à tous !

Comme vous êtes bons, on va augmenter la difficulté. Votre mission, si vous l'acceptez, consiste à coder une fonction syracuse qui renvoie la suite de Syracuse de n'importe quel entier x jusqu'à ce qu'elle atteigne 1. En d'autres termes, nous cherchons une fonction de type :

syracuse = function(x) {
 # faire quelque chose...
}

De telle sorte que :

> syracuse(42)
[1] 42 21 64 32 16  8  4  2  1

Mais comme ça, c'est trop facile, vous allez faire ça sans boucle (ni for ni while ni repeat !).

13 commentaires:

  1. It reveals how nicely you perceive this subject.

    RépondreSupprimer
  2. Bookmarked this website page, will come back for extra articles.

    RépondreSupprimer
  3. Rattling wonderful visual appeal on this web site, I’d value it 10 over 10.

    RépondreSupprimer
  4. Thanks for your marvelous posting! I certainly enjoyed reading this article... MM

    RépondreSupprimer
  5. Wonderful article. It's very useful. I think it's one of the most informative Websites... MM

    RépondreSupprimer
  6. I have taken this blog that written very well. I like you. I'll support you... MM

    RépondreSupprimer
  7. Such a valuable post. I like it very much, Love your skills in writing Thanks... MM

    RépondreSupprimer
  8. I found so many interesting stuff in this blog. Really its great article. Keep it up... MM

    RépondreSupprimer

  9. I am happy to find this way of writing the post. Thank you for this useful info

    RépondreSupprimer


  10. Really amazed with your writing talent. Thanks for sharing, Love your works

    RépondreSupprimer


  11. It’s really a cool and useful piece of info.

    RépondreSupprimer


  12. Wow, happy to see this awesome post. Thanks for sharing a great information

    RépondreSupprimer

  13. Pretty! This has been an extremely wonderful post. Thank you for supplying this info.

    RépondreSupprimer

Votre mot de passe

On ne va pas épiloguer pendant 150 ans, vous avez besoin : De mots de passe très forts (à partir de 128 bits), un par site (sauf, éventuel...