Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
24
Task/Nth/JavaScript/nth-1.js
Normal file
24
Task/Nth/JavaScript/nth-1.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
console.log(function () {
|
||||
|
||||
var lstSuffix = 'th st nd rd th th th th th th'.split(' '),
|
||||
|
||||
fnOrdinalForm = function (n) {
|
||||
return n.toString() + (
|
||||
11 <= n % 100 && 13 >= n % 100 ?
|
||||
"th" : lstSuffix[n % 10]
|
||||
);
|
||||
},
|
||||
|
||||
range = function (m, n) {
|
||||
return Array.apply(
|
||||
null, Array(n - m + 1)
|
||||
).map(function (x, i) {
|
||||
return m + i;
|
||||
});
|
||||
};
|
||||
|
||||
return [[0, 25], [250, 265], [1000, 1025]].map(function (tpl) {
|
||||
return range.apply(null, tpl).map(fnOrdinalForm).join(' ');
|
||||
}).join('\n\n');
|
||||
|
||||
}());
|
||||
5
Task/Nth/JavaScript/nth-2.js
Normal file
5
Task/Nth/JavaScript/nth-2.js
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
0th 1st 2nd 3rd 4th 5th 6th 7th 8th 9th 10th 11th 12th 13th 14th 15th 16th 17th 18th 19th 20th 21st 22nd 23rd 24th 25th
|
||||
|
||||
250th 251st 252nd 253rd 254th 255th 256th 257th 258th 259th 260th 261st 262nd 263rd 264th 265th
|
||||
|
||||
1000th 1001st 1002nd 1003rd 1004th 1005th 1006th 1007th 1008th 1009th 1010th 1011th 1012th 1013th 1014th 1015th 1016th 1017th 1018th 1019th 1020th 1021st 1022nd 1023rd 1024th 1025th
|
||||
26
Task/Nth/JavaScript/nth-3.js
Normal file
26
Task/Nth/JavaScript/nth-3.js
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
(function (lstTestRanges) {
|
||||
'use strict'
|
||||
|
||||
let lstSuffix = 'th st nd rd th th th th th th'.split(' '),
|
||||
|
||||
// ordinalString :: Int -> String
|
||||
ordinalString = n =>
|
||||
n.toString() + (
|
||||
11 <= n % 100 && 13 >= n % 100 ?
|
||||
"th" : lstSuffix[n % 10]
|
||||
),
|
||||
|
||||
// range :: Int -> Int -> [Int]
|
||||
range = (m, n) =>
|
||||
Array.from({
|
||||
length: (n - m) + 1
|
||||
}, (_, i) => m + i);
|
||||
|
||||
|
||||
return lstTestRanges
|
||||
.map(tpl => range
|
||||
.apply(null, tpl)
|
||||
.map(ordinalString)
|
||||
);
|
||||
|
||||
})([[0, 25], [250, 265], [1000, 1025]]);
|
||||
Loading…
Add table
Add a link
Reference in a new issue