[ prog / sol / mona ]

prog


[challenge] Try to rewrite SICP [urgent]

1 2022-08-15 22:14

The wizard book has been stolen (see: http://textboard.org/prog/22/165 )

Your task is to rewrite it one character at a time.

Prof. Abelson will help you recover the sacred text. The Sussman has shown no interest in doing so. Abelson cannot remember the whole book but you can call him and ask if a particular character was at a given position. For some reason that's something he remembers.

The SICP text is here: http://0x0.st/o20u.md (of course you're not allowed to access it from your program or include any part of it in your code but feel free to generate all the stats you deem necessary). Its length is 1223834. That means you have to call Abelson 1223834 times.

Here's Abelson (Abelson is actually a poorly written Python script)

#!/usr/bin/python
from pathlib import Path
import sys
sicp = Path('sicp.md').read_text()
if sys.argv[2] == sicp[int(sys.argv[1])]:
        print("yes yes!")
else:
        print("no, afraid not")

Save it as "say-abelson-was-the-char-at-position" and call it like this:

$ ./say-abelson-was-the-char-at-position 0 a
no, afraid not
$ ./say-abelson-was-the-char-at-position 1223833 "
> "
yes yes!

In other words, your program should take two arguments:
- n, the position in the text
- your guess for the nth character of SICP.

You have to call the Abelson script within your program, read Abelson's response and count the number of times you had a character right, which will be your score. The highest score wins this programming contest. You are naturally allowed to keep track of Abelson's previous answers and to use them however you like in order to guess the next character. Bonus points will be awarded for concision, esoterism, elegance, cleverness, whatever. (execution speed is irrelevant in this challenge)

Deadline is 2022-09-01 00:00 UTC. Good luck, anon, the fate of humanity is in your hands.

14


VIP:

do not edit these