Vassil_Iliev

GG

Feb 18th, 2022
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. // NAI DOBROTO OT JUDGE V TELERIK
  3. const getGets = arr => {
  4.     let index = 0
  5.    
  6.     return () => {
  7.       const toReturn = arr[index]
  8.       index += 1
  9.       return toReturn
  10.     }
  11.   }
  12.   // this is the test
  13.    
  14.   const test = ['5,3,2,1','2']
  15.   const gets = this.gets || getGets(test)
  16.   const print = this.print || console.log
  17.    
  18.   let list1 = gets().split(',').map(Number);
  19.   let arr = [];
  20.   let n = gets();
  21.  
  22.   for (let i = 0; i < list1.length; i++) {
  23.       arr.push(list1[i]);
  24.   }
  25.  
  26.   function rotate(nums, n) {
  27.     n = n % nums.length;
  28.     return nums.slice(n).concat(nums.slice(0, n))
  29.   }
  30.    arr = rotate(arr, n);
  31.  
  32.    let str = "";
  33.  
  34.  for (let i = 0; i < arr.length; i++) {
  35.      if(i != arr.length - 1){
  36.         str += arr[i] + ",";
  37.      }
  38.      else{
  39.          str += arr[i];
  40.      }
  41.  }
  42.  print(str);
  43.  
  44. // MOQ KOD
  45.  
  46. let string = gets().split(',');
  47. let N = +gets();
  48.  
  49. for (let i = 0; i < N; i++) {
  50.     string.push(string[i])
  51. }
  52. string.splice(0, N);
  53. print(string);
Advertisement
Add Comment
Please, Sign In to add comment