-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay20.js
More file actions
62 lines (54 loc) · 1.2 KB
/
Day20.js
File metadata and controls
62 lines (54 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//Digit Sum Sort!
// function digitSum(arr)
// {
// let tempArr = [...arr];
// // console.log(tempArr);
// let dSArray = [];
// for(let i=0; i<tempArr.length; i++)
// {
// let temp = 0;
// while(tempArr[i]>0)
// {
// temp+=tempArr[i]%10;
// tempArr[i] = parseInt(tempArr[i]/10);
// }
// dSArray.push(temp);
// }
// // console.log(arr);
// return dSArray;
// }
// function digitSumSort(arr,N)
// {
// for(let i=0; i<(N-1); i++)
// {
// for(let j=0; j<(N-i-1); j++)
// {
// if(arr[j]>arr[j+1])
// {
// let temp2 = arr[j];
// arr[j] = arr[j+1];
// arr[j+1] = temp2;
// }
// }
// }
// // console.log(arr);
// let dSArray = digitSum(arr);
// // console.log(arr);
// for(let i=0; i<(N-1); i++)
// {
// for(let j=0; j<(N-i-1); j++)
// {
// if(dSArray[j]>dSArray[j+1])
// {
// let temp1 = dSArray[j];
// dSArray[j] = dSArray[j+1];
// dSArray[j+1] = temp1;
// let temp2 = arr[j];
// arr[j] = arr[j+1];
// arr[j+1] = temp2;
// }
// }
// }
// console.log(arr.join(' '));
// // console.log(dSArray);
// }