This file contains 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
hc027@HC027:~$ nc -l -p 0 >> server.log & | |
[3] 13060 | |
hc027@HC027:~$ netstat -ltnp | grep nc # do rest in separate shell window | |
tcp 0 0 0.0.0.0:34033 0.0.0.0:* LISTEN 13060/nc | |
hc027@HC027:~$ nc localhost 34033 | |
Test Alexis hypothesis | |
^C | |
hc027@HC027:~$ cat server.log |
This file contains 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
.section .data | |
.section .text | |
.globl _start | |
_start: | |
mov $1, %eax # this is the linux kernel command | |
# number (system call) for exiting | |
# a program |
This file contains 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
queens = [] | |
def legalize(past): | |
row = [0 for i in range(8)] | |
for p_row in range(len(past)): | |
for i in range(len(past[p_row])): | |
if past[p_row][i] == "Q": | |
row[i] = 1 | |
if i - p_row >= 0: | |
row[i - p_row] = 1 |
This file contains 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
from copy import deepcopy | |
# deepcopy allows us to pass | |
# arrays as function arguments | |
# by value instead of reference | |
# array of solutions | |
queens = [] | |
# generate new row, marking unthreatened rows | |
# with 0 and threatened riws as 1 |
This file contains 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
.section .data | |
.section .text | |
.globl _start | |
_start: | |
movl $5, %edi # number of fibnum we hunt | |
movl $0, %ebx # 1st fibnum | |
movl $1, %eax # 2nd fibnum | |
start_loop: | |
## Check if %edi is 0 |
This file contains 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
hc015@HC015:~$ readelf -e love_asm | |
ELF Header: | |
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 | |
Class: ELF64 | |
Data: 2's complement, little endian | |
Version: 1 (current) | |
OS/ABI: UNIX - System V | |
ABI Version: 0 | |
Type: EXEC (Executable file) | |
Machine: Advanced Micro Devices X86-64 |
This file contains 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
.section .text | |
.globl _start | |
_start: | |
movl $5, %edi # number of fibnum we hunt | |
movl $0, %ebx # 1st fibnum | |
movl $1, %eax # 2nd fibnum | |
start_loop: | |
## Check if %edi is 0 | |
## (thus meaning %ebx is nth fibnum) |
This file contains 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
.section .data | |
.section .text | |
.globl _start | |
_start: | |
movl $10, %edi # number of fibnum we hunt | |
movl $0, %ebx # 1st fibnum | |
movl $1, %esi | |
call _saveIP | |
_saveIP: |
This file contains 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
.section .data | |
.section .text | |
.globl _start | |
_start: | |
# adjust stack frame and push fib args to stack | |
pushl $5 | |
pushl $1 | |
pushl $0 |
This file contains 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
def threatened(pos, past, n): | |
for i in range(len(past)): | |
if past[i] == pos or abs(pos - past[i]) == len(past) - i: | |
return True | |
return False | |
def nqueens(n, past=None): | |
if past == None: | |
for i in range(n): | |
yield from nqueens(n, [i+1]) |
OlderNewer