Jump to content
Neo Force Order Resurrection
Dr_Windu

Tout Est Codable Ou Presque

Recommended Posts

Rito plz

 

Extrait :

This problem was compounded by the various clock implementations present. Different clock instances would end up running at different rates as the game went on. We even had specialized code in the game that applied magic number multipliers to correct for drift between clock instances.

Oh yeah, baby.

Share this post


Link to post
drfred@holly:~$ python3
Python 3.5.3 (default, Jan 19 2017, 14:11:04)
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> x = "∞"
>>> x.__sizeof__()
40
>>> int(x)
Traceback (most recent call last):
File "", line 1, in
ValueError: invalid literal for int() with base 10: '∞'
>>> x.__sizeof__()
44
>>>
It begins...

Share this post


Link to post

Quand tu penses avoir tout vu lorsque :

return
{
    ...
}

// Équivaut à "return; { ... };"
Tu découvres que l'horreur va en fait toujours plus loin :

return a
(
   ...
)

// Équivaut à "return a( ... );"
M'enfin ?!

 

drfred@holly:~$ echo """
a = ... [REDACTED]
b = ... [REDACTED]
x = a+b
[1].toString()
""" > foo.js
drfred@holly:~$ js foo.js -strict -fatal warnings
drfred@holly:~$ # kthxbai.
PS : Si vous voulez des noms de variables du genre "wtf?", c'est presque-possible ! (Not-actually-a-rant.)

Share this post


Link to post

drfred@holly:~$ js
js> t = [1,2,3,4,5]
1,2,3,4,5
js> print (t[2])
3
js> print (t[5/2])
undefined
js> quit() // Fuck it.
jrwebdev@jsworld:~$ js
js> t = [1,2,3,4,5]
1,2,3,4,5
js> print (t[Math.floor(5/2)])
3
js> print (t[5/2>>0])
3
js> print (t[~~(5/2)])
3
...

 

Pour ceux qui n'auraient pas remarqué l'alias du terminal : le deuxième bloc correspond aux meilleures solutions considérées comme "normales" par la communauté JS.

Share this post


Link to post

I

 

drfred@cortana:~$ man
What manual page do you want?

drfred@cortana:~$ date
Mon Nov 20 23:47:59 CET 2017
drfred@cortana:~$ echo "Wait for it..."
Wait for it...
drfred@cortana:~$ date
Tue Nov 21 00:30:06 CET 2017

drfred@cortana:~$ man
gimme gimme gimme
What manual page do you want?
Obviously, this broke someone's workflow. True story.

Share this post


Link to post

Arg le gars qui pose la question sur SO est pas fut fut. C'est tellement évident comme easter egg !

En tout cas sympa  :lol:

Share this post


Link to post

Boah, évident, c'est relatif. Par exemple, je suis sûr à 97% qu'Aranud n'a aucune idée de pourquoi la commande "man" imprime le message « gimme gimme gimme » après minuit.

 

Explication alternative : le gars a très bien compris pourquoi ce message est là, mais il profite de l'occasion pour partager le WTF.

Share this post


Link to post

commit f860eeadf98319dede87aa142e5ac6a51e48411e
Author: redacted <redacted@example.com>
Date:   Thu Dec 7 00:06:14 2017 +0100

    Implemented flux capacitor.

commit 7ff39883e978ee0f77e925e85d7490f40594fa78
Author: redacted <redacted@example.com>
Date:   Thu Dec 7 00:07:28 2017 +0100

    Plugged leak in flux capacitor.
J'ai toujours rêvé de devenir un savant fou... et je l'ai fait !

 

===

 

Contexte.

 

 

commit 7ff39883e978ee0f77e925e85d7490f40594fa78
Author: redacted <redacted@example.com>
Date:   Thu Dec 7 00:07:28 2017 +0100

    Plugged leak in flux capacitor.

diff --git a/algo/code/turing/main.c b/algo/code/turing/main.c
index 5ffb383..63de484 100644
--- a/algo/code/turing/main.c
+++ b/algo/code/turing/main.c
@@ -178,6 +178,7 @@ int main ()
 			do_step(bb, &bh);
 	}
 
+	free (bh.hist);
 	free (bb->t.contents);
 	free (bb);
 	endwin();

commit f860eeadf98319dede87aa142e5ac6a51e48411e
Author: redacted <redacted@example.com>
Date:   Thu Dec 7 00:06:14 2017 +0100

    Implemented flux capacitor.

