remove orig code from 2018/hou
This commit is contained in:
1 parent
7c45f5fa69
commit
37cb1d1257
3 files changed
+151
-308
No files matched your search
+146
-106
@@ -1,41 +1,52 @@
|
||||
#!/usr/bin/env make
|
||||
#
|
||||
# 2018 makefile
|
||||
# IOCCC 20178 winning entry - hou
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# This work by Landon Curt Noll, Simon Cooper, and Leonid A. Broukhis
|
||||
# is licensed under:
|
||||
# Regarding individual entries:
|
||||
#
|
||||
# IOCCC winning entry code may not work on your system. Even with standards,
|
||||
# conditions and build environments change, especially when it comes to more
|
||||
# extreme code such you might find in an IOCCC winner. Moreover, what was
|
||||
# allowed and liked in one IOCCC contest may no longer be liked/allowed in
|
||||
# later IOCCC years.
|
||||
#
|
||||
# Corrections on winning author and fixing typos in remarks are VERY WELCOME.
|
||||
#
|
||||
# GitHub pull requests are welcome:
|
||||
#
|
||||
# If you have a patch that might make running an entry work in modern Unix-like
|
||||
# environments, please create a GitHub pull request for the IOCCC judges to
|
||||
# consider.
|
||||
#
|
||||
# Suggestions and corrections regarding Makefiles, winning author information,
|
||||
# fixing typos in remarks, and code patches are welcome via opening a GitHub
|
||||
# issue or better yet, by creating a GitHub pull request for the IOCCC judges
|
||||
# to consider. To form a GitHub issue or GitHub pull, please visit:
|
||||
#
|
||||
# https://github.com/ioccc-src/winner
|
||||
#
|
||||
################################################################################
|
||||
|
||||
# This work by Landon Curt Noll and Leonid A. Broukhis is licensed under:
|
||||
#
|
||||
# Creative Commons Attribution-ShareAlike 3.0 Unported License.
|
||||
#
|
||||
# See: http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
|
||||
################
|
||||
# tool locations
|
||||
################
|
||||
#############################
|
||||
# shell used by this Makefile
|
||||
#############################
|
||||
#
|
||||
SHELL= bash
|
||||
CP= cp
|
||||
CPP= cpp
|
||||
GUNZIP= gunzip
|
||||
BUNZIP2= bunzip2
|
||||
GZIP_PROG= gzip
|
||||
BZIP2= bzip2
|
||||
CURL= curl
|
||||
DD= dd
|
||||
LD= ld
|
||||
MAKE= make
|
||||
RM= rm
|
||||
SED= sed
|
||||
TAR= tar
|
||||
TRUE= true
|
||||
MKDIR= mkdir
|
||||
MV= mv
|
||||
TR= tr
|
||||
GREP= grep
|
||||
SORT= sort
|
||||
UNIQ= uniq
|
||||
STRIP= strip
|
||||
|
||||
#######################
|
||||
# common tool locations
|
||||
#######################
|
||||
#
|
||||
include ../../var.mk
|
||||
|
||||
# Set X11_LIBDIR to the directory where the X11 library resides
|
||||
#
|
||||
@@ -49,28 +60,25 @@ X11_LIBDIR= /opt/X11/lib
|
||||
#X11_INCDIR= /usr/X11/include
|
||||
X11_INCDIR= /opt/X11/include
|
||||
|
||||
# Compiler warnings
|
||||
# Common C compiler warnings to silence
|
||||
#
|
||||
#CWARN=
|
||||
#CWARN= -Wall
|
||||
#CWARN= -Wall -Wextra
|
||||
#CSILENCE=
|
||||
CSILENCE= -Wno-absolute-value
|
||||
|
||||
# Common C compiler warning flags
|
||||
#
|
||||
#CWARN= ${CSILENCE}
|
||||
#CWARN= -Wall ${CSILENCE}
|
||||
#CWARN= -Wall -Wextra ${CSILENCE}
|
||||
CWARN= -Wall -Wextra -pedantic ${CSILENCE}
|
||||
#CWARN= -Wall -Wextra -Weverything
|
||||
#CWARN= -Wall -Wextra -Weverything -pedantic
|
||||
#CWARN= -Wall -Wextra -Weverything -pedantic ${CSILENCE}
|
||||
|
||||
# Silence warnings that ${CWARN} would normally complain about
|
||||
#
|
||||
CSILENCE=
|
||||
#CSILENCE= -Wno-implicit-int
|
||||
|
||||
# compiler standard
|
||||
# Compiler standard
|
||||
#
|
||||
#CSTD=
|
||||
#CSTD= -ansi
|
||||
CSTD= -std=c11
|
||||
CSTD= -std=gnu17
|
||||
|
||||
# compiler bit architecture
|
||||
# Compiler bit architecture
|
||||
#
|
||||
# Some entries require 32-bitness:
|
||||
# ARCH= -m32
|
||||
@@ -82,20 +90,21 @@ CSTD= -std=c11
|
||||
#
|
||||
ARCH=
|
||||
|
||||
# defines that are needed to compile
|
||||
# Defines that are needed to compile
|
||||
#
|
||||
CDEFINE= -D_DEFAULT_SOURCE
|
||||
#CDEFINE= -DIOCCC=25
|
||||
CDEFINE=
|
||||
#CDEFINE= -DIOCCC
|
||||
|
||||
# include files that are needed to compile
|
||||
# Include files that are needed to compile
|
||||
#
|
||||
CINCLUDE=
|
||||
#CINCLUDE= -include stdlib.h
|
||||
#CINCLUDE= -include stdio.h
|
||||
#CINCLUDE= -include stdlib.h -include stdio.h
|
||||
#CINCLUDE= -I ${X11_INCDIR}
|
||||
#CINCLUDE= -I ${HOMEBREW_PREFIX}/include/SDL2
|
||||
|
||||
# optimization
|
||||
# Optimization
|
||||
#
|
||||
# Most compiles will safely use -O2. Some can use only -O1 or -O.
|
||||
# A few compilers have broken optimizers or this entry make break
|
||||
@@ -108,75 +117,99 @@ CINCLUDE=
|
||||
#OPT= -O2
|
||||
OPT= -O3
|
||||
|
||||
# default flags for ANSI C compilation
|
||||
# Default flags for ANSI C compilation
|
||||
#
|
||||
CFLAGS= ${CSTD} ${CWARN} ${ARCH} ${CDEFINE} ${CINCLUDE} ${OPT}
|
||||
|
||||
# Libraries needed to build
|
||||
#
|
||||
#LIBS=
|
||||
LIBS= -lm
|
||||
#LIBS= -L ${X11_LIBDIR}
|
||||
#LIBS= -L ${X11_LIBDIR} -lX11
|
||||
#LIBS= -L ${HOMEBREW_PREFIX}/lib -lSDL
|
||||
|
||||
# ANSI compiler
|
||||
#
|
||||
# Set CC to the name of your ANSI compiler.
|
||||
#
|
||||
# Some entries seem to need gcc. If you have gcc, set
|
||||
# both CC and MAY_NEED_GCC to gcc.
|
||||
#
|
||||
# If you do not have gcc, set CC to the name of your ANSI compiler, and
|
||||
# set MAY_NEED_GCC to either ${CC} (and hope for the best) or to just :
|
||||
# to disable such programs.
|
||||
# C compiler to use
|
||||
#
|
||||
CC= cc
|
||||
#CC=clang
|
||||
MAY_NEED_GCC= gcc
|
||||
#CC=gcc
|
||||
|
||||
# Compiler add-ons or replacements for clang only
|
||||
#
|
||||
ifeq ($(CC),clang)
|
||||
#
|
||||
CSILENCE+= -Wno-float-conversion -Wno-format-nonliteral -Wno-missing-prototypes \
|
||||
-Wno-poison-system-directories -Wno-strict-prototypes
|
||||
#
|
||||
CWARN+= -Weverything
|
||||
#
|
||||
endif
|
||||
|
||||
# Specific add-ons or replacements for gcc only
|
||||
#
|
||||
ifeq ($(CC),gcc)
|
||||
#
|
||||
#CSILENCE+=
|
||||
#
|
||||
#CWARN+=
|
||||
#
|
||||
endif
|
||||
|
||||
|
||||
##############################
|
||||
# Special flags for this entry
|
||||
##############################
|
||||
#
|
||||
OBJ= prog.o
|
||||
DATA=
|
||||
TARGET= prog
|
||||
ENTRY= hou
|
||||
PROG= prog
|
||||
#
|
||||
OBJ= ${PROG}.o
|
||||
DATA= input.json
|
||||
TARGET= ${PROG}
|
||||
#
|
||||
ALT_OBJ=
|
||||
ALT_TARGET= prog.orig
|
||||
ALT_TARGET=
|
||||
|
||||
|
||||
#################
|
||||
# build the entry
|
||||
#################
|
||||
#
|
||||
all: ${TARGET} ${DATA}
|
||||
all: data ${TARGET}
|
||||
@${TRUE}
|
||||
|
||||
prog: prog.c
|
||||
.PHONY: all alt data everything clean clobber install \
|
||||
love haste waste maker easter_egg sandwich \
|
||||
supernova deep_magic magic charon pluto
|
||||
|
||||
${PROG}: ${PROG}.c
|
||||
${CC} ${CFLAGS} $< -o $@ ${LIBS}
|
||||
|
||||
# alternative executable
|
||||
#
|
||||
alt: ${ALT_TARGET}
|
||||
alt: data ${ALT_TARGET}
|
||||
@${TRUE}
|
||||
|
||||
prog.orig: prog.orig.c
|
||||
${CC} ${CFLAGS} $< -o $@ ${LIBS}
|
||||
|
||||
# data files
|
||||
#
|
||||
data: ${DATA}
|
||||
@${TRUE}
|
||||
|
||||
# both all and alt
|
||||
#
|
||||
everything: all alt
|
||||
|
||||
|
||||
###############
|
||||
# utility rules
|
||||
###############
|
||||
#
|
||||
everything: all alt
|
||||
|
||||
clean:
|
||||
${RM} -f ${OBJ} ${ALT_OBJ}
|
||||
@-if [ -f indent.c ]; then \
|
||||
echo ${RM} -f indent.c; \
|
||||
${RM} -f indent.c; \
|
||||
fi
|
||||
|
||||
clobber: clean
|
||||
${RM} -f ${TARGET} ${ALT_TARGET}
|
||||
@@ -185,20 +218,28 @@ clobber: clean
|
||||
echo 'ate sandwich'; \
|
||||
fi
|
||||
|
||||
nuke: clobber
|
||||
@${TRUE}
|
||||
|
||||
dist_clean: nuke
|
||||
@${TRUE}
|
||||
|
||||
install:
|
||||
@echo "Surely you are performing, Dr. May!"
|
||||
@echo "Dr. Spock says that is not logical!"
|
||||
@${TRUE}
|
||||
|
||||
# backwards compatibility
|
||||
# you may be able to misunderstand the source by reading indent.c
|
||||
#
|
||||
build: all
|
||||
@${TRUE}
|
||||
indent.c: ${PROG}.c
|
||||
@if which "${GINDENT}" >/dev/null 2>&1; then \
|
||||
echo ${RM} -f $@; \
|
||||
${RM} -f $@; \
|
||||
echo "${GINDENT} < $< > $@"; \
|
||||
${GINDENT} < $< > $@; \
|
||||
elif which "${INDENT}" >/dev/null 2>&1; then \
|
||||
echo ${RM} -f $@; \
|
||||
${RM} -f $@; \
|
||||
echo "${INDENT} < $< > $@"; \
|
||||
${INDENT} < $< > $@; \
|
||||
else \
|
||||
echo "no intent tool found, ident $< yourself, sorry"; \
|
||||
echo "exit 1"; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
|
||||
##################
|
||||
@@ -217,22 +258,19 @@ waste:
|
||||
@echo 'haste'
|
||||
@${TRUE}
|
||||
|
||||
make:
|
||||
@echo 'Attend a maker faire'
|
||||
maker:
|
||||
@echo 'Participate in a maker faire'
|
||||
@${TRUE}
|
||||
|
||||
easter_egg:
|
||||
@echo you expected to often mis-understand this $${RANDOM} magic
|
||||
@echo chongo '<was here>' "/\\oo/\\"
|
||||
@echo Eggy
|
||||
@echo "you expected to often misunderstand this $${RANDOM} magic"
|
||||
@echo "chongo '<was here>' /\\oo/\\"
|
||||
@echo "Eggy"
|
||||
|
||||
fabricate fashion form frame manufacture produce: make
|
||||
@${TRUE}
|
||||
|
||||
sandwich:
|
||||
sandwich: easter_egg
|
||||
@if [ `id -u` -eq 0 ]; then \
|
||||
echo 'Okay.'; \
|
||||
echo $${RANDOM}`date +%s`$${RANDOM} > $@; \
|
||||
echo "$${RANDOM}`date +%s`$${RANDOM}" > $@; \
|
||||
else \
|
||||
echo 'What? Make it yourself.'; \
|
||||
exit 1; \
|
||||
@@ -242,18 +280,19 @@ sandwich:
|
||||
# as well as the West Coast Computer Faire and
|
||||
# you might be confused different. :-)
|
||||
#
|
||||
supernova: nuke
|
||||
supernova: sandwich
|
||||
@-if [ -r .code_anal ]; then \
|
||||
${RM} -f .code_anal_v6; \
|
||||
else \
|
||||
echo "planet deniers, like some members of the IAU, are so cute when they try to defend their logic"; \
|
||||
fi
|
||||
@echo A $@ helps ${MAKE} the elements that help form planets
|
||||
@echo "A $@ helps ${MAKE} the elements that help form planets"
|
||||
@${TRUE}
|
||||
|
||||
deep_magic:
|
||||
deep_magic: supernova
|
||||
@-if [ -r .code_anal ]; then \
|
||||
ccode_analysis --deep_magic 3a3fabb90892eeb2f610ae0f74a35a970060665a063ab702bd686c17c4ae07f6 --FNV1a_hash_256_bit "prog"; \
|
||||
ccode_analysis --deep_magic 7889066cdbdf09b0408021754586e895be641cc9be29e7eafd3ca65359541f17 \
|
||||
--FNV1a_hash_512_bit -v2 "${PROG}" "${PROG}.c"; \
|
||||
else \
|
||||
echo "Wrong! Do it again!"; \
|
||||
sleep 2; \
|
||||
@@ -265,7 +304,7 @@ deep_magic:
|
||||
|
||||
magic: deep_magic
|
||||
@-if [ -r .code_anal ]; then \
|
||||
ccode_analysis --mode 216091 --level 216193 --FNV1a_hash_256_bit "prog"; \
|
||||
ccode_analysis --level 20003 --mode 5717175 --FNV1a_hash_512_bit -v2 "${PROG}" "${PROG}.c"; \
|
||||
else \
|
||||
echo "If you don't eat yer meat, you can't have any pudding!"; \
|
||||
echo "How can you have any pudding if you don't eat yer meat?!"; \
|
||||
@@ -274,14 +313,15 @@ magic: deep_magic
|
||||
|
||||
# The IOCCC resident astronomer states
|
||||
#
|
||||
charon: supernova
|
||||
@echo $@ is a dwarf planet
|
||||
@echo dwarf is a type of planet
|
||||
@echo $@ is a planet
|
||||
charon: magic
|
||||
@echo "$@ is a dwarf planet"
|
||||
@echo "dwarf is a type of planet"
|
||||
@echo "therefore IAU, $@ is a planet"
|
||||
|
||||
pluto: supernova
|
||||
pluto: charon
|
||||
${MAKE} charon
|
||||
@echo $@ is a dwarf planet
|
||||
@echo dwarf is a type of planet
|
||||
@echo $@ is a planet
|
||||
@echo get used to having lots of planets becasue supernovae can ${MAKE} a lot of them
|
||||
@echo "$@ is a dwarf planet"
|
||||
@echo "dwarf is a type of planet"
|
||||
@echo "therefore, $@ is a planet"
|
||||
@echo "having lots of planets is good feature because supernovae can help ${MAKE} a lot of them"
|
||||
|
||||
+5
-5
@@ -2,14 +2,15 @@
|
||||
|
||||
Qiming HOU
|
||||
|
||||
## To build:
|
||||
|
||||
## Judges' comments:
|
||||
### To use:
|
||||
make all
|
||||
|
||||
### To run
|
||||
|
||||
make
|
||||
./prog < input.json > output.html
|
||||
|
||||
View `output.html` in a browser.
|
||||
View `output.html` in a browser.
|
||||
|
||||
### Try:
|
||||
|
||||
@@ -29,7 +30,6 @@ The rulez of programming in an imperative language are violated, aren't they?
|
||||
|
||||
Try figuring out how to increase the number of different colors, if you can.
|
||||
|
||||
|
||||
## Author's comments:
|
||||
|
||||
Nowadays almost every programmer needs to do some Web chore. With all the open source stuff readily available, often we just need to call a bunch of libraries to generate an HTML page from a JSON feed.
|
||||
|
||||
@@ -1,197 +0,0 @@
|
||||
/**
|
||||
* \file prog.c
|
||||
*
|
||||
* \brief Renders an HTML chart from JSON data
|
||||
*
|
||||
* \author Qiming HOU
|
||||
*
|
||||
* Copyright (C) 2017-2018, Qiming HOU
|
||||
*
|
||||
* Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported
|
||||
* (CC BY-SA 3.0), you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://creativecommons.org/licenses/by-sa/3.0/
|
||||
*
|
||||
* This file is an IOCCC submission.
|
||||
*
|
||||
* This thing wouldn't be possible without the advent of C / HTML standards.
|
||||
* We all love the new math functions in C99 and the inclusion of SVG in
|
||||
* HTML5.
|
||||
*
|
||||
*/
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
/* Macros are named after fashionable jargon */
|
||||
|
||||
#define J ceil(log(erfc(1)))
|
||||
#define S calloc(3, 1)
|
||||
#define O strcat(strcat(S, m(37)), m(102))
|
||||
#define N I(T(6))
|
||||
#define _(X) mmap(fopen(S, S), 64, 3, 1, X, 0)
|
||||
#define H(X) dup2(fileno(tmpfile()), X); m(ftruncate(X, 64))
|
||||
#define T(X) getenv(L(r(1, X, 64)))
|
||||
#define M(X, Y) memcmp(T(X), L(Y), 1)
|
||||
#define L(X) memset(S, X, 1)
|
||||
|
||||
#define m(X) memset(S, X, N)
|
||||
#define o(X) r(copysign(1, X), exp2(J), exp2(J))
|
||||
#define b(X) o(r(abs(X), J, 0))
|
||||
#define i(X) setenv(L(70), L(r(1, X, 48)), 1)
|
||||
#define l(X, Y) setenv(m(r(1, X, 64)), L(Y), 1)
|
||||
#define e(X) setenv(m(r(1, X, 64)), \
|
||||
strcat(strcpy(malloc(r(p(T(X)), 1, 2)), T(X)), T(4)), 1)
|
||||
|
||||
#define W(X) printf(O, floor(X))
|
||||
#define E(X) putchar(r(N, X, 32))
|
||||
#define B(X, Y) sprintf(_(r(N, X, 3)), O, Y)
|
||||
|
||||
#define j(X) t; E(55); E(41); E(36); E(52); E(40); E(29); W(X); t; E(40); \
|
||||
E(37); E(41); E(39); E(40); E(52); E(29); W(X)
|
||||
#define a(X) l(8, 0); i(o(M(8, X)))
|
||||
#define v t; E(16); t
|
||||
#define A E(52); E(37); E(56); E(52)
|
||||
#define s W(r(200, sin(I(_(4))), 250)); t; W(r(200, cos(I(_(4))), 250))
|
||||
#define c E(38); E(41); E(44); E(44); E(29); E(50); E(39); E(34); E(8); \
|
||||
W(r(cos(p(T(2))), 48, 48)); E(5); E(12); E(16); E(5); E(12); \
|
||||
W(r(sin(p(T(2))), 48, 48)); E(5); E(9); t; E(15); E(30); e(2)
|
||||
#define r fma
|
||||
#define I atof
|
||||
#define p strlen
|
||||
#define t E(0)
|
||||
|
||||
#define rulez o(r(J, exp2(N), p(T(1))))
|
||||
|
||||
/**
|
||||
* @brief Renders the chart from JSON input
|
||||
*
|
||||
* Expected input format:
|
||||
* [ {"foo": string, "bar": number}, ... ]
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
int C(){
|
||||
i(1);
|
||||
l(4, getchar());
|
||||
l(8, r(
|
||||
I(T(5)), 4,
|
||||
r(N, o(M(4, 33)), r(N, b(M(4, 44)), r(b(M(4, 34)), 2, 1)))
|
||||
));
|
||||
i(0);
|
||||
a(13);
|
||||
E(28);
|
||||
E(48);
|
||||
E(33);
|
||||
E(52);
|
||||
E(40);
|
||||
t;
|
||||
E(36);
|
||||
E(29);
|
||||
E(7);
|
||||
E(45);
|
||||
W(250);
|
||||
t;
|
||||
W(250);
|
||||
E(44);
|
||||
s;
|
||||
B(1, r(
|
||||
exp2(r(J, log2(I(_(5))), log2(I(T(1))))),
|
||||
r(2, acos(J), 0),
|
||||
I(_(4))
|
||||
));
|
||||
E(33);
|
||||
W(200);
|
||||
t;
|
||||
W(200);
|
||||
v;
|
||||
E(r(1, o(r(2, I(T(1)), r(J, I(_(5)), 0))), 16));
|
||||
v;
|
||||
s;
|
||||
E(58);
|
||||
E(7);
|
||||
c;
|
||||
setenv(m(65), strchr(T(1), r(1, I(T(7)), 9)), 1);
|
||||
l(7, r(J, I(T(7)), 49));
|
||||
fflush(fopen(S, S));
|
||||
assert(rulez);
|
||||
a(12);
|
||||
l(5, 48);
|
||||
E(28);
|
||||
E(15);
|
||||
A;
|
||||
E(30);
|
||||
a(9);
|
||||
m(write(1, T(4), N));
|
||||
a(8);
|
||||
l(5, 50);
|
||||
E(28);
|
||||
E(50);
|
||||
E(37);
|
||||
E(35);
|
||||
E(52);
|
||||
j(16);
|
||||
t;
|
||||
E(56);
|
||||
E(29);
|
||||
W(472);
|
||||
t;
|
||||
E(57);
|
||||
E(29);
|
||||
W(r(p(T(2)), 28, 0));
|
||||
t;
|
||||
c;
|
||||
E(28);
|
||||
A;
|
||||
t;
|
||||
E(56);
|
||||
E(29);
|
||||
W(500);
|
||||
t;
|
||||
E(57);
|
||||
E(29);
|
||||
W(r(p(T(2)), 28, r(J, 16, 0)));
|
||||
E(30);
|
||||
a(7);
|
||||
l(5, 48);
|
||||
l(4, r(1, I(T(7)), 9));
|
||||
e(1);
|
||||
l(7, r(J, I(T(7)), 49));
|
||||
B(2, r(1, I(_(5)), I(strrchr(T(r(N, J, 2)), r(N, I(T(7)), 9)))));
|
||||
a(6);
|
||||
e(1);
|
||||
a(1);
|
||||
i(r(N, b(M(4, 58)), 0));
|
||||
l(5, 49);
|
||||
a(1);
|
||||
i(r(N, b(M(4, J)), 0));
|
||||
l(7, 9);
|
||||
l(5, 51);
|
||||
l(2, 9);
|
||||
return C();
|
||||
}
|
||||
|
||||
int main(){
|
||||
i(1);
|
||||
E(28);
|
||||
E(51);
|
||||
E(54);
|
||||
E(39);
|
||||
j(r(2, 250, 250));
|
||||
E(30);
|
||||
l(1, 10);
|
||||
l(2, 9);
|
||||
l(8, 9);
|
||||
l(4, 9);
|
||||
l(5, 9);
|
||||
l(7, 9);
|
||||
H(3);
|
||||
H(4);
|
||||
H(5);
|
||||
return C();
|
||||
}
|
||||
Reference in new issue
Block a user