Advertisement
Guest User

Untitled

a guest
Mar 16th, 2016
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.35 KB | None | 0 0
  1. Active Freedom - Test V1.2
  2.  
  3. // Important Update
  4.  
  5. Dear Candidates, Thank you so much for your submissions
  6. We have noticed some of the candidates are taking approaches such as passing or parsing data from files or generating data using functions.
  7. There is no need to do so, our testing app will generate a super large string like shown below and pass it through your function.
  8.  
  9. Your code will be placed in the following function:
  10.  
  11.  
  12. function removeLowScoredYYY($string)
  13. {
  14.  
  15. Do some really cool (and efficient) stuff!
  16.  
  17. return some result
  18. }
  19. }
  20.  
  21. // EO Update
  22.  
  23. The following tests are designed to assess both your programming skill level, speed and most importantly logic and thinking approach.
  24.  
  25. Please read all details carefully, and ask for any clarification if needed.
  26. Your results will be inputted into a benchmark testing unit which will compare results against a baseline and other candidates.
  27.  
  28. Your solution should focus on: Speed, speed, speed! Resource consumption, code readability
  29.  
  30. Eliminate Lowest Score for specific criteria (est. time 15 min):
  31.  
  32. ( Task was edited because it’s a lot of candidates and it’s start to be very hard to compare their results in one test. We look at code style and whole approach. )
  33.  
  34. A JSON string with over 100000 elements is passed to your function.
  35. The sting is already SORTED and will contain data as shown in the example below.
  36.  
  37. [{"_id":"4940dgfd95jfsd9","score":15,"user":0,"type":"xxx"},
  38. {"_id":"4940dsdsvhjttt89","score":4,"user":0,"type":"yyy"},
  39. {"_id":"4941dgfdsdfggd9","score":7,"user":0,"type":"yyy"},
  40. {"_id":"4941dfds43rfsff9","score":21,"user":1,"type":"yyy"},
  41. {"_id":"4941dgfd93jfsd0","score":15,"user":1,"type":"xxx"},
  42. {"_id":"4942dgdsadvfd9","score":8,"user":1,"type":"yyy"},
  43. {"_id":"4942dgfdaefcod8","score":4,"user":2,"type":"yyy"},
  44. {"_id":"4942dgfdsarfsd1","score":32,"user":2,"type":"yyy"},
  45. {"_id":"4943dgfddasjfsd5","score":20,"user":2,"type":"xxx"},
  46. {"_id":"4943dasrtqxrfsd9","score":15,"user":3,"type":"xxx"},
  47. {"_id":"4943dgfooorafsd8","score":15,"user":3,"type":"yyy"},
  48. {"_id":"4944dgfddadfsd3","score":15,"user":3,"type":"yyy"},
  49. {"_id":"4944dgfd9dssdc4","score":15,"user":4,"type":"xxx"},
  50. {"_id":"4944dgdacbbrttt9","score":19,"user":4,"type":"yyy"},
  51. {"_id":"4945dgfsaddddd5","score":15,"user":4,"type":"xxx"}]
  52.  
  53. Write a function that would produce the following:
  54.  
  55. Find and DELETE the lowest score for each of row of type ‘yyy’ for each user.
  56. - If All scores are Identical for a user. Keep only one result
  57. - If a user only have one score of type ‘yyy’, DO NOT DELETE score.
  58. return a string formatted as above.
  59.  
  60. Note: Feel free to write several versions of the code, we will keep the optimal result.
  61.  
  62.  
  63.  
  64. Programming Task (15 minutes)
  65.  
  66.  
  67. You have given string which came through inputstream, string can be enormously large, here is short example:
  68.  
  69. [
  70. {
  71. "_id":1364,"name":"Predator","occupations":[
  72. {"title":"exploring","time":54.9,"activityLevel":1},
  73. {"title":"hunting","time":22.4,"activityLevel":2},
  74. {"title":"sleep","time":5.1,"activityLevel":0},
  75. {"title":"nap","time":2.0,"activityLevel":0},
  76. {"title":"slacking","time":10.0,"activityLevel":0},
  77. {"title":"cooking","time":9.0,"activityLevel":1}
  78. ]
  79. },
  80. {
  81. "_id":1365,"name":"Alien","occupations":[
  82. {"title":"sleep","time":5.1,"activityLevel":0},
  83. {"title":"nap","time":2.0,"activityLevel":0},
  84. {"title":"exploring","time":32.1,"activityLevel":1},
  85. {"title":"slacking","time":20.1,"activityLevel":0},
  86. {"title":"cooking","time":0,"activityLevel":1},
  87. {"title":"hunting","time":43.2,"activityLevel":2}
  88. ]
  89. },
  90. {
  91. "_id":1366,"name":"Harry Potter","occupations":[
  92. {"title":"sleep","time":30.0,"activityLevel":0},
  93. {"title":"exploring","time":10.5,"activityLevel":1},
  94. {"title":"slacking","time":30.1,"activityLevel":0},
  95. {"title":"cooking","time":0,"activityLevel":1},
  96. {"title":"dreaming","time":10.0,"activityLevel":0},
  97. {"title":"nap","time":10.0,"activityLevel":0},
  98. {"title":"hunting","time":0,"activityLevel":2}
  99. ]
  100. }
  101. ]
  102.  
  103. Write code using one of the languages: PHP, JS or Java. Your code need to remove occupations activity with the smallest time value and this activity need to be not intensive one.
  104. Please return same string after removing those elements.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement