Skip to main content

Coding Challenge: Kage Bunshin No Jutsu

Updated 2 min readMarkdown
Part of seriesCoding Exercises. Exercicios de Algoritmo/Programação

[PT-BR] Um ninja começou a treinar o Jutsu Clone das Sombras, seu poder era instável, e após o primeiro clone ser gerado a chance de se gerar o próximo clone era 1% menor, e caso houvesse falha o jutsu era encerrado. Sabendo que a chance de se gerar o primeiro clone era de 100% e que o objetivo é sempre tentar gerar o máximo de clones possíveis, crie um programa que simule este Jutsu. Use sua linguagem favorita e use números aleatórios para que em cada execução ocorra um resultado diferente.

[ENG] A ninja started to practice the Kage Bunshin No Jutsu, his power was instable, and after the first clone appears, the chance of create the next clone was diminished by 1%, and in case that the clone fails the jutsu simply ends. Kepping in mind that the chance of generate the first clone is 100% and that the aim is to generate the maximum number of clones, create a program that simulates this jutsu. Use you favorite programming language and use random numbers so the program will display a different result in every execution.

Uma solução em Java

https://gist.github.com/tictackode/3497382670dd963cd25a7066650b1494

https://gist.github.com/tictackode/3497382670dd963cd25a7066650b1494

A Solution in Python

https://gist.github.com/tictackode/037736989b807e9064fc14920a20b8c0

https://gist.github.com/tictackode/037736989b807e9064fc14920a20b8c0

A Solution in C/C++

https://gist.github.com/tictackode/7c57e26441c4327a7f1183a18a6e82cc

https://gist.github.com/tictackode/7c57e26441c4327a7f1183a18a6e82cc

About the author

  • I'm an Information Systems Bachelor that writes code even by hobby, and now got into a mathematics degree for teaching. Sou formado em Sistemas de Informação, estou cursando Licenciatura em Matemática pela UFF-CEDERJ, e amo programar.

No comments yet. Be the first to comment.

Coding Exercises. Exercicios de Algoritmo/Programação

Part 4 of 9

Nesta série postarei desafios de algoritmo originais e resoluções em diversas linguagens de programação. In this series I will post coding exercises and solutions in many programming languagens.

Up nextCoding Challenge: Pikachu Thundershock![ENG] Create a code that simulates the damage of the Pikachu's thundershock attack for any level! Pass the integer number of the level by parameter to the thundershock(level) function, and the functio

More from this blog