summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/dragonturn.c14
-rw-r--r--src/bin/lineplot.c18
-rw-r--r--src/bin/turn2line.c16
3 files changed, 48 insertions, 0 deletions
diff --git a/src/bin/dragonturn.c b/src/bin/dragonturn.c
new file mode 100644
index 0000000..a12bb97
--- /dev/null
+++ b/src/bin/dragonturn.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <string.h>
+int main(int argc,char *argv[]) {
+ int i,j;
+ char turns[1024]="R",append[1024],tmp[1024];
+ for(i=0;i<atoi(argv[1]);i++) {
+ strcpy(append,turns);
+ strcat(turns,"R");
+ for(j=0;append[j];j++) tmp[strlen(append)-j-1]=append[j]=='R'?'L':'R';
+ tmp[j]=0;
+ strcat(turns,tmp);
+ }
+ printf("F%s\n",turns);
+}
diff --git a/src/bin/lineplot.c b/src/bin/lineplot.c
new file mode 100644
index 0000000..781a85a
--- /dev/null
+++ b/src/bin/lineplot.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <string.h>
+#define WIDTH 39
+#define HEIGHT 24
+char buff[WIDTH*HEIGHT*4];
+void draw_line(x1,y1,x2,y2) {
+ buff[(y1*WIDTH*2)+x1]='+';
+ buff[(((y1+y2)/2) * WIDTH *2)+((x1+x2)/2)]=
+ (x1==x2)?'|':(y1==y2)?'-':((x1<x2&&y1>y2)||(x1>x2&&y1<y2))?'/':'\\';
+ buff[(y2*WIDTH*2)+x2]='+';
+}
+int main(int argc,char *argv[]) {
+ int x1,y1,x2,y2,y;
+ memset(buff,' ',WIDTH*HEIGHT*4);
+ while(scanf("%d %d %d %d",&x1,&y1,&x2,&y2) == 4)
+ draw_line((x1+8)*2,(y1+8)*2,(x2+8)*2,(y2+8)*2);
+ for(y=0;y<HEIGHT*2;y++,write(1,"\n",1)) write(1,buff+(y*WIDTH*2),WIDTH*2);
+}
diff --git a/src/bin/turn2line.c b/src/bin/turn2line.c
new file mode 100644
index 0000000..3dc190a
--- /dev/null
+++ b/src/bin/turn2line.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+int main(int argc,char *argv[]) {
+ int in,x=0,dx,y=0,dy,h=0,dh=argc<2?-1:atoi(argv[1]);
+ for(;(in=fgetc(stdin)) != -1;dh=-1,x+=dx,y+=dy) {
+ if(dh == -1) {
+ dh=-4;
+ switch(in) { case'B':dh++;case'm':dh++;case'L':dh++;case'l':dh++;
+ case'F':dh++;case'r':dh++;case'R':dh++;case's':dh++;default:break; }
+ if(dh==-4) continue;
+ }
+ h=(h+8+dh)%8;
+ dx=(signed char)"\x01\x01\x00\xff\xff\xff\x00\x01"[h%8];
+ dy=(signed char)"\x00\x01\x01\x01\x00\xff\xff\xff"[h%8];
+ printf("%d %d %d %d\n",x,y,x+dx,y+dy);
+ }
+}