Add 2020 source files for real

This commit is contained in:
Landon Curt Noll committed 2020-12-31 18:34:17 -08:00
1 parent a3c1748648
commit 9d61fc0fb4
147 files changed
+32101

No files matched your search

+617
View File
@@ -0,0 +1,617 @@
#!/usr/bin/env make
#
# 2020 makefile
#
# This work by Landon Curt Noll, Simon Cooper, and Leonid A. Broukhis
# is licensed under:
#
# Creative Commons Attribution-ShareAlike 3.0 Unported License.
#
# See: http://creativecommons.org/licenses/by-sa/3.0/
#############################
# shell used by this Makefile
#############################
#
SHELL= /bin/bash
#######################
# common tool locations
#######################
#
A2P= a2p
AR= ar
ASA= asa
AT= at
ATQ= atq
ATRM= atrm
AWK= awk
BANNER= banner
BASE64= base64
BASENAME= basename
BATCH= batch
BC= bc
BINHEX= binhex
BISON= bison
BUNZIP2= bunzip2
BZCAT= bzcat
BZCMP= bzcmp
BZDIFF= bzdiff
BZEGREP= bzegrep
BZFGREP= bzfgrep
BZGREP= bzgrep
BZIP2= bzip2
BZLESS= bzless
BZMORE= bzmore
C2PH= c2ph
C89= c89
C99= c99
CAL= cal
CALC= calc
CAT= cat
CD= cd
CHFLAGS= chflags
CHGRP= chgrp
CHMOD= chmod
CKSUM= cksum
CLANG= clang
CLANG_PLUSPLUS= clang++
CLEAR= clear
CMP= cmp
COL= col
COLLDEF= colldef
COLRM= colrm
COLUMN= column
COMPRESS= compress
CP= cp
CPIO= cpio
CPP= cpp
CRC32= crc32
CSH= csh
CSPLIT= csplit
CURL= curl
CUT= cut
C_PLUSPLUS= c++
C_PLUSPLUS_FILT= c++filt
DATE= date
DC= dc
DD= dd
DF= df
DIFF3= diff3
DIFF= diff
DIG= dig
DIRNAME= dirname
ECHO= echo
ED= ed
EGREP= egrep
ENV= env
EQN= eqn
ETAGS= etags
EXPECT= expect
EXPR= expr
FALSE= false
FGREP= fgrep
FILE= file
FIND2PERL= find2perl
FIND= find
FLEX= flex
FLEX_PLUSPLUS= flex++
FMT= fmt
FOLD= fold
FS_USAGE= fs_usage
FUNZIP= funzip
FUSER= fuser
GCC= gcc
GDIFFMK= gdiffmk
GENCAT= gencat
GENSTRINGS= genstrings
GETOPT= getopt
GETOPTS= getopts
GINDENT= gindent
GNUMAKE= gnumake
GREP= grep
GROFF= groff
GROFFER= groffer
GROG= grog
GROPS= grops
GROTTY= grotty
GUNZIP= gunzip
GVIM= gvim
GZCAT= gzcat
GZEXE= gzexe
GZIP_PROG= gzip
G_PLUSPLUS= g++
H2PH= h2ph
H2XS= h2xs
HASH= hash
HEAD= head
HOSTNAME_PROG= hostname
ICONV= iconv
ID= id
INDENT= indent
INFO= info
JOT= jot
KILL= kill
KSH= ksh
LAST= last
LD= ld
LESSECHO= lessecho
LEX= len
LINK= link
LN= ln
LS= ls
M4= m4
MAKE= make
MAN= man
MKDIR= mkdir
MKFIFo= mkfifo
MKTEMP= mktemp
MV= mv
NANO= nano
NASM= nasm
NEQN= neqn
NICE= nice
NL= nl
NM= nm
NOHUP= nohup
NROFF= nroff
NSLOOKUP= nslookup
OD= od
OPENSSL= openssl
PASTE= paste
PATCH= patch
PATHCHK= pathchk
PAX= pax
PERL= perl
PICO= pico
PR= pr
PRINTENV= printenv
PS= ps
PTAR= ptar
PTARDIFF= ptardiff
PTARGREP= ptargrep
PWD= pwd
PYDOC= pydoc
PYTHON= python
PYTHONW= pythonw
READLINK= readlink
RENICE= renice
RESET= reset
REV= rev
RI= ri
RM= rm
RMDIR= rmdir
RSYNC= rsync
RUBY= ruby
RVIM= rvim
SAY= say
SCP= scp
SCREEN= screen
SCRIPT= script
SDIFF= sdiff
SED= sed
SEQ= seq
SFTP= sftp
SH= sh
SHA1= sha1
SHA= sha
SHAR= shar
SHASUM5_18= shasum5.18
SHASUM= shasum
SIZE= size
SLEEP= sleep
SORT= sort
SSH= ssh
STAT= stat
STRIP= strip
STTY= stty
SUM= sum
SYNC= sync
TABS= tabs
TAIL= tail
TAR= tar
TEE= tee
TEST= test
TFTP= tftp
TIDY= tidy
TIME= time
TOP= top
TOUCH= touch
TPUT= tout
TPUT= tput
TR= tr
TROFF= troff
TRUE= true
TSET= tset
TSORT= tsort
UL= ul
UNAME= uname
UNCOMPRESS= uncompress
UNEXPAND= unexpand
UNIFDEF= unifdef
UNIFDEFALL= unifdefall
UNIQ= uniq
UNITS= units
UNLINK= unlink
UNZIP= unzip
UNZIPSFX= unzipsfx
UPTIME= uptime
UUDECODE= uudecode
UUENCODE= uuencode
UUIDGEN= uuidgen
VI= vi
VIEW= view
VIM= vim
VIMDIFF= vimdiff
W= w
WAIT4PATH= wait4path
WAIT= wait
WC= wc
WHAT= what
WHATIS= whatis
WHICH= which
WHO= who
WHOAMI= whoami
WHOIS= whois
WRTIE= write
XAR= xar
XARGS= xargs
XATTR= xattr
XXD= xxd
YACC= yacc
YES= yes
ZCAT= zcat
ZCMP= zcmp
ZDIFF= zdiff
ZEGREP= zegrep
ZFGREP= zfgrep
ZFORCE= zforce
ZGREP= zgrep
ZIP= zip
ZIPCLOAK= zipcloak
ZIPGREp= zipgrep
ZIPINFo= zipinfo
ZIPNOTE= zipnote
ZIPSPLIT= zipsplit
ZLESS= zless
ZMORE= zmore
ZNEW= znew
ZPRINT= zprint
ZSH= zsh
# Set X11_LIBDIR to the directory where the X11 library resides
#
#X11_LIBDIR= /usr/X11R6/lib
#X11_LIBDIR= /usr/X11/lib
X11_LIBDIR= /opt/X11/lib
# Set X11_INCLUDEDIR to the directory where the X11 include files reside
#
#X11_INCDIR= /usr/X11R6/include
#X11_INCDIR= /usr/X11/include
X11_INCDIR= /opt/X11/include
# CWARN - Silence warnings that ${CWARN} would normally complain about
# CSILENCE -Compiler warnings
#
ifeq ($(CC),clang)
# clang CSILENCE and CWARN
#
CSILENCE=
#CSILENCE= -Wno-implicit-int
#
#CWARN= $CSILENCE}
#CWARN= -Wall $CSILENCE}
#CWARN= -Wall -Wextra $CSILENCE}
#CWARN= -Wall -Wextra -pedantic ${CSILENCE}
#CWARN= -Wall -Wextra -Weverything $CSILENCE}
CWARN= -Wall -Wextra -Weverything -pedantic ${CSILENCE}
else
ifeq ($(CC),gcc)
# gcc CSILENCE and CWARN
#
CSILENCE=
#CSILENCE= -Wno-implicit-int
#
#CWARN= $CSILENCE}
#CWARN= -Wall $CSILENCE}
#CWARN= -Wall -Wextra $CSILENCE}
CWARN= -Wall -Wextra -pedantic ${CSILENCE}
else
# default CSILENCE and WARN
#
CSILENCE=
#CSILENCE= -Wno-implicit-int
#
#CWARN= $CSILENCE}
#CWARN= -Wall $CSILENCE}
#CWARN= -Wall -Wextra $CSILENCE}
CWARN= -Wall -Wextra -pedantic ${CSILENCE}
#CWARN= -Wall -Wextra -Weverything $CSILENCE}
#CWARN= -Wall -Wextra -Weverything -pedantic ${CSILENCE}
endif
endif
# compiler standard
#
#CSTD=
#CSTD= -ansi
CSTD= -std=c11
# compiler bit architecture
#
# Some entries require 32-bitness:
# ARCH= -m32
#
# Some entries require 64-bitness:
# ARCH= -m64
#
# By default we assume nothing:
#
ARCH=
# defines that are needed to compile
#
CDEFINE=
#CDEFINE= -DIOCCC
# 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}
# 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
# under those buggy optimizers and thus you may not want anything.
# Reasonable compilers will allow for -O3.
#
#OPT=
#OPT= -O
#OPT= -O1
#OPT= -O2
OPT= -O3
# default flags for ANSI C compilation
#
CFLAGS= ${CSTD} ${CWARN} ${ARCH} ${CDEFINE} ${CINCLUDE} ${OPT}
# Libraries needed to build
#
LIBS=
#LIBS= -L ${X11_LIBDIR}
# 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.
#
CC= cc
#CC= clang
MAY_NEED_GCC= gcc
##############################
# Special flags for this entry
##############################
#
OBJ= prog.o prog_be.o
DATA= correct
TARGET= prog prog_be check check_be
#
ALT_OBJ= prog.orig.o
ALT_TARGET= prog.orig prog_be.orig
#
B=6945503773712347754LL
I=5859838231191962459LL
T=0
S=7
#
_B=7091606191627001958LL
_I=6006468689561538903LL
_T=1
_S=0
#################
# build the entry
#################
#
all: ${TARGET} ${DATA}
@${TRUE}
prog: prog.c
${CC} ${CFLAGS} -DB=${B} -DI=${I} -DT=${T} -DS=${S} $< -o $@ ${LIBS}
prog_be: prog.c
${CC} ${CFLAGS} -DB=${_B} -DI=${_I} -DT=${_T} -DS=${_S} $< -o $@ ${LIBS}
check: check.sh
@${RM} -f $@
${CP} -f $< $@
${CHMOD} +x $@
check_be: check_be.sh
@${RM} -f $@
${CP} -f $< $@
${CHMOD} +x $@
test: check check_be prog prog_be correct
./check ./prog | ${DIFF} -bw - correct
./check_be ./prog_be | ${DIFF} -bw - correct
# alternative executable
#
alt: ${ALT_TARGET}
@${TRUE}
prog.orig: prog.orig.c
${CC} ${CFLAGS} -DB=${B} -DI=${I} -DT=${T} -DS=${S} $< -o $@ ${LIBS}
prog_be.orig: prog.orig.c
${CC} ${CFLAGS} -DB=${_B} -DI=${_I} -DT=${_T} -DS=${_S} $< -o $@ ${LIBS}
# data files
#
data: ${DATA}
@${TRUE}
###############
# 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}
@-if [ -e sandwich ]; then \
${RM} -f sandwich; \
${ECHO} 'ate sandwich'; \
fi
nuke: clobber
@${TRUE}
dist_clean: nuke
@${TRUE}
install:
@${ECHO} "Surely you are performing, Dr. Science!"
@${TRUE}
# backwards compatibility
#
build: all
@${TRUE}
# you may be able to mis-understand the source by reading indent.c
#
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 prog found, ident $< yourself, sorry"; \
${ECHO} "exit 1"; \
exit 1; \
fi
##################
# 133t hacker rulz
##################
#
love:
@${ECHO} 'not war?'
@${TRUE}
haste:
$(MAKE) waste
@${TRUE}
waste:
@${ECHO} 'haste'
@${TRUE}
make:
@${ECHO} 'We encourage you to attend a maker faire'
@${TRUE}
easter_egg:
@${ECHO} you expected to often mis-understand this $${RANDOM} magic
@${ECHO} chongo '<was here>' "/\\oo/\\"
@${ECHO} Eggy and Kitty
fabricate fashion form frame manufacture produce: make
@${TRUE}
sandwich:
@if [ `id -u` -eq 0 ]; then \
${ECHO} 'Okay.'; \
${ECHO} $${RANDOM}`date +%s`$${RANDOM} | \
${SHASUM} -a 512256 | \
${SED} -e 's/ .*//' > $@; \
else \
${ECHO} 'Reall?!? Make it yourself.'; \
exit 1; \
fi
# Understand the history of the Homebrew Computer Club
# as well as the West Coast Computer Faire and
# you might be confused different. :-)
#
supernova: nuke
@-if [ -r .code_anal ]; then \
${RM} -f .code_anal_v6; \
else \
${ECHO} "planet deniers, like a few silly IAU members, are so cute when they try to defend their logic"; \
fi
@${ECHO} A $@ helps ${MAKE} the elements that help form planets
@${TRUE}
deep_magic:
@-if [ -r .code_anal ]; then \
ccode_analysis --deep_magic 253d8c80830e2df66c018820004b3d4939821bbd7d781fc50d9e633797e44f65d1d62c707bb7e5a82c328a37bbf9ecb4c46fb56aa3f08641fcf45d10ba3c6081 --FNV1a_hash_512_bit "prog"; \
else \
${ECHO} "Wrong! Do it again!"; \
sleep 1; \
${ECHO} "Wrong! Do it again!"; \
sleep 1; \
${ECHO} "Wrong! Do it again!"; \
fi
@${TRUE}
magic: deep_magic
@-if [ -r .code_anal ]; then \
ccode_analysis --level 391581 --mode 216193 --state Riesel --FNV1a_hash_512_bit "prog"; \
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?!"; \
${ECHO} "p.s. Be cafeful with that axe, Eugene."; \
fi
@${TRUE}
# The IOCCC resident astronomer states
#
charon: supernova
@${ECHO} $@ is a dwarf planet
@${ECHO} dwarf is a type of planet
@${ECHO} therefore we continue to tell the IAU that $@ is a planet
pluto: supernova
${MAKE} charon
@${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 $< can help ${MAKE} a lot of them
+12
View File
@@ -0,0 +1,12 @@
#!/bin/sh
prog="$1"
: ${prog:=./prog}
check_prog() {
/bin/echo -n "$1 "; $prog $1
}
seq 0 255 | while read a; do
check_prog "$a"
done | pr -t -w120 -8
+12
View File
@@ -0,0 +1,12 @@
#!/bin/sh
prog="$1"
: ${prog:=prog_be}
check_code() {
/bin/echo -n "$1 "; $prog $1 | rev
}
seq 0 255 | while read a; do
check_code "$a"
done | pr -t -w120 -8
+32
View File
@@ -0,0 +1,32 @@
0 00000000 32 00100000 64 01000000 96 01100000 128 10000000 160 10100000 192 11000000 224 11100000
1 00000001 33 00100001 65 01000001 97 01100001 129 10000001 161 10100001 193 11000001 225 11100001
2 00000010 34 00100010 66 01000010 98 01100010 130 10000010 162 10100010 194 11000010 226 11100010
3 00000011 35 00100011 67 01000011 99 01100011 131 10000011 163 10100011 195 11000011 227 11100011
4 00000100 36 00100100 68 01000100 100 01100100 132 10000100 164 10100100 196 11000100 228 11100100
5 00000101 37 00100101 69 01000101 101 01100101 133 10000101 165 10100101 197 11000101 229 11100101
6 00000110 38 00100110 70 01000110 102 01100110 134 10000110 166 10100110 198 11000110 230 11100110
7 00000111 39 00100111 71 01000111 103 01100111 135 10000111 167 10100111 199 11000111 231 11100111
8 00001000 40 00101000 72 01001000 104 01101000 136 10001000 168 10101000 200 11001000 232 11101000
9 00001001 41 00101001 73 01001001 105 01101001 137 10001001 169 10101001 201 11001001 233 11101001
10 00001010 42 00101010 74 01001010 106 01101010 138 10001010 170 10101010 202 11001010 234 11101010
11 00001011 43 00101011 75 01001011 107 01101011 139 10001011 171 10101011 203 11001011 235 11101011
12 00001100 44 00101100 76 01001100 108 01101100 140 10001100 172 10101100 204 11001100 236 11101100
13 00001101 45 00101101 77 01001101 109 01101101 141 10001101 173 10101101 205 11001101 237 11101101
14 00001110 46 00101110 78 01001110 110 01101110 142 10001110 174 10101110 206 11001110 238 11101110
15 00001111 47 00101111 79 01001111 111 01101111 143 10001111 175 10101111 207 11001111 239 11101111
16 00010000 48 00110000 80 01010000 112 01110000 144 10010000 176 10110000 208 11010000 240 11110000
17 00010001 49 00110001 81 01010001 113 01110001 145 10010001 177 10110001 209 11010001 241 11110001
18 00010010 50 00110010 82 01010010 114 01110010 146 10010010 178 10110010 210 11010010 242 11110010
19 00010011 51 00110011 83 01010011 115 01110011 147 10010011 179 10110011 211 11010011 243 11110011
20 00010100 52 00110100 84 01010100 116 01110100 148 10010100 180 10110100 212 11010100 244 11110100
21 00010101 53 00110101 85 01010101 117 01110101 149 10010101 181 10110101 213 11010101 245 11110101
22 00010110 54 00110110 86 01010110 118 01110110 150 10010110 182 10110110 214 11010110 246 11110110
23 00010111 55 00110111 87 01010111 119 01110111 151 10010111 183 10110111 215 11010111 247 11110111
24 00011000 56 00111000 88 01011000 120 01111000 152 10011000 184 10111000 216 11011000 248 11111000
25 00011001 57 00111001 89 01011001 121 01111001 153 10011001 185 10111001 217 11011001 249 11111001
26 00011010 58 00111010 90 01011010 122 01111010 154 10011010 186 10111010 218 11011010 250 11111010
27 00011011 59 00111011 91 01011011 123 01111011 155 10011011 187 10111011 219 11011011 251 11111011
28 00011100 60 00111100 92 01011100 124 01111100 156 10011100 188 10111100 220 11011100 252 11111100
29 00011101 61 00111101 93 01011101 125 01111101 157 10011101 189 10111101 221 11011101 253 11111101
30 00011110 62 00111110 94 01011110 126 01111110 158 10011110 190 10111110 222 11011110 254 11111110
31 00011111 63 00111111 95 01011111 127 01111111 159 10011111 191 10111111 223 11011111 255 11111111
+85
View File
@@ -0,0 +1,85 @@
# Best one-liner
Dave Burton
<http://snox.net/ioccc>
Twitter: @lv2jmp
The code for this entry can be found in prog.c
## Judges' comments:
### To use:
make
./prog
### Try:
./prog 128
./prog_be 128
./prog 170
./prog 85
### Selected Judges Remarks:
This tiny one-liner is a bit-twiddlers delight! It does all of the work
without looping.
To understand how it works, a good place to start is to look at the hex
value that results when the two magic constants are XOR'ed.
Once you've figured out what happens with one set of constants, how can
choosing new constants, but using the same computation generate a reversed
result?
## Author's comments:
Invoke this with a single non-negative integer less than 256, and a useful transformation occurs.
### Rule 2-ish
Exporting the constants B,I,T,S to the makefile allows the code
to be compiled for either LE (little-endian) or BE (big-endian) machines(!!),
so they are truly configuration parameters, not logic.
### Notes
One <strike>ping</strike> argument only. It will SEGV on zero arguments, and
display strange results if more than one argument.
Small, non-negative integers only. Useful range is 0 .. 511, sorta, for LE; 0 .. 255 for BE.
Bonus points if you can explain why the limits work this way.
ASCII character set, 64-bit long longs are required.
v,a,r,i,a,b,l,e,s_NAME the operation.
No loops, no branches?!?
### Compilation
Compiles cleanly under `clang -Wall -Weverything -pedantic`,
but you need to add `--include stdio.h --include stdlib.h` for the `printf`(3) and `atoi`(3).
On a little-endian machine:
clang -include stdio.h -include stdlib.h -Wall -Weverything -pedantic -DB=6945503773712347754LL -DI=5859838231191962459LL -DT=0 -DS=7 -o prog prog.c
On a big-endian machine:
clang -include stdio.h -include stdlib.h -Wall -Weverything -pedantic -DB=7091606191627001958LL -DI=6006468689561538903LL -DT=1 -DS=0 -o prog.be prog.c
You might be interested to compile it both ways on the same host, and try:
./prog 1; ./prog.be 1
-----------------------------------------------------------------------------------------------------
(c) Copyright 1984-2020, [Leo Broukhis, Simon Cooper, Landon Curt Noll][judges] - All rights reserved
This work is licensed under a [Creative Commons Attribution-ShareAlike 3.0 Unported License][cc].
[judges]: http://www.ioccc.org/judges.html
[cc]: http://creativecommons.org/licenses/by-sa/3.0/
-----------------------------------------------------------------------------------------------------
+122
View File
@@ -0,0 +1,122 @@
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional //EN">
<html>
<head>
<meta name="GENERATOR" content="mkd2html 2.2.2">
<meta http-equiv="Content-Type"
content="text/html; charset=utf-8"> <link rel="stylesheet"
type="text/css"
href="../hint.css" />
<title></title>
<title>Best one-liner</title>
</head>
<body>
<CENTER>
<IMG SRC="/png/ioccc.png" ALT="IOCCC" height=78 width=267>
<P><FONT size="6"><I>The International Obfuscated C Code Contest</I></FONT></P>
<div id="bar">
<ul>
<li><a href="../index.html">About the 27th IOCCC</a></li>
<li><a href="../whowon.html">27th IOCCC Winners</a></li>
<li><a href="/index.html">IOCCC home</a></li>
<li><a href="/winners.html">List of All Winners</a></li>
<li><a href="/judges.html">The Judges</a></li>
</ul>
</div>
<P><FONT size="6"><B>A 27<sup>th</sup> IOCCC Winner</B></FONT></P>
</CENTER>
<h1>Best one-liner</h1>
<p>Dave Burton<br/>
<a href="http://snox.net/ioccc">http://snox.net/ioccc</a><br/>
Twitter: @lv2jmp</p>
<p>The code for this entry can be found in <a href="prog.c">prog.c</a></p>
<h2>Judges' comments:</h2>
<h3>To use:</h3>
<pre><code>make
./prog
</code></pre>
<h3>Try:</h3>
<pre><code>./prog 128
./prog_be 128
./prog 170
./prog 85
</code></pre>
<h3>Selected Judges Remarks:</h3>
<p>This tiny one-liner is a bit-twiddlers delight! It does all of the work
without looping.</p>
<p>To understand how it works, a good place to start is to look at the hex
value that results when the two magic constants are XOR'ed.</p>
<p>Once you&rsquo;ve figured out what happens with one set of constants, how can
choosing new constants, but using the same computation generate a reversed
result?</p>
<h2>Author&rsquo;s comments:</h2>
<p>Invoke this with a single non-negative integer less than 256, and a useful transformation occurs.</p>
<h3>Rule 2-ish</h3>
<p>Exporting the constants B,I,T,S to the makefile allows the code
to be compiled for either LE (little-endian) or BE (big-endian) machines(!!),
so they are truly configuration parameters, not logic.</p>
<h3>Notes</h3>
<p>One <strike>ping</strike> argument only. It will SEGV on zero arguments, and
display strange results if more than one argument.</p>
<p>Small, non-negative integers only. Useful range is 0 .. 511, sorta, for LE; 0 .. 255 for BE.
Bonus points if you can explain why the limits work this way.</p>
<p>ASCII character set, 64-bit long longs are required.</p>
<p>v,a,r,i,a,b,l,e,s_NAME the operation.</p>
<p>No loops, no branches?!?</p>
<h3>Compilation</h3>
<p>Compiles cleanly under <code>clang -Wall -Weverything -pedantic</code>,
but you need to add <code>--include stdio.h --include stdlib.h</code> for the <code>printf</code>(3) and <code>atoi</code>(3).</p>
<p>On a little-endian machine:</p>
<pre><code>clang -include stdio.h -include stdlib.h -Wall -Weverything -pedantic -DB=6945503773712347754LL -DI=5859838231191962459LL -DT=0 -DS=7 -o prog prog.c
</code></pre>
<p>On a big-endian machine:</p>
<pre><code>clang -include stdio.h -include stdlib.h -Wall -Weverything -pedantic -DB=7091606191627001958LL -DI=6006468689561538903LL -DT=1 -DS=0 -o prog.be prog.c
</code></pre>
<p>You might be interested to compile it both ways on the same host, and try:</p>
<pre><code>./prog 1; ./prog.be 1
</code></pre>
<BR>
<HR>
<TABLE><TR>
<TD><a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="/png/by-sa-3.0-88x31.png" /></a></TD>
<TD><P>&copy; Copyright 1984-2020,
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
- All rights reserved<BR>
This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
<TD>&nbsp;<!--<a href="https://validator.w3.org/check?uri=referer"><img src="https://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
</TR></TABLE>
</body>
</html>
+1
View File
@@ -0,0 +1 @@
int main(int b,char**i){long long n=B,a=I^n,r=(a/b&a)>>4,y=atoi(*++i),_=(((a^n/b)*(y>>T)|y>>S)&r)|(a^r);printf("%.8s\n",(char*)&_);}