Skip to content

Commit aba22ee

Browse files
blackeningremo5000
authored andcommitted
Mock pe2018 s1 (#409)
* Mock PE library. * take_array, drop_array for pe_library. * assert_compiled, with q1 and q2 solutions. * Obfuscated the compiled solution. Check 01s repo for source. * Bump version
1 parent a8deafc commit aba22ee

File tree

4 files changed

+61
-1
lines changed

4 files changed

+61
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "cadet-frontend",
4-
"version": "1.0.17",
4+
"version": "1.0.18",
55
"scripts-info": {
66
"format": "Format source code",
77
"start": "Start the Webpack development server",
894 KB
Binary file not shown.

public/externalLibs/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ function loadAllLibs() {
3636
'/externalLibs/tree.js',
3737
// streams
3838
'/externalLibs/streams/stream.js',
39+
'/externalLibs/pe_library.js',
40+
'/externalLibs/assert_compiled.js'
3941
];
4042

4143
for (var i = 0; i < files.length; i++) {

public/externalLibs/pe_library.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
function is_array(x) {
2+
if (Array.isArray === undefined) {
3+
return x instanceof Array;
4+
} else {
5+
return Array.isArray(x);
6+
}
7+
}
8+
9+
function map_array(f, ls){
10+
let res = [];
11+
let len = ls.length;
12+
for(let i = 0; i < len; i++){
13+
res.push(f(ls[i]));
14+
}
15+
return res;
16+
}
17+
function accumulate_array(op, init, ls){
18+
for(let i = 0; i < ls.length; i++){
19+
init = op(ls[i], init);
20+
}
21+
return init;
22+
}
23+
24+
function filter_array(f, ls){
25+
let res = [];
26+
for(let i = 0; i < ls.length; i++){
27+
if(f(ls[i])){
28+
res.push(ls[i]);
29+
}
30+
}
31+
return res;
32+
}
33+
34+
function enum_array(a,b){
35+
let res = [];
36+
for(let i = a; a <= b; a++){
37+
res.push(a);
38+
}
39+
return res;
40+
}
41+
42+
function take_array(xs, n){
43+
let res = [];
44+
let arr_len = xs.length;
45+
for(let i = 0; i < n; i = i + 1){
46+
res[i] = xs[i];
47+
}
48+
return res;
49+
}
50+
51+
function drop_array(xs, n){
52+
let res = [];
53+
let arr_len = xs.length;
54+
for(let i = n; i < arr_len; i = i + 1){
55+
res.push(xs[i]);
56+
}
57+
return res;
58+
}

0 commit comments

Comments
 (0)