Merge pull request #1202 from xexyl/2020-endoh2
This commit is contained in:
9 files changed
+428
-5
No files matched your search
@@ -26,15 +26,16 @@ make
|
||||
./prog yoda.txt
|
||||
|
||||
./prog bear.txt
|
||||
``
|
||||
```
|
||||
|
||||
## Judges' remarks:
|
||||
|
||||
Clever use of the C99 complex data type. The spoiler.zip file contains clues
|
||||
as to how some winning authors create / edit programs into ASCII shapes.
|
||||
Clever use of the C99 complex data type. The [spoiler](spoiler/) directory
|
||||
contains clues as to how some winning authors create / edit programs into ASCII
|
||||
shapes.
|
||||
|
||||
With the source from the spoiler.zip file could you make the code render for a
|
||||
larger terminal window? How about adding more glyphs?
|
||||
With the source from the [spoiler](spoiler/) directory could you make the code
|
||||
render for a larger terminal window? How about adding more glyphs?
|
||||
|
||||
## Author's remarks:
|
||||
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,91 @@
|
||||
int*d,D[9999],N=20,L=4,n,m,k,a[3],i;
|
||||
char*p,*q,S[2000]="L@X-SGD-HNBBB-AD-VHSG--XNT\x1b[2J\x1b[H",*s=S,*G="GLYPHS";
|
||||
#include<complex.h>
|
||||
typedef/**/complex/**/double(c);c(X)[3],P,O;
|
||||
c/**/B(double t){
|
||||
double s=1-t,u;
|
||||
P=s*s*X[1]+2*s*t**X+t*t*X[2]+O;
|
||||
u=I*P;
|
||||
return+48*((s=P)+48*I)/(1<u?u:1);
|
||||
}
|
||||
#include<stdio.h>
|
||||
void/**/b(double t,double u){
|
||||
double s=P=B(t)-B(u);
|
||||
(s=P*(2*s-P))<1?
|
||||
m=P=B((t+u)/2),k=-I*P,
|
||||
m>-41&&m<39&&9<k&&k<48?
|
||||
m+=k/2*80+73,
|
||||
S[m]=S[m]-73?k%2?S[m]-96?95:73:S[m]-95?96:73:73
|
||||
:
|
||||
1
|
||||
:
|
||||
(
|
||||
b(t,(t+u)/2),
|
||||
b((t+u)/2,u),
|
||||
0
|
||||
);
|
||||
}
|
||||
#include<time.h>
|
||||
int(main)(int(x),char**V){
|
||||
clock_t(c)=clock();
|
||||
// default message
|
||||
for(d=D;m<26;m++,s++)
|
||||
*s>63?
|
||||
*d++=m%7*16-7*8,*d++=m/7*25,*d++=*s-64
|
||||
:
|
||||
0;;
|
||||
if(V[1]){
|
||||
// read a given file
|
||||
;;;FILE*F=fopen(V[+1],"r");
|
||||
for(d=D,L=N=m=0;(x=fgetc(F))>0||fclose(F);)
|
||||
if(
|
||||
x>13?
|
||||
64<x&&x<91?
|
||||
*d++=m*16,
|
||||
*d++=L*25,
|
||||
*d++=x%26
|
||||
:
|
||||
0,
|
||||
m++,
|
||||
0
|
||||
:
|
||||
1
|
||||
)
|
||||
for(++L;d-D>N*3||(m=0);N++)D[N*3]-=m*8;
|
||||
}
|
||||
for(;i<200+L*25;i++){
|
||||
// clear the screen
|
||||
for(n=0,p=S+33;n<1920;*p++=n++%80>78?10:32){}
|
||||
// render the message
|
||||
for(*p=x=0,d=D;x<N;x++,d+=3){
|
||||
O=(d[1]-i-40)*I+*d;
|
||||
// render a letter
|
||||
n=d[2];
|
||||
p=G;
|
||||
for(;n--;)for(;*p++>33;);
|
||||
*a=a[1]=*p++;
|
||||
for(;*p>33;p++)
|
||||
if(
|
||||
*p%2?
|
||||
*a=*p,0
|
||||
:
|
||||
1
|
||||
){
|
||||
a[2]=*p;
|
||||
for(m=0;m<3;m++){
|
||||
// calculate the point on the load
|
||||
k=a[m]/2-18;
|
||||
q="POINTTABLE";
|
||||
for(n=POINTSTART;k--;)n+=*q++-34;
|
||||
X[m]=n%XMAX+n/XMAX*I;
|
||||
}
|
||||
// bezier
|
||||
b(0,1);
|
||||
*a=a[1]=*p;
|
||||
}
|
||||
}
|
||||
// show and wait
|
||||
for(puts(s),s=S+30;(clock()-c)*10<i*CLOCKS_PER_SEC;);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
Xmax = 13
|
||||
Ymax = 21
|
||||
|
||||
glyphs = {}
|
||||
|
||||
points = []
|
||||
open("glyphs.txt") do |f|
|
||||
while ch = f.gets
|
||||
ch = ch.to_i
|
||||
glyphs[ch] = []
|
||||
while pnt = f.gets
|
||||
break if pnt.chomp == ""
|
||||
x, y, c = pnt.split(",").map {|s| s.to_i }
|
||||
points << (y * Xmax + x)
|
||||
glyphs[ch] << [y * Xmax + x, c == 1]
|
||||
end
|
||||
end
|
||||
end
|
||||
points = points.sort.uniq
|
||||
glyphs.each do |ch, pnts|
|
||||
pnts.map! do |pnt, c|
|
||||
points.index(pnt) * 2 + (c ? 1 : 0) + 36
|
||||
end
|
||||
end
|
||||
pointtable = points.each_cons(2).map {|a, b| b-a+34 }.pack("C*")
|
||||
s = []
|
||||
glyphs.values.each do |points|
|
||||
s += points
|
||||
s << 33
|
||||
end
|
||||
s.pop
|
||||
glyphs = s.pack("C*")
|
||||
|
||||
src = File.read("code.c")
|
||||
src = src.gsub(/\/\/.*/, "")
|
||||
src = src.lines.map {|n| n.strip }.join
|
||||
src = src.gsub("POINTTABLE") { pointtable }
|
||||
src = src.gsub("POINTSTART") { points.first }
|
||||
src = src.gsub("GLYPHS") { glyphs }
|
||||
src = src.gsub("XMAX") { Xmax }
|
||||
src = File.read("tmpl.txt").gsub(/[#!]/) { src.slice!(0, 1) }
|
||||
File.write("prog.c", src)
|
||||
@@ -0,0 +1,209 @@
|
||||
65
|
||||
1,16,0
|
||||
6,2,0
|
||||
11,16,0
|
||||
9,11,0
|
||||
3,11,0
|
||||
|
||||
66
|
||||
2,2,0
|
||||
10,1,1
|
||||
10,5,0
|
||||
10,8,1
|
||||
2,8,0
|
||||
10,8,1
|
||||
10,12,0
|
||||
10,16,1
|
||||
2,15,0
|
||||
2,2,0
|
||||
|
||||
67
|
||||
10,3,0
|
||||
2,0,1
|
||||
2,8,0
|
||||
2,16,1
|
||||
10,13,0
|
||||
|
||||
68
|
||||
2,2,0
|
||||
10,1,1
|
||||
10,8,0
|
||||
10,16,1
|
||||
2,15,0
|
||||
2,2,0
|
||||
|
||||
69
|
||||
10,2,0
|
||||
2,2,0
|
||||
2,8,0
|
||||
8,8,0
|
||||
2,8,0
|
||||
2,15,0
|
||||
10,15,0
|
||||
|
||||
70
|
||||
10,2,0
|
||||
2,2,0
|
||||
2,8,0
|
||||
8,8,0
|
||||
2,8,0
|
||||
2,15,0
|
||||
|
||||
71
|
||||
10,3,0
|
||||
2,0,1
|
||||
2,8,0
|
||||
2,16,1
|
||||
6,16,0
|
||||
11,16,1
|
||||
10,10,0
|
||||
6,10,0
|
||||
|
||||
72
|
||||
2,2,0
|
||||
2,15,0
|
||||
2,8,0
|
||||
10,8,0
|
||||
10,2,0
|
||||
10,15,0
|
||||
|
||||
73
|
||||
3,2,0
|
||||
9,2,0
|
||||
6,2,0
|
||||
6,15,0
|
||||
3,15,0
|
||||
9,15,0
|
||||
|
||||
74
|
||||
6,2,0
|
||||
11,2,0
|
||||
9,2,0
|
||||
9,13,0
|
||||
6,19,1
|
||||
3,13,0
|
||||
|
||||
75
|
||||
2,2,0
|
||||
2,15,0
|
||||
2,10,0
|
||||
10,2,0
|
||||
4,8,0
|
||||
10,15,0
|
||||
|
||||
76
|
||||
2,2,0
|
||||
2,15,0
|
||||
10,15,0
|
||||
|
||||
77
|
||||
2,15,0
|
||||
2,2,0
|
||||
6,10,0
|
||||
10,2,0
|
||||
10,15,0
|
||||
|
||||
78
|
||||
2,15,0
|
||||
2,2,0
|
||||
10,15,0
|
||||
10,2,0
|
||||
|
||||
79
|
||||
6,2,0
|
||||
2,2,1
|
||||
2,9,0
|
||||
2,15,1
|
||||
6,15,0
|
||||
10,15,1
|
||||
10,9,0
|
||||
10,2,1
|
||||
6,2,0
|
||||
|
||||
80
|
||||
2,15,0
|
||||
2,2,0
|
||||
10,1,1
|
||||
10,5,0
|
||||
10,9,1
|
||||
2,8,0
|
||||
|
||||
81
|
||||
10,19,0
|
||||
6,19,1
|
||||
6,15,0
|
||||
10,15,1
|
||||
10,9,0
|
||||
10,2,1
|
||||
6,2,0
|
||||
2,2,1
|
||||
2,9,0
|
||||
2,15,1
|
||||
6,15,0
|
||||
|
||||
82
|
||||
2,15,0
|
||||
2,2,0
|
||||
10,1,1
|
||||
10,5,0
|
||||
10,9,1
|
||||
2,8,0
|
||||
6,8,0
|
||||
10,15,0
|
||||
|
||||
83
|
||||
10,3,0
|
||||
6,1,1
|
||||
3,2,0
|
||||
0,5,1
|
||||
6,8,0
|
||||
12,11,1
|
||||
9,15,0
|
||||
6,16,1
|
||||
2,14,0
|
||||
|
||||
84
|
||||
1,2,0
|
||||
11,2,0
|
||||
6,2,0
|
||||
6,16,0
|
||||
|
||||
85
|
||||
2,2,0
|
||||
1,16,1
|
||||
6,16,0
|
||||
11,16,1
|
||||
10,2,0
|
||||
|
||||
86
|
||||
2,2,0
|
||||
6,15,0
|
||||
10,2,0
|
||||
|
||||
87
|
||||
1,2,0
|
||||
3,15,0
|
||||
6,4,0
|
||||
9,15,0
|
||||
11,2,0
|
||||
|
||||
88
|
||||
2,2,0
|
||||
10,16,0
|
||||
6,9,0
|
||||
10,2,0
|
||||
2,16,0
|
||||
|
||||
89
|
||||
2,1,0
|
||||
6,9,0
|
||||
6,16,0
|
||||
6,9,0
|
||||
10,1,0
|
||||
|
||||
90
|
||||
2,2,0
|
||||
10,2,0
|
||||
2,15,0
|
||||
10,15,0
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/* A long time ago in a galaxy far, far away.... */
|
||||
|
||||
int*d,D[9999],N=20,L=4,n,m,k,a[3],i;char*p,*q,S[2000]="L@X-SGD-HNBBB-AD-VHSG-\
|
||||
-XNT\x1b[2J\x1b[H",*s=S,*G="r2zZX!.+@KBK^yh.!:%Bud!.+Jyh.!6.BHBhp!6.BHBh!:%Bu\
|
||||
v{VT!.hBJ6p!042ljn!284b}`!.hR6Dp!.hp!h.T6p!h.p6!2/LilqP72!h.+@QB!~}lqP72/Lil!\
|
||||
h.+@QBFp!:)0?F]nwf!,82v!.sv{6!.l6!,j<n8!.xN6t!&NvN*!.6hp";/*Stay_on_target.**/
|
||||
#include/**/<complex.h>/**//*Oh,my_dear_friend.How_I've_missed_you.--C-3PO***/
|
||||
typedef/**/complex/**/double(c);c(X)[3],P,O;c/**/B(double t){double s=1-t,u;P=
|
||||
s*s*X[1] +2 *s*t* *X+t *t*X [2]+O;u=I*P;
|
||||
return+48*(( s=P)+ 48*I )/( 1<u? u: 1);} /* 1977 IOCCC2020*/
|
||||
#include/** Do.Or do_not . There_is_ no_try... --Yoda**/<stdio.h>
|
||||
void/**/b( double t,/*** * **/double u){double s=P=B(t)-B(u);(s=P
|
||||
*(2*s-P)) <1?m=P=B ((t+ u)/ 2),k =- I*P, m> -41&&m<39&&9<k&&k
|
||||
<48? m+=k/ 2*80+ 73,S [m]= S[m]
|
||||
-73?k%2?S[m]-96?95:73:S[m]-95?96:73:73:1:(b(t,(t+u)/2),b((t+u)/2,u),0);}/*<oo>
|
||||
_No. _I_am_ IOCCC 1977 ***/
|
||||
#include/***** your father.. --DarthVader **/ <time.h>/**** ****/
|
||||
int(main)(int (x), char**V){; clock_t(c)= /* */clock();;; for(d=D
|
||||
;m<26;m++,s ++)*s> 63?*d++=m% 7* 16-7 *8,*d++=m/ 7*25,*d++
|
||||
=*s-64:0;; if(V[1]) {;;;FILE *F =fopen(V[+1], "r");for (d=D,L=N=m
|
||||
=0;(x=/** * *** **/ fgetc(F))>0
|
||||
||fclose(F);)if(x>13?64<x&&x<91?*d++=m*16,*d++=L*25,*d++=x%26:0,m++,0:1)for(++
|
||||
L;d-D>N*3||(m=0);N++)D[N*3]-=m*8;}for(;i<200+L*25;i++){for(n=0,p=S+33;n<1920;*
|
||||
p++=n++%80>78?10:32){}for(*p=x=0,d=D;x<N;x++,d+=3){O=(d[1]-i-40)*I+*d;n=d[2];p
|
||||
=G;for(;n--;)for(;*p++>33;);*a=a[1]=*p++;for(;*p>33;p++)if(*p%2?*a=*p,0:1){a[2
|
||||
]=*p;for(m=0;m<3;m++){k=a[m]/2-18;q="/&&&##%%##.+),A$$$$'&&'&&((%-((#'/#%%#&#\
|
||||
&&#D&";for(n=2;k--;)n+=*q++-34;X[m]=n%13+n/13*I;}b(0,1);*a=a[1]=*p;}}for(puts(
|
||||
s),s=S+30;(clock()-c)*10<i*CLOCKS_PER_SEC;);}return 0;}/*Nevertellmetheodds*/
|
||||
@@ -0,0 +1,19 @@
|
||||
# Opening crawl ROT13 decoder
|
||||
|
||||
The program contains dedicated font data for all uppercase alphabet letters.
|
||||
|
||||
The source code of the font is [glyphs.txt](glyphs.txt), which is a sequence of
|
||||
chunks that is a ASCII code (65-90) followed by points data: `x,y,ctrl`.
|
||||
|
||||
If `ctrl` is 1, the point is used as control point for quadratic bezier curve.
|
||||
|
||||
[code.c](code.c) is the main logic for the program, which has some placeholders
|
||||
for font data and something.
|
||||
|
||||
It decompresses the font data and renders a given text by projection. It
|
||||
exploits `C99`'s `double complex` type to represent 2D points, but carefully
|
||||
coded so that it does not require any `math.h` functions; you don't have to pass
|
||||
`-lm` to `cc`.
|
||||
|
||||
[tmpl.txt](tmpl.txt) is a template for the program. [gen.rb](gen.rb) composes
|
||||
the all items and generates [prog.c](prog.c).
|
||||
@@ -0,0 +1,28 @@
|
||||
/* A long time ago in a galaxy far, far away.... */
|
||||
|
||||
#############################################################################\
|
||||
#############################################################################\
|
||||
#############################################################################\
|
||||
##########################################################/*Stay_on_target.**/
|
||||
########/**/###########/**//*Oh,my_dear_friend.How_I've_missed_you.--C-3PO***/
|
||||
##############################################################################
|
||||
######## ## ##### #### #### ############
|
||||
############ ##### #### ### #### ## #### /* 1977 IOCCC2020*/
|
||||
########/** Do.Or do_not . There_is_ no_try... --Yoda**/#########
|
||||
########## ###### ! ##/*** * **/###### ! ######### ! ##################
|
||||
######### ######## #### ### #### ## #### ## #################
|
||||
#### ##### ##### #### #### ####
|
||||
########################################################################/*<oo>
|
||||
_No. _I_am_ IOCCC 1977 ***/
|
||||
########/***** your father.. --DarthVader **/ ########/**** ****/
|
||||
############# #### #########; ########### /* */########;; #######
|
||||
########### ###### ########## ## #### ########## #########
|
||||
########## ######## ######## ## ############# ######## ##########
|
||||
######/** * *** **/ ###########
|
||||
##############################################################################
|
||||
##############################################################################
|
||||
##############################################################################
|
||||
##############################################################################
|
||||
#############################################################################\
|
||||
##############################################################################
|
||||
#######################################################/*Nevertellmetheodds!*/
|
||||
@@ -2501,6 +2501,11 @@ debugging it since it works with `-O0`.
|
||||
He also added the script [demo.sh](2019/karns/demo.sh) to showcase the entry a
|
||||
bit more easily.
|
||||
|
||||
## [2020/endoh2](2020/endoh2/prog.c) ([README.md](2020/endoh2/README.md))
|
||||
|
||||
Cody copied the files from the spoiler.zip file that was password protected with
|
||||
a password that was no longer known from his preview of 2020.
|
||||
|
||||
## [2020/endoh3](2020/endoh3/prog.c) ([README.md](2020/endoh3/README.md))
|
||||
|
||||
Cody fixed the script [run_clock.sh](2020/endoh3/run_clock.sh) which gave a
|
||||
|
||||
Reference in new issue
Block a user