fix add diplodocus writeup
Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
This commit is contained in:
1 parent
34be6a4a96
commit
3e9261a7c8
22 files changed
+1112
No files matched your search
@@ -0,0 +1,35 @@
|
||||
case 0:
|
||||
{
|
||||
int32_t count = 0;
|
||||
for (int i = 0; i <= 0xb; ++i) // Refactorized SIMD instruction as loop
|
||||
count += pop_count(context.visited[i]);
|
||||
|
||||
int32_t err = count != 0x90;
|
||||
err = err | context.err;
|
||||
context.err = err; // Set error
|
||||
|
||||
int128_t third_board_1 = context.third_board; // Trying to clean up SIMD
|
||||
int128_t third_board_2 = *(((uint128_t *)&context.third_board) + 1);
|
||||
int128_t third_board_3 = *(((uint128_t *)&context.third_board) + 2);
|
||||
int128_t zmm0 = ((third_board_1 & third_board_2) & third_board_3);
|
||||
zmm0 = (zmm0 & _mm_bsrli_si128(zmm0, 8)); // More SIMD magic
|
||||
zmm0 = (zmm0 & _mm_bsrli_si128(zmm0, 4));
|
||||
|
||||
int32_t all_set = (zmm0 & 0xfff) != 0xfff;// Check that context.third_board
|
||||
err = all_set | err; // Is all set to 1
|
||||
context.err = err;
|
||||
|
||||
uint32_t flag = 1; // Set error flag
|
||||
if (context.bit_queue == 0) // Check that we emptied the bit queue
|
||||
{
|
||||
int32_t x = 0;
|
||||
for (int i = 0; i <= 0xb; ++i) // SIMD refactor
|
||||
x ^= context.board[i];
|
||||
flag = x;
|
||||
}
|
||||
|
||||
res = ((uint64_t)(err | flag));
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
case 1:
|
||||
{
|
||||
context.__offset0xa0_d = ((context.__offset0xa0_d + 1) & 3);
|
||||
break;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
case 2:
|
||||
{
|
||||
enum moves move = context.move; //__offset0xa0
|
||||
int32_t j = context.j;
|
||||
int32_t i = context.i;
|
||||
if (move == 0)
|
||||
{
|
||||
j = (j + 1);
|
||||
}
|
||||
else if (move == 1)
|
||||
{
|
||||
i = (i - 1);
|
||||
}
|
||||
else if (move == 2)
|
||||
{
|
||||
j = (j - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
op = op == 3;
|
||||
i = (i + ((uint32_t)op));
|
||||
}
|
||||
int32_t row;
|
||||
if ((j <= 0xb && i <= 0xb))
|
||||
{
|
||||
row = context.visited[i];
|
||||
}
|
||||
if (((j > 0xb || (j <= 0xb && i > 0xb)) || ((j <= 0xb && i <= 0xb) && (TEST_BITD(row, j)))))
|
||||
{
|
||||
context.err = (context.err | 1);
|
||||
}
|
||||
if (((j <= 0xb && i <= 0xb) && (!(TEST_BITD(row, j)))))
|
||||
{
|
||||
context.i = i;
|
||||
context.j = j;
|
||||
context.visited[i] = (row | ((int32_t)(1 << j))); // set bit
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
case 3:
|
||||
{
|
||||
int32_t bits_queue = context.bits_queue;
|
||||
int64_t i = ((int64_t)context.i);
|
||||
int32_t bits_cleared;
|
||||
bits_cleared = bits_queue == 0;
|
||||
int32_t new_flags = (bits_cleared | context.err);
|
||||
uint64_t row = ((uint64_t)(((bits_queue & 1) << ((int8_t)context.j)) | context.board[i])); // set bit
|
||||
context.bits_queue = (bits_queue >> 1); // pop bit queue
|
||||
context.board[i] = row; // save new board with new bit
|
||||
int32_t count;
|
||||
count = pop_count(row);
|
||||
count = count > 2;
|
||||
context.err = (new_flags | ((uint32_t)count));
|
||||
break;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
case 3:
|
||||
{
|
||||
int32_t bits_queue = context.bits_queue; //offset0x8_q
|
||||
int64_t i = ((int64_t)context.i);
|
||||
int32_t bits_cleared;
|
||||
bits_cleared = bits_queue == 0;
|
||||
int32_t new_flags = (bits_cleared | context.err);
|
||||
uint64_t row = ((uint64_t)(((bits_queue & 1) << ((int8_t)context.j)) | context.board[i])); // set bit
|
||||
context.bits_queue = (bits_queue >> 1); // pop bit queue
|
||||
context.board[i] = row; // save new board with new bit
|
||||
int32_t sub_res;
|
||||
sub_res = sub_1c60(row);
|
||||
sub_res = sub_res > 2;
|
||||
context.err = (new_flags | ((uint32_t)sub_res));
|
||||
break;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
case 4:
|
||||
{
|
||||
int32_t j = ((int32_t)cursor[1]);
|
||||
int64_t i = ((int64_t)cursor[2]);
|
||||
|
||||
int32_t bits_set;
|
||||
bits_set = context.bits_queue != 0;
|
||||
context.err = (context.err | bits_set);
|
||||
|
||||
next = &cursor[3];
|
||||
|
||||
int32_t bit = sub_1570(j, i, context);
|
||||
context.third_board[i] = (context.third_board[i] | (bit << j));
|
||||
break;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
case 4:
|
||||
{
|
||||
int32_t j = ((int32_t)cursor[1]);
|
||||
int64_t i = ((int64_t)cursor[2]);
|
||||
|
||||
int32_t bits_set;
|
||||
bits_set = context.bits_queue != 0;
|
||||
context.err = (context.err | bits_set);
|
||||
|
||||
next = &cursor[3];
|
||||
|
||||
int32_t bit = sub_1570(j, i, context);
|
||||
context.third_board[i] = (context.third_board[i] | (bit << j));
|
||||
break;
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
uint64_t check(char* input, int64_t len)
|
||||
{
|
||||
int64_t i = 0x14;
|
||||
char* cursor = input;
|
||||
void* end = &cursor[len];
|
||||
void* fsbase;
|
||||
int64_t rax = *(int64_t*)((char*)fsbase + 0x28);
|
||||
struct context context;
|
||||
int64_t* context_ptr = &context;
|
||||
for (; i != 0; i = (i - 1))
|
||||
{
|
||||
*(int64_t*)context_ptr = 0;
|
||||
context_ptr = &context_ptr[1];
|
||||
}
|
||||
// bits = 0x00ffffff
|
||||
// visited[0] = 1
|
||||
context.bits_queue = 0x100ffffff;
|
||||
*(int32_t*)context_ptr = 0;
|
||||
uint64_t res;
|
||||
if (cursor < end)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
char* next = &cursor[1];
|
||||
if (*(int8_t*)cursor > 4)
|
||||
{
|
||||
res = ((uint64_t)(context.err | 1));
|
||||
break;
|
||||
}
|
||||
int32_t i;
|
||||
uint128_t zmm0;
|
||||
int128_t arr3_5-9;
|
||||
int128_t arr3_1-4;
|
||||
switch (*(int8_t*)cursor)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
int128_t arr1_1-5 = context.visited[1];
|
||||
arr3_1-4 = context.check_board[1];
|
||||
int128_t arr1_5-9 = context.visited[5];
|
||||
int128_t arr1_9-13 = context.visited[9];
|
||||
arr3_5-9 = context.check_board[5];
|
||||
int128_t arr2_1-5 = context.board[1];
|
||||
int32_t r12 = context.visited[5];
|
||||
int32_t rbp_1 = context.visited[9];
|
||||
int128_t arr2_5-9 = context.board[5];
|
||||
int128_t arr2_9-13 = context.board[9];
|
||||
int32_t var_38_1 = context.move;
|
||||
int32_t err1 = (pop_count(((uint64_t)*(int32_t*)((char*)context.j)[0xc])) + pop_count(((uint64_t)context.visited[1])));
|
||||
int32_t err2 = ((err1 + pop_count(((uint64_t)*(int32_t*)((char*)arr1_1-5)[4]))) + pop_count(((uint64_t)*(int32_t*)((char*)arr1_1-5)[8])));
|
||||
int32_t err3 = ((err2 + pop_count(((uint64_t)*(int32_t*)((char*)arr1_1-5)[0xc]))) + pop_count(((uint64_t)r12)));
|
||||
int32_t err4 = ((err3 + pop_count(((uint64_t)*(int32_t*)((char*)arr1_5-9)[4]))) + pop_count(((uint64_t)*(int32_t*)((char*)arr1_5-9)[8])));
|
||||
int32_t err5 = ((err4 + pop_count(((uint64_t)*(int32_t*)((char*)arr1_5-9)[0xc]))) + pop_count(((uint64_t)rbp_1)));
|
||||
int32_t bits = context.bits_queue;
|
||||
int32_t err6;
|
||||
err6 = ((err5 + pop_count(((uint64_t)*(int32_t*)((char*)arr1_9-13)[4]))) + pop_count(((uint64_t)*(int32_t*)((char*)arr1_9-13)[8]))) != 0x90;
|
||||
int32_t err = (err6 | context.err);
|
||||
context.err = err;
|
||||
int128_t var_48_1 = context.check_board[9];
|
||||
zmm0 = ((arr2_9-13 & arr3_1-4) & arr3_5-9);
|
||||
zmm0 = (zmm0 & _mm_bsrli_si128(zmm0, 8));
|
||||
zmm0 = (zmm0 & _mm_bsrli_si128(zmm0, 4));
|
||||
int32_t rax_23;
|
||||
rax_23 = (zmm0 & 0xfff) != 0xfff;
|
||||
int32_t err = (((uint32_t)rax_23) | err);
|
||||
uint32_t flag = 1;
|
||||
context.err = err;
|
||||
if (bits == 0)
|
||||
{
|
||||
int128_t var_48_2 = context.check_board[9];
|
||||
int32_t flag;
|
||||
flag = *(int32_t*)((char*)arr2_9-13)[8] != ((((((((((*(int32_t*)((char*)arr1_9-13)[0xc] ^ arr2_1-5) ^ *(int32_t*)((char*)arr2_1-5)[4]) ^ *(int32_t*)((char*)arr2_1-5)[8]) ^ *(int32_t*)((char*)arr2_1-5)[0xc]) ^ arr2_5-9) ^ *(int32_t*)((char*)arr2_5-9)[4]) ^ *(int32_t*)((char*)arr2_5-9)[8]) ^ *(int32_t*)((char*)arr2_5-9)[0xc]) ^ arr2_9-13) ^ *(int32_t*)((char*)arr2_9-13)[4]);
|
||||
flag = ((uint32_t)flag);
|
||||
}
|
||||
res = ((uint64_t)(err | flag));
|
||||
break;
|
||||
break;
|
||||
}
|
||||
case 1: // cycle through instructions
|
||||
{
|
||||
cursor = next;
|
||||
context.move = ((context.move + 1) & 3);
|
||||
break;
|
||||
}
|
||||
// change coordinates and set nth bit of ith element of arr
|
||||
// error if bit is already set
|
||||
case 2:
|
||||
{
|
||||
enum moves op = context.move;
|
||||
int32_t j = context.j;
|
||||
i = context.i;
|
||||
if (op == 0)
|
||||
{
|
||||
j = (j + 1);
|
||||
}
|
||||
else if (op == 1)
|
||||
{
|
||||
i = (i - 1);
|
||||
}
|
||||
else if (op == 2)
|
||||
{
|
||||
j = (j - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
op = op == 3;
|
||||
i = (i + ((uint32_t)op));
|
||||
}
|
||||
int32_t row; // get element
|
||||
int64_t i_cpy;
|
||||
if ((j <= 0xb && i <= 0xb))
|
||||
{
|
||||
i_cpy = ((int64_t)i);
|
||||
row = context.visited[i_cpy];
|
||||
}
|
||||
if (((j > 0xb || (j <= 0xb && i > 0xb)) || ((j <= 0xb && i <= 0xb) && (TEST_BITD(row, j)))))
|
||||
{
|
||||
context.err = (context.err | 1);
|
||||
cursor = next;
|
||||
}
|
||||
if (((j <= 0xb && i <= 0xb) && (!(TEST_BITD(row, j)))))
|
||||
{
|
||||
cursor = next;
|
||||
context.j = _mm_unpacklo_epi32(j, i); // store new indexes
|
||||
context.visited[i_cpy] = (row | ((int32_t)(1 << j))); // set bit
|
||||
}
|
||||
break;
|
||||
}
|
||||
// set the nth bit of the ith element of arr2 if lsb of bits is set
|
||||
// error if bits is cleared or if bitwise_check(new_element) > 2
|
||||
case 3:
|
||||
{
|
||||
int32_t bits_queue = context.bits_queue;
|
||||
int64_t i = ((int64_t)context.i);
|
||||
int32_t bits_cleared;
|
||||
bits_cleared = bits_queue == 0;
|
||||
int32_t new_flags = (bits_cleared | context.err);
|
||||
uint64_t row = ((uint64_t)(((bits_queue & 1) << ((int8_t)context.j)) | context.board[i])); // set bit
|
||||
context.bits_queue = (bits_queue >> 1); // rshift bits
|
||||
context.board[i] = row; // save new element of arr2
|
||||
int32_t sub_res;
|
||||
sub_res = pop_count(row);
|
||||
sub_res = sub_res > 2;
|
||||
context.err = (new_flags | ((uint32_t)sub_res));
|
||||
cursor = next;
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
int32_t j = ((int32_t)cursor[1]);
|
||||
int64_t i = ((int64_t)cursor[2]);
|
||||
int32_t bits_set;
|
||||
bits_set = context.bits_queue != 0;
|
||||
context.err = (context.err | bits_set);
|
||||
cursor = &cursor[3];
|
||||
int32_t var_198_1 = context.move;
|
||||
int32_t rax_26;
|
||||
uint128_t zmm1;
|
||||
int128_t zmm3;
|
||||
int128_t zmm4;
|
||||
int128_t zmm5;
|
||||
int128_t zmm6;
|
||||
rax_26 = sub_1570(j, i, context.j, context.visited[1], context.visited[5], context.visited[9], context.board[1], context.board[5], context.board[9], context.check_board[1], context.check_board[5], context.check_board[9], i);
|
||||
context.check_board[i] = (context.check_board[i] | (rax_26 << j));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((((*(int8_t*)cursor == 3 || *(int8_t*)cursor == 1) || *(int8_t*)cursor == 4) || *(int8_t*)cursor == 2))
|
||||
{
|
||||
if (cursor >= end)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((cursor >= end || (cursor < end && *(int8_t*)cursor <= 4)))
|
||||
{
|
||||
res = 1;
|
||||
}
|
||||
*(int64_t*)((char*)fsbase + 0x28);
|
||||
if (rax != *(int64_t*)((char*)fsbase + 0x28))
|
||||
{
|
||||
__stack_chk_fail();
|
||||
/* no return */
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
uint64_t sub_1570(int32_t j, int32_t i, struct context context)
|
||||
{
|
||||
int32_t res = 0;
|
||||
int32_t *board = context.board;;
|
||||
int32_t res_flag = 0;
|
||||
if ((j <= 0xb && i <= 0xb))
|
||||
{
|
||||
int32_t r12_1 = (i + 0x79); // ignore this
|
||||
int32_t y = -0xb; // First increment
|
||||
int32_t rbp_1 = (j + 0xb); // ignore this too
|
||||
while (true)
|
||||
{
|
||||
int32_t y_cpy = (y + 1);
|
||||
if (y != 0)
|
||||
{
|
||||
int32_t r8 = r12_1; // ignore for now
|
||||
int32_t x = -0xb; // Second increment
|
||||
int32_t neg = (y >> 0x1f); // Probably interesting
|
||||
int32_t r11_2 = ((y_cpy * -0xb) + rbp_1); // but I can't seem
|
||||
int32_t y_cpy_cpy = ((neg ^ y) - osef); // to care enough
|
||||
while (true)
|
||||
{
|
||||
if (x != 0)
|
||||
{
|
||||
int32_t neg = (x >> 0x1f); // Abs value again or
|
||||
int32_t x_cpy = ((neg ^ x) - osef); // something
|
||||
int32_t y_cpy_cpy_cpy = y_cpy_cpy;
|
||||
int32_t count;
|
||||
while (true) // Euclidean algorithm
|
||||
{
|
||||
int32_t y_cpy_cpy;
|
||||
int32_t _;
|
||||
_ = HIGHW(((int64_t)y_cpy_cpy_cpy));
|
||||
y_cpy_cpy = LOWW(((int64_t)y_cpy_cpy_cpy));
|
||||
int32_t mod = (COMBINE(y_cpy_cpy, y_cpy_cpy) % x_cpy);
|
||||
y_cpy_cpy_cpy = x_cpy;
|
||||
count = mod;
|
||||
if (mod == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
x_cpy = mod;
|
||||
}
|
||||
if (x_cpy == 1) // Check if increments are coprime
|
||||
{
|
||||
int32_t row = r8; // Stuff we ignored but seems to
|
||||
int32_t column = r11_2; // be the starting point
|
||||
int32_t m = 0x17;
|
||||
int32_t m_cpy;
|
||||
do // Run through the board using coprime increments
|
||||
{
|
||||
// Check if we are inside the board
|
||||
if ((column <= 0xb && row <= 0xb))
|
||||
{
|
||||
// Count the bits
|
||||
count += (board[row] >> column) & 1;
|
||||
}
|
||||
column = (column + y);
|
||||
row = (row + x);
|
||||
m_cpy = m;
|
||||
m = (m - 1);
|
||||
} while (m_cpy != 1);
|
||||
|
||||
// STOP THE COUNT
|
||||
int32_t too_much = count > 2;
|
||||
res_flag = (res_flag | count>2);
|
||||
}
|
||||
if (x == 0xb) // End the while true loops and iterate
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
x = (x + 1); // Update increment
|
||||
r8 = (r8 - 0xb);
|
||||
}
|
||||
if (y_cpy == 0xc)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
y = y_cpy; // Update increment with the next one
|
||||
}
|
||||
res = res_flag == 0;
|
||||
}
|
||||
return ((uint64_t)res);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
uint64_t check(char* input, int64_t len)
|
||||
{
|
||||
char* cursor = input;
|
||||
void* end = &cursor[len];
|
||||
void* fsbase;
|
||||
struct context context;
|
||||
int64_t* context_ptr = &context;
|
||||
for (int64_t i = 0x14; i != 0; i = (i - 1))
|
||||
{
|
||||
*(int64_t*)context_ptr = 0;
|
||||
context_ptr = &context_ptr[1];
|
||||
}
|
||||
|
||||
context.__offset0x8_q = 0x100ffffff;
|
||||
*(int32_t*)context_ptr = 0;
|
||||
|
||||
...
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
uint64_t check(char* input, int64_t len)
|
||||
{
|
||||
...
|
||||
|
||||
uint64_t res;
|
||||
while (cursor < end)
|
||||
{
|
||||
char* next = &cursor[1];
|
||||
if (*(int8_t*)cursor > 4)
|
||||
{
|
||||
res = ((uint64_t)(context.err | 1));
|
||||
break;
|
||||
}
|
||||
switch (*(int8_t*)cursor)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
...
|
||||
break;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
...
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
...
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
...
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
...
|
||||
break;
|
||||
}
|
||||
}
|
||||
cursor = next;
|
||||
}
|
||||
if ((cursor >= end || (cursor < end && *(int8_t*)cursor <= 4)))
|
||||
{
|
||||
res = 1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
Executable
BIN
Binary file not shown.
@@ -0,0 +1,29 @@
|
||||
int32_t main(int32_t argc, char** argv, char** envp)
|
||||
{
|
||||
char input[0x400];
|
||||
ssize_t len = read(0, &input, 0x400);
|
||||
if (len <= 0)
|
||||
{
|
||||
puts("Error.");
|
||||
exit(1);
|
||||
/* no return */
|
||||
}
|
||||
int32_t res = check(&input, len);
|
||||
if (res == 0)
|
||||
{
|
||||
FILE* file = fopen("flag.txt", &r);
|
||||
if (file == 0)
|
||||
{
|
||||
puts("Well done! You can submit your i…");
|
||||
exit(1);
|
||||
/* no return */
|
||||
}
|
||||
char flag[0x46];
|
||||
if (fread(&flag, 1, 0x46, file) != 0)
|
||||
{
|
||||
__printf_chk(1, "Well done, the flag is %s\n", &flag);
|
||||
}
|
||||
fclose(file);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
enum moves : uint32_t
|
||||
{
|
||||
NEXT_COL = 0x0,
|
||||
PREV_ROW = 0x1,
|
||||
PREV_COL = 0x2,
|
||||
NEXT_ROW = 0x3
|
||||
};
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
uint64_t pop_count(int64_t row)
|
||||
{
|
||||
int64_t rdi = (row - ((row >> 1) & 0x5555555555555555));
|
||||
int64_t rdi_3 = (((rdi >> 2) & 0x3333333333333333) + (rdi & 0x3333333333333333));
|
||||
return (((((rdi_3 >> 4) + rdi_3) & 0xf0f0f0f0f0f0f0f) * 0x101010101010101) >> 0x38);
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
10 8
|
||||
5 6
|
||||
0 4
|
||||
| | | | |X| | | | | | | |
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | |X| | | | | |
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | | | |X| | | |
|
||||
| | | | | | | | | | | | |
|
||||
|
||||
11 10
|
||||
8 8
|
||||
5 6
|
||||
2 4
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | |
|
||||
| | | | |X| | | | | | | |
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | |X| | | | | |
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | | | |X| | | |
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | | | | | |X| |
|
||||
|
||||
7 10
|
||||
6 8
|
||||
5 6
|
||||
4 4
|
||||
3 2
|
||||
2 0
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | |
|
||||
|X| | | | | | | | | | | |
|
||||
| | |X| | | | | | | | | |
|
||||
| | | | |X| | | | | | | |
|
||||
| | | | | | |X| | | | | |
|
||||
| | | | | | | | |X| | | |
|
||||
| | | | | | | | | | |X| |
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | |
|
||||
|
||||
3 10
|
||||
4 8
|
||||
5 6
|
||||
6 4
|
||||
7 2
|
||||
8 0
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | | | | | |X| |
|
||||
| | | | | | | | |X| | | |
|
||||
| | | | | | |X| | | | | |
|
||||
| | | | |X| | | | | | | |
|
||||
| | |X| | | | | | | | | |
|
||||
|X| | | | | | | | | | | |
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | |
|
||||
|
||||
2 8
|
||||
5 6
|
||||
8 4
|
||||
11 2
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | | | |X| | | |
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | |X| | | | | |
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | |
|
||||
| | | | |X| | | | | | | |
|
||||
| | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | |
|
||||
| | |X| | | | | | | | | |
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
from math import gcd
|
||||
|
||||
def pretty_print(arr):
|
||||
res = ""
|
||||
for row in arr:
|
||||
res += '|'
|
||||
for el in row:
|
||||
res += el + '|'
|
||||
res += '\n'
|
||||
return res
|
||||
|
||||
def count_alligned(i, j):
|
||||
for y in range(-0xb, 0xc):
|
||||
if y == 0:
|
||||
continue
|
||||
|
||||
start_row = i + 0x79
|
||||
start_column = (y + 1) * -0xb + j + 11
|
||||
|
||||
for x in range(-0xb, 0xc):
|
||||
if x == 0:
|
||||
start_row -= 0xb
|
||||
continue
|
||||
pgcd = gcd(y, x)
|
||||
if pgcd == 1:
|
||||
arr = [[' ' for _ in range(0xc)] for _ in range(0xc)]
|
||||
row = start_row
|
||||
column = start_column
|
||||
for _ in range(0x17):
|
||||
if column <= 0xb and row <= 0xb and column >= 0 and row >= 0:
|
||||
print(row, column)
|
||||
arr[row][column] = 'X'
|
||||
column += y
|
||||
row += x
|
||||
|
||||
print(pretty_print(arr))
|
||||
start_row -= 0xb
|
||||
|
||||
|
||||
count_alligned(5, 6)
|
||||
Executable
+51
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
|
||||
def check_align(i, j):
|
||||
return b'\x04' + j.to_bytes(1, 'little') + i.to_bytes(1, 'little')
|
||||
|
||||
def cycle():
|
||||
return b'\x01'
|
||||
|
||||
def done():
|
||||
return b'\x00'
|
||||
|
||||
def move():
|
||||
return b'\x02'
|
||||
|
||||
def place():
|
||||
return b'\x03'
|
||||
|
||||
|
||||
def fill_column(skip = True):
|
||||
res = b''
|
||||
for _ in range(0xb):
|
||||
if not skip:
|
||||
res += place()
|
||||
res += move()
|
||||
if not skip:
|
||||
res += place()
|
||||
return res
|
||||
|
||||
|
||||
|
||||
def fill():
|
||||
res = b''
|
||||
res += cycle() * 3
|
||||
res += fill_column(False)
|
||||
for _ in range(5):
|
||||
res += cycle() + move() + cycle()
|
||||
res += fill_column()
|
||||
res += cycle() * 3 + move() + cycle() * 3
|
||||
res += fill_column()
|
||||
res += cycle() + move() + cycle()
|
||||
res += fill_column(False)
|
||||
|
||||
for i in range(0xc):
|
||||
for j in range(0xc):
|
||||
res += check_align(i, j)
|
||||
|
||||
return res + done()
|
||||
|
||||
res = fill()
|
||||
os.write(1, res)
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 140 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.2 MiB |