Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1.  
  2.  
  3. Challenge 3 - A l'abri !
  4. by Kenny
  5.  
  6. Bonus:
  7.  
  8. Instructions
  9.  
  10. Directions
  11. 3 - A l'abri !
  12.  
  13. La bataille fait rage, et vous avez survécu jusqu'à présent. Mais le plus dur reste devant vous !
  14.  
  15. "Rétrécissement de la zone de combat dans 2 minutes"
  16.  
  17. Vite, il faut rejoindre la zone sécurisée !! Mais où est-elle ?
  18.  
  19. Vous ouvrez votre carte : il y a n zones, toutes numérotées de 1 à n, mais seule l'une d'entre elles est sécurisée. Sa coordonnée sur la carte correspond au nombre total de chiffres qui sont nécessaires pour écrire tous les nombres entre 1 et n.
  20.  
  21. Donnez vite une fonction qui à partir du nombre de zones donne la coordonnée de la zone sécurisée !
  22. Entrée
  23.  
  24. L'entrée est un entier n avec 0 < n < 10^10
  25. Sortie
  26.  
  27. Votre fonction doit retourner un entier représentant le nombre de chiffres nécessaires pour écrire tous les nombres de 1 à n (compris)
  28. Exemples
  29.  
  30. Entrée : 12
  31. Sortie : 15
  32. Explication: 1 2 3 4 5 6 7 8 9 10 11 12 -> 15 chiffres
  33.  
  34. Entrée : 750
  35. Sortie : 2142
  36.  
  37. .
  38.  
  39. .
  40.  
  41. .
  42. 3 - Take cover!
  43.  
  44. The battle rages on, and you have survived until now. But the hardest part is still ahead of you!
  45.  
  46. "Battle zone shrinks in 2 minutes "
  47.  
  48. Quick, we have to get to the safe zone! Where the hell is it?
  49.  
  50. You open your map : there are n zones, all numbered from 1 to n, but only one of them is safe. Its coordinate on the card is the total number of digits that are needed to write all the numbers between 1 and n.
  51.  
  52. Quick, give a function that from the number of zones gives the coordinate of the safe zone!
  53. Input
  54.  
  55. The input is an integer n with 0 < n < 10^10.
  56. Output
  57.  
  58. Your function must return an integer representing the number of digits needed to write all numbers from 1 to n (inclusive).
  59. Examples
  60.  
  61. Input : 12
  62. Output : 15
  63. Explanation: 1 2 3 4 5 6 7 8 9 10 11 12 -> 15 digits
  64.  
  65. Input : 750
  66. Output : 2142
  67. Test Cases
  68. Test 1
  69. Test 2
  70. Test 3
  71. Test 4
  72. Test 5
  73. Test 6
  74. Test 7
  75. Test 8
  76. Test 9
  77. Test 10
  78. Test 11
  79. Test 12
  80. Test 13
  81. Test 14
  82. Test 15
  83. Test 16
  84. Test 17
  85. Test 18
  86. Test 19
  87. Test 20
  88.  
  89. Console output
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement