Exercism: Go version of the 'Raindrops' exercise.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.2 KiB

9 years ago
  1. # Raindrops
  2. Write a program that converts a number to a string, the contents of which depends on the number's prime factors.
  3. - If the number contains 3 as a prime factor, output 'Pling'.
  4. - If the number contains 5 as a prime factor, output 'Plang'.
  5. - If the number contains 7 as a prime factor, output 'Plong'.
  6. - If the number does not contain 3, 5, or 7 as a prime factor,
  7. just pass the number's digits straight through.
  8. ## Examples
  9. - 28's prime-factorization is 2, 2, 7.
  10. - In raindrop-speak, this would be a simple "Plong".
  11. - 1755 prime-factorization is 3, 3, 3, 5, 13.
  12. - In raindrop-speak, this would be a "PlingPlang".
  13. - The prime factors of 34 are 2 and 17.
  14. - Raindrop-speak doesn't know what to make of that,
  15. so it just goes with the straightforward "34".
  16. To run the tests simply run the command `go test` in the exercise directory.
  17. If the test suite contains benchmarks, you can run these with the `-bench`
  18. flag:
  19. go test -bench .
  20. For more detailed info about the Go track see the [help
  21. page](http://exercism.io/languages/go).
  22. ## Source
  23. A variation on a famous interview question intended to weed out potential candidates. [view source](http://jumpstartlab.com)