diff --git a/algo/code/turing/beaver.c b/algo/code/turing/beaver.c
index 466874f..ac2c920 100644
--- a/algo/code/turing/beaver.c
+++ b/algo/code/turing/beaver.c
@@ -105,11 +105,20 @@ void expand (tape* t)
 	t->head += shift;
 }
 
-void do_step (machine* m)
+void do_step (machine* m, history* h)
 {
 	tape* t = &m->t;
 	step next = m->tf[m->s-1][t->contents[t->head] == BLANK ? 0 : 1];
 
+	if (h) 
+	{
+		bstep back = {t->contents[t->head], -next.dir, m->s};
+		h->hist[h->n++] = back;
+
+		if (h->n == h->size)
+			h->hist = realloc(h->hist, (h->size *= 2) * sizeof(bstep));
+	}
+
 	t->contents[t->head] = next.sym;
 	t->head += next.dir;
 	m->s = next.ns;
@@ -118,3 +127,15 @@ void do_step (machine* m)
 	if (t->head >= t->size)
 		expand(t);
 }
+
+void do_bstep (machine* m, history* h)
+{
+	if (!h->n) { return; }
+
+	tape* t = &m->t;
+	bstep back = h->hist[--(h->n)];
+
+	m->s = back.ns;
+	t->head += back.dir;
+	t->contents[t->head] = back.sym;
+}
diff --git a/algo/code/turing/beaver.h b/algo/code/turing/beaver.h
index 29d7e60..c2d9a37 100644
--- a/algo/code/turing/beaver.h
+++ b/algo/code/turing/beaver.h
@@ -36,6 +36,9 @@ typedef struct {
 	state ns;      // New state
 } step;
 
+// Backstep = { Erased symbol, Head return, Former state }
+typedef step bstep;
+
 typedef struct {
 	symbol* contents; // Contents of the tape
 	unsigned size;    // Total physical size
@@ -51,8 +54,15 @@ typedef struct {
 	tape t;       // Machine tape
 } machine;
 
+typedef struct {
+	bstep* hist;   // History of all backwards steps
+	unsigned size; // Total length of history
+	unsigned n;    // Current position
+} history;
+
 machine* new_beaver (symbol* alph, unsigned as, unsigned ns, step** instructions, state start);
-void do_step (machine* m);
+void do_step (machine* m, history* h); // h = NULL if you don't care
+void do_bstep (machine* m, history* h);
 
 /* Some busy beavers and contenders :
  *
diff --git a/algo/code/turing/main.c b/algo/code/turing/main.c
index d1a1de1..5ffb383 100644
--- a/algo/code/turing/main.c
+++ b/algo/code/turing/main.c
@@ -23,8 +23,6 @@
 #include "beaver.h"
 
 //FIXME: Decouple simulation and interface steps.
-//TODO: Flux capacitor @88MPH.
-//TODO: Tape minimap.
 
 unsigned clamp (unsigned min, unsigned val, unsigned max)
 {
@@ -61,7 +59,7 @@ void print_instructions (machine* m, unsigned x, unsigned y)
 	move(y+1, x);
 	addstr("| S ");
 	for (unsigned i = 1 ; i <= m->ns ; ++i)
-		printw("|   %i%c  ", i, i == m->s ? '*' : ' '); // FIXME: i>9
+		printw("|   %i%c  ", i, (int) i == m->s ? '*' : ' '); // FIXME: i>9
 	addstr("|");
 
 	move(y+2, x);
@@ -100,6 +98,10 @@ int main ()
 	}
 
 	machine* bb = new_beaver(binary, 2, 5, tf, 1);
+	history bh;
+	bh.hist = calloc(42, sizeof(bstep));
+	bh.size = 42;
+	bh.n = 0;
 
 	// Init ncurses
 	initscr(); cbreak(); noecho();
@@ -138,17 +140,25 @@ int main ()
 
 		// Keyboard commands (zqsd=3425)
 		switch (cmd) {
+			case 3: // Up
+				pause = true;
+				do_step(bb, &bh);
+				break;
+			case 2: // Down
+				pause = true;
+				do_bstep(bb, &bh);
+				break;
 			case 4: // Left
-				view--;
+				speed++;
 				break;
 			case 5: // Right
-				view++;
+				speed--;
 				break;
 			case '<':
-				speed ++;
+				view--;
 				break;
 			case '>':
-				speed--;
+				view++;
 				break;
 			case ' ':
 				pause ^= true;
@@ -165,7 +175,7 @@ int main ()
 		// Beaver step
 		usleep(1 << speed);
 		if (!pause)
-			do_step(bb);
+			do_step(bb, &bh);
 	}
 
 	free (bb->t.contents);

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×