jump
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
const canJump = (arr, pos = 0) => {
|
||||
if (pos >= arr.length) return true;
|
||||
if (pos === arr.length - 1) return false;
|
||||
for (let i = arr[pos]; i > 0; --i) {
|
||||
if (canJump(arr, pos + i)) return true;
|
||||
}
|
||||
|
||||
16
reversing-fun/index.bf
Normal file
16
reversing-fun/index.bf
Normal file
@@ -0,0 +1,16 @@
|
||||
>
|
||||
,[>,]
|
||||
|
||||
<[->+>+<<]> >[-<<+>>]< copy here from left cell
|
||||
|
||||
[[-] make loop if copied is nonzero:
|
||||
<[
|
||||
.[-] print & remove right
|
||||
<[<] move left edge
|
||||
>[.[-]] print & remove left if exist
|
||||
>[>] move right edge
|
||||
]
|
||||
<[->+>+<<]> >[-<<+>>]< copy here from left cell
|
||||
]
|
||||
|
||||
<[<]
|
||||
12
reversing-fun/index.js
Normal file
12
reversing-fun/index.js
Normal file
@@ -0,0 +1,12 @@
|
||||
// https://www.codewars.com/kata/reversing-fun/javascript
|
||||
|
||||
function flipNumber(n) {
|
||||
let cnt = 0;
|
||||
const arr = [...n];
|
||||
const res = [];
|
||||
while (1) {
|
||||
let c = arr[++cnt % 2 ? 'pop' : 'shift']();
|
||||
if (!c) return res.join``;
|
||||
res.push(c);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user