Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let input = ["1,2,3", "2"];
- let print = this.print || console.log;
- let gets =
- this.gets ||
- (
- (arr, index) => () =>
- arr[index++]
- )(input, 0);
- let list = gets().split(",").map(Number);
- let N = +gets();
- let curr = [];
- let k = 0;
- let sum = "";
- if (N > list.length) {
- N = N % list.length; // Corrected line: Adjust N if it's larger than the length of the list
- }
- for (let i = N; i < list.length; i++) {
- curr[k] = list[i];
- k++;
- }
- for (let i = 0; i < N; i++) {
- curr[k] = list[i];
- k++;
- }
- for (let j = 0; j < curr.length; j++) {
- sum = `${sum}${curr[j]},`;
- }
- print(sum.substring(0, sum.length - 1));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement