Open cs6413110 opened 1 week ago
ooh ooh me next(smth for c++) if u can
const ignore = ["the","of","in","from","by","with","and", "or", "for", "to", "at", "a"]; function generateBC(url, separator) { let src = 'HOME'+separator; const paths = url.split('/').slice(1); for (const path of paths) { let parsed = path.split('#')[0].split('?')[0]; if (parsed.length > 30) parsed = parsed.split('-').reduce((a, c) => a+c.split('')[0].toUpperCase(), ''); console.log(parsed); } }
uhm givme 2 periods
oka
i literally have looked at one slide of a like 2 day long lesson plan so surely I got it
https://www.codewars.com/kata/563fbac924106b8bf7000046/train/javascript
const ignore = ['THE','OF','IN','FROM','BY','WITH','AND','OR','FOR','TO','AT','A'];
function generateBC(url, separator) {
let paths = url.replace('https://', '').replace('http://', '').replace('www.', '').split('/').slice(1);
let src = '<a href="/">HOME</a>'+separator;
if (paths.length === 0) return '<span class="active">HOME</span>';
if (paths[paths.length-1].split('#')[0].split('?')[0].split('.')[0] === 'index') paths.pop();
paths = paths.filter(a => a !== '');
if (paths.length === 0) return '<span class="active">HOME</span>';
let pathage = '';
for (const path of paths) {
let last = path === paths[paths.length-1], parsed = path.split('#')[0].split('?')[0].toUpperCase();
if (parsed.length > 30) parsed = parsed.split('-').filter(a => !ignore.includes(a)).reduce((a, c) => a+c.split('')[0], '');
if (last) {
src += '<span class="active">'+parsed.split('.')[0].replace(/-/g, ' ')+'</span>';
} else {
pathage += '/'+path;
src += '<a href="'+pathage+'/">'+parsed.replace(/-/g, ' ')+'</a>'+separator;
}
}
console.log(url, src.toString());
return src.toString();
}
^^^ is for me?
OOH. can I do one of these?
You can go on codewars and find some ig
yaaay thxxxxx
wha-how do i code it? ive never used this
like where
https://www.codewars.com/kata/531489f2bb244a5b9f00077e/
function undoRedo(object) {
let o = {...object};
o.actions = [];
o.unactions = [];
o.get = k => o[k];
o.set = (k, v) => {
o.unactions = o.unactions.filter(a => a[0] !== k);
o.actions.unshift([k, o[k]]);
object[k] = o[k] = v;
}
o.del = k => {
o.actions.unshift([k, o[k]]);
delete o[k];
delete object[k];
}
o.undo = () => {
if (!o.actions.length) return;
o.unactions.unshift([o.actions[0][0], o[o.actions[0][0]]]);
object[o.actions[0][0]] = o[o.actions[0][0]] = o.actions[0][1];
if (o.actions[0][1] === undefined) {
delete o[o.actions[0][0]];
delete object[o.actions[0][0]];
}
o.actions.shift();
}
o.redo = () => {
if (!o.unactions.length) return;
o.actions.unshift([o.unactions[0][0], o.unactions[0][1]]);
object[o.unactions[0][0]] = o[o.unactions[0][0]] = o.unactions[0][1];
if (o.unactions[0][1] === undefined) {
delete o[o.unactions[0][0]];
delete object[o.unactions[0][0]];
}
o.unactions.shift();
}
return o;
}
https://www.codewars.com/kata/540afbe2dc9f615d5e000425/train/javascript
const Sudoku = function(data) {
const series = [];
return {
isValid: () => {
for (let i = 0; i < data.length; i++) {
series.push(data[i]);
series.push(data.reduce((a, c) => a.concat(c[i]), []));
}
for (let n = 0, d = [].concat(...data), s = Math.sqrt(data.length); n < s; n++) {
for (let q = 0; q < s; q++) {
let chunk = [];
for (let m = 0; m < s; m++) {
let j = q*s+n*data.length*s+m*data.length;
chunk = chunk.concat(d.slice(j, j+s));
}
series.push(chunk);
}
}
return !series.some(a => {
let m = a;
for (let i = 0; i < data.length; i++) if (m.indexOf(i+1) !== -1) m.splice(m.indexOf(i+1), 1);
return m.length !== 0;
}) && series.length !== 0;
}
}
}
BREAD 2 HAS ARRISEN. make me collaberator
Reported
Ur joking right?. @BreadSpammer LETS GO. Welcome back
No
Jonas, did u report him?
Yes
https://www.codewars.com/kata/52742f58faf5485cae000b9a/train/javascript function formatDuration (seconds) { if (seconds === 0) return 'now'; let y = 0; let d = 0; let h = 0; let m = 0; let s = 0; if (seconds >= 31536000) { while (seconds >= 31536000) { y++; seconds = seconds-31536000; } } if (seconds >= 86400) { while (seconds >= 86400) { d++; seconds = seconds-86400; } } if (seconds >= 3600) { while (seconds >= 3600) { h++; seconds = seconds-3600; } } if (seconds >= 60) { while (seconds >= 60) { m++; seconds = seconds-60; } } s = seconds; console.log(y,d,h,m,s); let final = ""; if (y > 0) { if (y === 1) final += ("1 year"); if (y > 1) final += (String(y)+" years"); } if (d > 0) { if (y > 0 && (h > 0 || m > 0 || s > 0)) final += (", "); if (y > 0 && h === 0 && m === 0 && s === 0) final += (" and "); if (d === 1) final += ("1 day"); if (d > 1) final += (String(d)+" days"); } if (h > 0) { if ((y > 0 || d > 0) && (m > 0 || s > 0)) final += (", "); if ((y > 0 || d > 0) && (m === 0 && s === 0)) final += (" and "); if (h === 1) final += ("1 hour"); if (h > 1) final += (String(h)+" hours"); } if (m > 0) { if ((y > 0 || d > 0 || h > 0) && s > 0) final += (", "); if ((y > 0 || d > 0 || h > 0) && s === 0) final += (" and "); if (m === 1) final += ("1 minute"); if (m > 1) final += (String(m)+" minutes"); } if (s > 0) { if (y > 0 || d > 0 || h > 0 || m > 0) final += (" and "); if (s === 1) final += ("1 second"); if (s > 1) final += (String(s)+" seconds"); } return final; }
k so like time to assign Aaron to everything. top 1 priority
https://www.codewars.com/kata/534e01fbbb17187c7e0000c6/
const spiralize = n => {
const spiral = [];
for (let i = 0; i < n; i++) spiral.push([]);
for (let layer = 0; layer < Math.ceil(n/2); layer++) {
const length = n-layer*2, key = (layer+1)%2;
for (let i = 0; i < n-2*layer; i++) {
spiral[layer][layer+i] = key;
if (i !== 0 && i !== n-2*layer-1) spiral[layer+i][n-1-layer] = key;
spiral[n-1-layer][layer+i] = key;
if (i !== 0 && (i !== n-2*layer-1 || (i === 1 && key === 1))) spiral[layer+i][layer] = i === 1 ? (key === 1 ? 0 : 1) : key;
}
}
return spiral;
}
I dtapped a ht3
I didn't get 4 kyu :(((
scammed
dtapped
https://www.codewars.com/kata/52742f58faf5485cae000b9a/train/javascript function formatDuration (seconds) { if (seconds === 0) return 'now'; let y = 0; let d = 0; let h = 0; let m = 0; let s = 0; if (seconds >= 31536000) { while (seconds >= 31536000) { y++; seconds = seconds-31536000; } } if (seconds >= 86400) { while (seconds >= 86400) { d++; seconds = seconds-86400; } } if (seconds >= 3600) { while (seconds >= 3600) { h++; seconds = seconds-3600; } } if (seconds >= 60) { while (seconds >= 60) { m++; seconds = seconds-60; } } s = seconds; console.log(y,d,h,m,s); let final = ""; if (y > 0) { if (y === 1) final += ("1 year"); if (y > 1) final += (String(y)+" years"); } if (d > 0) { if (y > 0 && (h > 0 || m > 0 || s > 0)) final += (", "); if (y > 0 && h === 0 && m === 0 && s === 0) final += (" and "); if (d === 1) final += ("1 day"); if (d > 1) final += (String(d)+" days"); } if (h > 0) { if ((y > 0 || d > 0) && (m > 0 || s > 0)) final += (", "); if ((y > 0 || d > 0) && (m === 0 && s === 0)) final += (" and "); if (h === 1) final += ("1 hour"); if (h > 1) final += (String(h)+" hours"); } if (m > 0) { if ((y > 0 || d > 0 || h > 0) && s > 0) final += (", "); if ((y > 0 || d > 0 || h > 0) && s === 0) final += (" and "); if (m === 1) final += ("1 minute"); if (m > 1) final += (String(m)+" minutes"); } if (s > 0) { if (y > 0 || d > 0 || h > 0 || m > 0) final += (" and "); if (s === 1) final += ("1 second"); if (s > 1) final += (String(s)+" seconds"); } return final; }
AHHHHHH MY EYES
Literally just do:
const formatDuration = t => {
if (!t) return 'now';
let y, d, h, m, s, msg = '';
let time = [t%60, Math.floor(t/60)%60, Math.floor(t/(60*60))%24, Math.floor(t/(60*60*24))%365, Math.floor(t/(60*60*24*365))];
for (let i = 4; i >= 0; i--) {
if (time[i] && msg.length > 0 && time.slice(0, i).join('').replace(/0/g, '').length === 0) msg = msg.slice(0, -2)+' and ';
if (time[i]) msg += time[i]+' '+['second', 'minute', 'hour', 'day', 'year'][i]+(time[i] > 1 ? 's' : '')+', ';
}
return msg.slice(0, -2);
}
ye like cmon man its simple
shut lk. i'd like to see u try a kyu 6 lAFF
i'd like to see u try english
wahtsa n englamasish ???
const alpha = 'abcdefghijklmnopqrstuvwxyz'.split(''), alphabetPosition = s => s.split(' ').reduce((a, c) => a.concat(c.toLowerCase().split('').filter(a => alpha.includes(a)).reduce((b, d) => b.concat(alpha.indexOf(d)+1), []).join(' ')), []).filter(a => a.length).join(' ');
https://www.codewars.com/kata/5cba04533e6dce000eaf6126/train/javascript - Math practice (possible with only 18 characters)
https://www.codewars.com/kata/57cf50a7eca2603de0000090/train/javascript - String and array practice
https://www.codewars.com/kata/51e0007c1f9378fa810002a9/train/javascript - If statements