http://www.codewars.com/kata/52b7ed099cdc285c300001cd/train/javascript
๊ฒน์น๋(overlap) ์ธํฐ๋ฒ์ ํฉ์น๊ณ ๋ชจ๋ ์ธํฐ๋ฒ์ ๊ธธ์ด์ ํฉ์ ์ถ๋ ฅ
sumIntervals( [
[1,2],
[6, 10],
[11, 15]
] ); //=> returns 9
http://www.codewars.com/kata/52b7ed099cdc285c300001cd/train/javascript
๊ฒน์น๋(overlap) ์ธํฐ๋ฒ์ ํฉ์น๊ณ ๋ชจ๋ ์ธํฐ๋ฒ์ ๊ธธ์ด์ ํฉ์ ์ถ๋ ฅ
sumIntervals( [
[1,2],
[6, 10],
[11, 15]
] ); //=> returns 9
message: my secret code i want to secure
key: passwordpasswordpasswordpasswor
var alphabet = 'abcdefghijklmnopqrstuvwxyz';
var key = 'password';
// creates a cipher helper with each letter substituted
๊ฒ๋ ๊ฐ๋จํ ์์ค์ ์ ๊ท์๋ฐ์ ๋ชป์จ์ ์ด๋ ๊ฒ ํ๋๋ฐ;;;
function isValidIP(str) {
var r = /^([\d]{1,})\.([\d]{1,})\.([\d]{1,})\.([\d]{1,})$/g;
var result = r.exec(str);
if (result&&result.length==5)
return result.slice(1).every(s=>(s.length==1?true:s[0]!='0') && 0<=+s && +s<=255);
return false;
}
http://www.codewars.com/kata/529bf0e9bdf7657179000008/train/javascript;
์ฒ์์๋ ํฉ์ด 45๊ฐ ๋์ค๋๊น ํฉ์ ๋ชจ๋ ๊ณ์ฐํด์ ํด๋ณผ๊น...
ํ๋ค๊ฐ ๊ทธ๋ดํ์ ์์ด ๊ฐ ๋ก์ฐ/์ปฌ๋ผ/3x3๋ฐ์ค์ 1~9๊ฐ ๋ชจ๋ ๋ค์ด์์ผ๋ฉด ๋๊ฒ ๋ค ํด์ ์ด๋ ๊ฒ ํ๋๋ฐ;;
๊ทธ๋ฅ ์ซ์๊ฐ ๋ชจ๋ ์๋ค๋ฅผ ์ฒดํฌํ๋๊ฒ ๋์๊ฑฐ ๊ฐ์์ ๊ทธ๋ฅ ํด๋ด;;
var hasAll = (arr) => arr.reduce((a,b)=>a+b)==45
function undoRedo(object) {
function History(type, key, oldValue, newValue) {
this.type = type;
this.key = key;
this.oldValue = oldValue;
this.newValue = newValue;
(์์)[https://www.youtube.com/watch?v=W23s6kYJbrA]
ํฌ๋กฌ ์ฝ์์์๋ง ํด๋ณด๋๋ผ(๊ท์ฐฎ์์) tdd๋ฅผ ๋ชปํ๋น....
ํ์ค์ผ ์ข ๊ณต๋ถํด์ ํด๋ณด์. recursive
, map
, filter
๊ฐ ์ฃผ ๋ก์ง์ด๋ ์ฝ๊ฒ(๋ ์๋๊ณ ) ๊ฐ๋ฅํ ๊ฑฐ ๊ฐ๋ค
0 4 8
1 3 5 7 9
extern crate rand; // Cargo.toml ์ ์ ์ํ ๋ํฌ๋์๋ฅผ ๊ฐ์ ธ์ค๊ธฐ ์ํด extern crate ํค์๋๋ก ๊ฐ์ ธ์ค๊ธฐ | |
use std::io; // ์ํฌํธ | |
use std::cmp::Ordering; | |
use rand::Rng; | |
fn main() { | |
println!("Guess the number"); // ๊ธฐ๋ณธ์ ์ผ๋ก ํจ์ ํธ์ถ์ ๊ทธ๋ฅ ๋ ธ๋งํ๊ฒ ํธ์ถ, ๋๋ํ๋ ๋งคํฌ๋ก๋ฅผ ํธ์ถ | |
let secret_number = rand::thread_rng().gen_range(1, 101); // ์์์ ๋ฐ์ธ๋ฉ. |
http://www.codewars.com/kata/5402724fd39b43c075000116/train/javascript | |
```javascript | |
function fill(n, x) { | |
var a = []; | |
for(var i=0;i<n;i++) { | |
if (typeof x === 'function') a[i] = x(); | |
else if(x instanceof Array) a[i] = x.slice(0); | |
else a[i] = x; | |
} |
`gcc -E -x c source.js | sed '/^#/d' > result.js``