This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fibonacci = (n) => { | |
if (n <= 2) { | |
return Number(!!n); | |
} else { | |
return fibonacci(n - 1) + fibonacci(n - 2); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Remainder of the division (Остаток от деления) | |
const b = (num1, num2) => { | |
const convertValues = (num1, num2) => { | |
let isNegative = false; | |
if (num1 < 0 && num2 < 0) { | |
num1 = -num1; | |
num2 = -num2; | |
} else if (num1 < 0) { | |
num1 = -num1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var BitArray = require('node-bitarray'); | |
var text = BitArray.fromBinary('10110110').toJSON().reverse(); | |
var key = BitArray.fromBinary('1111010110').toJSON().reverse(); | |
var extendTransposition = [1, 4, 3, 4, 2, 1, 3, 2]; | |
var transposition = [3, 4, 2, 1]; | |
var s1 = [[0, 1, 2, 1], [2, 3, 0, 3], [2, 1, 2, 1], [3, 0, 3, 0]]; | |
var s2 = [[0, 2, 0 ,1], [0, 1, 3, 2], [3, 2, 3, 1], [0, 2, 3, 1]]; | |
var p_pryamoi = [3, 5, 2, 7, 4, 10, 1, 9, 8, 6] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pretty(input) { | |
return JSON.stringify(input, null, '\t'); | |
} | |
function pp(input) { | |
console.log(pretty(input)); | |
} | |
function output(input) { | |
$('.output').append('<p>' + input + '</p>'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body> | |
<div class="middle"> | |
<form class="form"> | |
<div class="form-group"> | |
<div style="text-align: center"> | |
<b><label>Заполните следующие поля</label></b> | |
</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Необходимо написать функция, которая работала бы в следующем случае: | |
var x = add(1)(5)(7)(11)(3) ... | |
console.log(x+10); | |
Должно вывести: 1+5+7+11+3+10 = 37 | |
Кол-во скобок в функции add может быть произвольным. | |
*/ | |
add.result = 0; | |
function add(x) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re,tarfile | |
lxc = re.compile("sys/fs/cgroup/cpuacct/lxc/.*/cpuacct.usage$") | |
tar_archive = tarfile.open("input.tgz", "r:gz") | |
lxc_time = 0 | |
lxc_name = '' | |
for tarname in tar_archive: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
fr = open('access.log','r') | |
ip = re.compile('^([0-9a-fA-F]?[0-9a-fA-F]?[0-9a-fA-F]?[0-9a-fA-F]?(:| )){1,8}') | |
count = 0 | |
for line in fr: | |
if ip.search(line) != None: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re,tarfile | |
runlevel = re.compile("env DEFAULT_RUNLEVEL=\d*$") | |
initdefault = re.compile(".*:initdefault:.*$") | |
# Open archive | |
tar_archive = tarfile.open("etc.tar.gz", "r:gz") | |
# Extract necessary file | |
file = tar_archive.extractfile("etc/init/rc-sysinit.conf") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
error = re.compile("<(kernel|initrd|cmdline)>.*$") | |
boot = re.compile("<boot dev='hd'/>.*$") | |
fr = open('input.xml','r') | |
fw = open('output.xml','w') | |
not_change = True |
NewerOlder