fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7. Console.WriteLine("#1: " + numberOne() + " times");
  8. Console.WriteLine("#2: " + numberTwo() + " mph");
  9. Console.WriteLine("#3: " + numberThree() + " cm^2");
  10. }
  11.  
  12. public static int numberOne()
  13. {
  14. int count = 0;
  15. for (int i = 1; i <= 150; i++)
  16. {
  17. count += (i + "").Split('3').Length - 1;
  18. }
  19. return count;
  20. }
  21.  
  22. public static double numberTwo()
  23. {
  24. int start = 15952;
  25. string num, rev;
  26. while (true)
  27. {
  28. num = start + "";
  29. char[] arr = num.ToCharArray();
  30. Array.Reverse(arr);
  31. rev = new string(arr);
  32. if (num.Equals(rev))
  33. {
  34. break;
  35. }
  36. start++;
  37. }
  38. //average speed in mph
  39. return (start - 15951)/2.0;
  40. }
  41.  
  42. public static double numberThree()
  43. {
  44. //Not really a programming question
  45. //64-7=57 identical cubes with total volume of 1539 cm^3
  46. double vol_per_cube = 1539.0/57; //volume per cube
  47. //Volume for cube: s^3
  48. double sidelength = Math.Pow(vol_per_cube, 1.0/3);
  49. //side length^
  50. sidelength = sidelength * 4; //side length of the entire cube
  51. //it's 4 because: 64 total cubes, 4 (horizontal) * 4 (vertical) * 4 (3d-z-tal-thing) = 64
  52. //surface area of cube: 6s^2
  53. return 6 * Math.Pow(sidelength, 2);
  54. }
  55. }
Success #stdin #stdout 0.03s 33896KB
stdin
Standard input is empty
stdout
#1: 35 times
#2: 55 mph
#3: 864 cm^2