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

+589
View File
@@ -0,0 +1,589 @@
#!/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
CSILENCE= -Wno-missing-variable-declarations -Wno-shorten-64-to-32 -Wno-comma -Wno-shadow \
-Wno-missing-prototypes -Wno-sign-conversion -Wno-implicit-int-conversion \
-Wno-conversion -Wno-unknown-warning-option
#
#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
CSILENCE= -Wno-misleading-indentation -Wno-unknown-warning-option
#
#CWARN= $CSILENCE}
#CWARN= -Wall $CSILENCE}
#CWARN= -Wall -Wextra $CSILENCE}
CWARN= -Wall -Wextra -pedantic ${CSILENCE}
else
# default CSILENCE and WARN
#
CSILENCE= -Wno-misleading-indentation -Wno-unknown-warning-option
#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}
LIBS= -lcurses
# 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
DATA= ioccc.txt unwinnable.txt
TARGET= prog
#
ALT_OBJ=
ALT_TARGET=
#################
# build the entry
#################
#
all: ${TARGET} ${DATA}
@${TRUE}
prog: prog.c
${CC} ${CFLAGS} $< -o $@ ${LIBS}
# alternative executable
#
alt: ${ALT_TARGET}
@${TRUE}
# 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
+33
View File
@@ -0,0 +1,33 @@
64 32 510
510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573
574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637
638 639 0 640 641 642 1 2 3 4 5 6 7 8 9 643 644 645 10 11 12 13 14 15 16 17 18 646 647 648 19 20 21 22 23 24 25 26 27 649 650 651 28 29 30 31 32 33 34 35 36 652 653 654 37 38 39 40 41 42 43 44 45 655
656 657 46 658 659 660 47 661 662 663 664 665 666 667 48 668 669 670 49 671 672 673 674 675 676 677 50 678 679 680 51 681 682 683 684 685 686 687 52 688 689 690 53 691 692 693 694 695 696 697 54 698 699 700 55 701 702 703 704 705 706 707 56 708
709 710 57 711 712 713 58 714 715 716 717 718 719 720 59 721 722 723 60 724 725 726 727 728 729 730 61 731 732 733 62 734 735 736 737 738 739 740 63 741 742 743 64 744 745 746 747 748 749 750 65 751 752 753 66 754 755 756 757 758 759 760 67 761
762 763 68 764 765 766 69 767 768 769 770 771 772 773 70 774 775 776 71 777 778 779 780 781 782 783 72 784 785 786 73 787 788 789 790 791 792 793 74 794 795 796 75 797 798 799 800 801 802 803 76 804 805 806 77 807 808 809 810 811 812 813 78 814
815 816 79 80 81 82 83 817 818 819 84 85 86 87 88 820 821 822 89 90 91 92 93 823 824 825 94 95 96 97 98 826 827 828 99 100 101 102 103 829 830 831 104 105 106 107 108 832 833 834 109 110 111 112 113 835 836 837 114 115 116 117 118 838
839 840 841 842 843 844 845 846 847 848 119 849 850 851 852 853 854 855 856 857 858 859 120 860 861 862 863 864 865 866 867 868 869 870 121 871 872 873 874 875 876 877 878 879 880 881 122 882 883 884 885 886 887 888 889 890 891 892 123 893 894 895 896 897
898 899 900 901 902 903 904 905 906 907 124 908 909 910 911 912 913 914 915 916 917 918 125 919 920 921 922 923 924 925 926 927 928 929 126 930 931 932 933 934 935 936 937 938 939 940 127 941 942 943 944 945 946 947 948 949 950 951 128 952 953 954 955 956
957 958 959 960 961 962 963 964 965 966 129 967 968 969 970 971 972 973 974 975 976 977 130 978 979 980 981 982 983 984 985 986 987 988 131 989 990 991 992 993 994 995 996 997 998 999 132 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 133 1011 1012 1013 1014 1015
1016 1017 134 135 136 137 138 1018 1019 1020 139 140 141 142 143 1021 1022 1023 144 145 146 147 148 1024 1025 1026 149 150 151 152 153 1027 1028 1029 154 1030 1031 1032 155 156 157 158 159 1033 1034 1035 160 1036 1037 1038 161 162 163 164 165 1039 1040 1041 166 167 168 169 170 1042
1043 1044 171 1045 1046 1047 172 1048 1049 1050 1051 1052 1053 1054 173 1055 1056 1057 174 1058 1059 1060 1061 1062 1063 1064 175 1065 1066 1067 176 1068 1069 1070 177 1071 1072 1073 178 1074 1075 1076 179 1077 1078 1079 180 1080 1081 1082 181 1083 1084 1085 182 1086 1087 1088 1089 1090 1091 1092 183 1093
1094 1095 184 1096 1097 1098 185 1099 1100 1101 1102 1103 1104 1105 186 1106 1107 1108 187 1109 1110 1111 1112 1113 1114 1115 188 1116 1117 1118 189 1119 1120 1121 190 1122 1123 1124 191 1125 1126 1127 192 1128 1129 1130 193 1131 1132 1133 194 1134 1135 1136 195 1137 1138 1139 1140 1141 1142 1143 196 1144
1145 1146 197 1147 1148 1149 198 1150 1151 1152 1153 1154 1155 1156 199 1157 1158 1159 200 1160 1161 1162 1163 1164 1165 1166 201 1167 1168 1169 202 1170 1171 1172 203 1173 1174 1175 204 1176 1177 1178 205 1179 1180 1181 206 1182 1183 1184 207 1185 1186 1187 208 1188 1189 1190 1191 1192 1193 1194 209 1195
1196 1197 210 1198 1199 1200 211 212 213 214 215 216 217 218 219 1201 1202 1203 220 221 222 223 224 225 226 227 228 1204 1205 1206 229 1207 1208 1209 230 231 232 233 234 1210 1211 1212 235 236 237 238 239 1213 1214 1215 240 1216 1217 1218 241 242 243 244 245 246 247 248 249 1219
1220 1221 250 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 251 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 252 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280
1281 1282 253 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 254 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 255 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341
1342 1343 256 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 257 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 258 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402
1403 1404 259 260 261 262 263 1405 1406 1407 264 265 266 267 268 269 270 271 272 273 274 275 276 1408 1409 1410 277 278 279 280 281 1411 1412 1413 282 283 284 285 286 1414 1415 1416 287 288 289 290 291 1417 1418 1419 292 1420 1421 1422 293 294 295 296 297 298 299 300 301 1423
1424 1425 1426 1427 1428 1429 302 1430 1431 1432 303 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 304 1444 1445 1446 305 1447 1448 1449 1450 1451 1452 1453 306 1454 1455 1456 307 1457 1458 1459 308 1460 1461 1462 309 1463 1464 1465 310 1466 1467 1468 311 1469 1470 1471 1472 1473 1474 1475 312 1476
1477 1478 1479 1480 1481 1482 313 1483 1484 1485 314 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 315 1497 1498 1499 316 1500 1501 1502 1503 1504 1505 1506 317 1507 1508 1509 318 1510 1511 1512 319 1513 1514 1515 320 1516 1517 1518 321 1519 1520 1521 322 1522 1523 1524 1525 1526 1527 1528 323 1529
1530 1531 1532 1533 1534 1535 324 1536 1537 1538 325 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 326 1550 1551 1552 327 1553 1554 1555 1556 1557 1558 1559 328 1560 1561 1562 329 1563 1564 1565 330 1566 1567 1568 331 1569 1570 1571 332 1572 1573 1574 333 1575 1576 1577 1578 1579 1580 1581 334 1582
1583 1584 335 336 337 338 339 1585 1586 1587 340 341 342 343 344 1588 1589 1590 345 346 347 348 349 1591 1592 1593 350 351 352 353 354 1594 1595 1596 355 1597 1598 1599 356 357 358 359 360 1600 1601 1602 361 1603 1604 1605 362 363 364 365 366 1606 1607 1608 367 368 369 370 371 1609
1610 1611 372 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 373 1623 1624 1625 374 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 375 1637 1638 1639 376 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 377 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 378 1662 1663 1664 1665 1666
1667 1668 379 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 380 1680 1681 1682 381 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 382 1694 1695 1696 383 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 384 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 385 1719 1720 1721 1722 1723
1724 1725 386 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 387 1737 1738 1739 388 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 389 1751 1752 1753 390 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 391 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 392 1776 1777 1778 1779 1780
1781 1782 393 1783 1784 1785 394 395 396 397 398 1786 1787 1788 399 1789 1790 1791 400 1792 1793 1794 401 402 403 404 405 1795 1796 1797 406 1798 1799 1800 407 408 409 410 411 1801 1802 1803 412 413 414 415 416 1804 1805 1806 417 418 419 420 421 1807 1808 1809 422 423 424 425 426 1810
1811 1812 427 1813 1814 1815 428 1816 1817 1818 429 1819 1820 1821 430 1822 1823 1824 431 1825 1826 1827 432 1828 1829 1830 433 1831 1832 1833 434 1834 1835 1836 1837 1838 1839 1840 435 1841 1842 1843 436 1844 1845 1846 1847 1848 1849 1850 437 1851 1852 1853 438 1854 1855 1856 1857 1858 1859 1860 439 1861
1862 1863 440 1864 1865 1866 441 1867 1868 1869 442 1870 1871 1872 443 1873 1874 1875 444 1876 1877 1878 445 1879 1880 1881 446 1882 1883 1884 447 1885 1886 1887 1888 1889 1890 1891 448 1892 1893 1894 449 1895 1896 1897 1898 1899 1900 1901 450 1902 1903 1904 451 1905 1906 1907 1908 1909 1910 1911 452 1912
1913 1914 453 1915 1916 1917 454 1918 1919 1920 455 1921 1922 1923 456 1924 1925 1926 457 1927 1928 1929 458 1930 1931 1932 459 1933 1934 1935 460 1936 1937 1938 1939 1940 1941 1942 461 1943 1944 1945 462 1946 1947 1948 1949 1950 1951 1952 463 1953 1954 1955 464 1956 1957 1958 1959 1960 1961 1962 465 1963
1964 1965 466 467 468 469 470 1966 1967 1968 471 472 473 474 475 1969 1970 1971 476 477 478 479 480 1972 1973 1974 481 482 483 484 485 1975 1976 1977 486 487 488 489 490 1978 1979 1980 491 492 493 494 495 496 497 498 499 1981 1982 1983 500 501 502 503 504 505 506 507 508 1984
1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 509 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047
+9
View File
@@ -0,0 +1,9 @@
8 8 13
13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28
29 30 0 31 32 33 1 34
35 36 2 37 38 39 3 40
41 42 4 43 44 45 5 46
47 48 6 49 50 51 7 52
53 54 8 9 10 11 12 55
56 57 58 59 60 61 62 63
+17
View File
@@ -0,0 +1,17 @@
16 16 61
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
93 94 0 95 96 97 1 2 3 4 5 6 7 8 9 98
99 100 10 101 102 103 11 104 105 106 107 108 109 110 12 111
112 113 13 114 115 116 14 117 118 119 120 121 122 123 15 124
125 126 16 127 128 129 17 130 131 132 133 134 135 136 18 137
138 139 19 20 21 22 23 140 141 142 24 25 26 27 28 143
144 145 146 147 148 149 150 151 152 153 29 154 155 156 157 158
159 160 161 162 163 164 165 166 167 168 30 169 170 171 172 173
174 175 176 177 178 179 180 181 182 183 31 184 185 186 187 188
189 190 32 33 34 35 36 191 192 193 37 38 39 40 41 194
195 196 42 197 198 199 43 200 201 202 203 204 205 206 44 207
208 209 45 210 211 212 46 213 214 215 216 217 218 219 47 220
221 222 48 223 224 225 49 226 227 228 229 230 231 232 50 233
234 235 51 236 237 238 52 53 54 55 56 57 58 59 60 239
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
+33
View File
@@ -0,0 +1,33 @@
32 32 253
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316
317 318 0 319 320 321 1 2 3 4 5 6 7 8 9 322 323 324 10 11 12 13 14 15 16 17 18 325 326 327 19 328
329 330 20 331 332 333 21 334 335 336 337 338 339 340 22 341 342 343 23 344 345 346 347 348 349 350 24 351 352 353 25 354
355 356 26 357 358 359 27 360 361 362 363 364 365 366 28 367 368 369 29 370 371 372 373 374 375 376 30 377 378 379 31 380
381 382 32 383 384 385 33 386 387 388 389 390 391 392 34 393 394 395 35 396 397 398 399 400 401 402 36 403 404 405 37 406
407 408 38 39 40 41 42 409 410 411 43 44 45 46 47 412 413 414 48 49 50 51 52 415 416 417 53 54 55 56 57 418
419 420 421 422 423 424 425 426 427 428 58 429 430 431 432 433 434 435 436 437 438 439 59 440 441 442 443 444 445 446 447 448
449 450 451 452 453 454 455 456 457 458 60 459 460 461 462 463 464 465 466 467 468 469 61 470 471 472 473 474 475 476 477 478
479 480 481 482 483 484 485 486 487 488 62 489 490 491 492 493 494 495 496 497 498 499 63 500 501 502 503 504 505 506 507 508
509 510 64 65 66 67 68 511 512 513 69 70 71 72 73 514 515 516 74 75 76 77 78 517 518 519 79 80 81 82 83 520
521 522 84 523 524 525 85 526 527 528 529 530 531 532 86 533 534 535 87 536 537 538 539 540 541 542 88 543 544 545 89 546
547 548 90 549 550 551 91 552 553 554 555 556 557 558 92 559 560 561 93 562 563 564 565 566 567 568 94 569 570 571 95 572
573 574 96 575 576 577 97 578 579 580 581 582 583 584 98 585 586 587 99 588 589 590 591 592 593 594 100 595 596 597 101 598
599 600 102 601 602 603 103 104 105 106 107 108 109 110 111 604 605 606 112 113 114 115 116 117 118 119 120 607 608 609 121 610
611 612 122 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 123 640
641 642 124 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 125 670
671 672 126 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 127 700
701 702 128 129 130 131 132 703 704 705 133 134 135 136 137 138 139 140 141 142 143 144 145 706 707 708 146 147 148 149 150 709
710 711 712 713 714 715 151 716 717 718 152 719 720 721 722 723 724 725 726 727 728 729 153 730 731 732 154 733 734 735 736 737
738 739 740 741 742 743 155 744 745 746 156 747 748 749 750 751 752 753 754 755 756 757 157 758 759 760 158 761 762 763 764 765
766 767 768 769 770 771 159 772 773 774 160 775 776 777 778 779 780 781 782 783 784 785 161 786 787 788 162 789 790 791 792 793
794 795 163 164 165 166 167 796 797 798 168 169 170 171 172 799 800 801 173 174 175 176 177 802 803 804 178 179 180 181 182 805
806 807 183 808 809 810 811 812 813 814 815 816 817 818 184 819 820 821 185 822 823 824 825 826 827 828 829 830 831 832 186 833
834 835 187 836 837 838 839 840 841 842 843 844 845 846 188 847 848 849 189 850 851 852 853 854 855 856 857 858 859 860 190 861
862 863 191 864 865 866 867 868 869 870 871 872 873 874 192 875 876 877 193 878 879 880 881 882 883 884 885 886 887 888 194 889
890 891 195 892 893 894 196 197 198 199 200 895 896 897 201 898 899 900 202 901 902 903 203 204 205 206 207 904 905 906 208 907
908 909 209 910 911 912 210 913 914 915 211 916 917 918 212 919 920 921 213 922 923 924 214 925 926 927 215 928 929 930 216 931
932 933 217 934 935 936 218 937 938 939 219 940 941 942 220 943 944 945 221 946 947 948 222 949 950 951 223 952 953 954 224 955
956 957 225 958 959 960 226 961 962 963 227 964 965 966 228 967 968 969 229 970 971 972 230 973 974 975 231 976 977 978 232 979
980 981 233 234 235 236 237 982 983 984 238 239 240 241 242 985 986 987 243 244 245 246 247 988 989 990 248 249 250 251 252 991
992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023
+152
View File
@@ -0,0 +1,152 @@
# Most explosive
Yusuke Endoh
Twitter: @mametter
The code for this entry can be found in prog.c
## Judges' comments:
### To use:
make
./prog
### Try:
# Try resizing the terminal window before the first click.
# Try resizing the terminal window after the first click.
./prog ioccc.txt
./prog unwinnable.txt
### Selected Judges Remarks:
When playing Minesweeper, a misclick might ruin a game, so why not leave the routine to the computer?
This program automatically uncovers mines according to several rules, and leaves guessing (and applying
the most straightforward of the rules -- just for fun, perhaps?) to the user.
Try creating your own input files according to the author's remarks. Did you encounter any problems?
The submission was in violation of the "2053" size rule by one character, likely a late typo. It was easy to fix.
## Author's comments:
### Semi-automatic Minesweeper
Minesweeper is a game to sweep mines, as you know. The task consists of two parts:
A) choose a random cell based on your sixth sense
B) identify a non-mine cell based on logical inference
However, (B) is error-prone, and a waste of time. You must use a computer to do such a boring task!
This program is a semi-automatic minesweeper which does Part (B) automatically.
All you have to do is (A). You can test if you are lucky or not.
#### How to use
It uses ncurses:
$ gcc -o prog prog.c -lncurses
$ ./prog
You will see a terminal-wide field of a minesweeper. Probe a cell by mouse click.
If a cell turns out to have a mine (or not), the program determines whether its neighbors have a mine or not, and automatically probes (or flags) the cell.
* `R`: new game (You can also click the smiley face at the top line.)
* `Q`: quit
#### Internal
The program uses four types of local inference:
#### Rule 1
If the number of a cell is equal to the count of the flagged neighbors, all the unprobed neighbors are probed.
Example:
```
? ? ? . . .
? 3 ? => . 3 .
! ! ! ! ! !
```
Note that `?` is a unprobed cell (it is unknown whether the cell has a mine or not); `!` is a flagged cell (it is already known that the cell has a mine); and `.` is a probed cell (it is already known that the cell has no mine).
#### Rule 2
If the number of a cell is equal to the count of the unprobed or flagged neighbors, all the unprobed neighbors are flagged,
Example:
```
. ? ? . ! !
. 4 ? => . 4 !
. 2 ! . 2 !
```
#### Rule 3
Consider two number cells A and B. If A is equal to the difference of B and the count of B's unprobed and flagged neighbors that are not A's neighbors, all A's unprobed neighbors that are not B's neighbors are probed.
Example:
```
? ? ? . . .
? 1 ? ? => . 1 ? ?
? ? 4 . . ? 4 .
? . ! ? . !
```
A and B are probed cells whose numbers are, respectively, 1 and 4. The count of B's unprobed and flagged neighbors that are not A's neighbors is three (one `!` and two `?`s). Since A (1) == B (4) - the count (3), the left and top unprobed cells are probed.
#### Rule 4
Consider two number cells A and B. If B is equal to the difference of A and the count of A's unprobed and flagged neighbors that are not B's neighbors, all A's unprobed neighbors that are not B's neighbors are flagged.
```
? ? ? ? ! ? ? ?
? 3 1 2 => ! 3 1 2
2 2 . . 2 2 . .
```
A and B are probed cells whose numbers are, respectively, 3 and 1. The count of A's unprobed and flagged neighbors that are not B's neighbors is two (left `?`s). Since B (1) == A (3) - the count (2), the left unprobed cells are flagged.
#### Note
Interestingly, these complex rules can be integrated to one simple rule. Analyze the code.
#### One more thing
You can also play with a prepared map.
$ ./prog ioccc.txt
The format of the text is:
width height number-of-mines priorities-of-each-cell...
There are mines in a cell whose "priorities-of-each-cell" is less than "number-of-mines".
(But the mine in the first-clicked cell is removed.)
#### Bug fixes and Credits
The judges pointed out a bug of the original version that I submitted (prog.orig.c). Because this program does not provide a feature to flag unprobed cells manually, we can do nothing if the number of unprobed cells are equal to the number of mines remaining; unwinnable.txt is an example for such a case.
Thus, I implemented an additional rule to flag all unprobed cells in such a case into the final version (prog.c).
Ilya Kurdyukov also pointed out a warning "ignoring return value of 'fscanf'" only when "-O3" is used. So I changed the code a little to pretend to use the return value of fscanf.
Don Yang (omoikane) contributed another example map "megumin.txt" which is the Explosion Arch-Wizard.
-----------------------------------------------------------------------------------------------------
(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/
-----------------------------------------------------------------------------------------------------
+191
View File
@@ -0,0 +1,191 @@
<!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>Most explosive</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>Most explosive</h1>
<p>Yusuke Endoh<br/>
Twitter: @mametter</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># Try resizing the terminal window before the first click.
# Try resizing the terminal window after the first click.
./prog ioccc.txt
./prog unwinnable.txt
</code></pre>
<h3>Selected Judges Remarks:</h3>
<p>When playing Minesweeper, a misclick might ruin a game, so why not leave the routine to the computer?
This program automatically uncovers mines according to several rules, and leaves guessing (and applying
the most straightforward of the rules &ndash; just for fun, perhaps?) to the user.</p>
<p>Try creating your own input files according to the author&rsquo;s remarks. Did you encounter any problems?</p>
<p>The submission was in violation of the &ldquo;2053&rdquo; size rule by one character, likely a late typo. It was easy to fix.</p>
<h2>Author&rsquo;s comments:</h2>
<h3>Semi-automatic Minesweeper</h3>
<p>Minesweeper is a game to sweep mines, as you know. The task consists of two parts:</p>
<p>A) choose a random cell based on your sixth sense
B) identify a non-mine cell based on logical inference</p>
<p>However, (B) is error-prone, and a waste of time. You must use a computer to do such a boring task!</p>
<p>This program is a semi-automatic minesweeper which does Part (B) automatically.
All you have to do is (A). You can test if you are lucky or not.</p>
<h4>How to use</h4>
<p>It uses ncurses:</p>
<pre><code>$ gcc -o prog prog.c -lncurses
$ ./prog
</code></pre>
<p>You will see a terminal-wide field of a minesweeper. Probe a cell by mouse click.
If a cell turns out to have a mine (or not), the program determines whether its neighbors have a mine or not, and automatically probes (or flags) the cell.</p>
<ul>
<li><code>R</code>: new game (You can also click the smiley face at the top line.)</li>
<li><code>Q</code>: quit</li>
</ul>
<h4>Internal</h4>
<p>The program uses four types of local inference:</p>
<h4>Rule 1</h4>
<p>If the number of a cell is equal to the count of the flagged neighbors, all the unprobed neighbors are probed.</p>
<p>Example:</p>
<p><code>
? ? ? . . .
? 3 ? =&gt; . 3 .
! ! ! ! ! !
</code></p>
<p>Note that <code>?</code> is a unprobed cell (it is unknown whether the cell has a mine or not); <code>!</code> is a flagged cell (it is already known that the cell has a mine); and <code>.</code> is a probed cell (it is already known that the cell has no mine).</p>
<h4>Rule 2</h4>
<p>If the number of a cell is equal to the count of the unprobed or flagged neighbors, all the unprobed neighbors are flagged,</p>
<p>Example:</p>
<p><code>
. ? ? . ! !
. 4 ? =&gt; . 4 !
. 2 ! . 2 !
</code></p>
<h4>Rule 3</h4>
<p>Consider two number cells A and B. If A is equal to the difference of B and the count of B&rsquo;s unprobed and flagged neighbors that are not A&rsquo;s neighbors, all A&rsquo;s unprobed neighbors that are not B&rsquo;s neighbors are probed.</p>
<p>Example:</p>
<p><code>
? ? ? . . .
? 1 ? ? =&gt; . 1 ? ?
? ? 4 . . ? 4 .
? . ! ? . !
</code></p>
<p>A and B are probed cells whose numbers are, respectively, 1 and 4. The count of B&rsquo;s unprobed and flagged neighbors that are not A&rsquo;s neighbors is three (one <code>!</code> and two <code>?</code>s). Since A (1) == B (4) - the count (3), the left and top unprobed cells are probed.</p>
<h4>Rule 4</h4>
<p>Consider two number cells A and B. If B is equal to the difference of A and the count of A&rsquo;s unprobed and flagged neighbors that are not B&rsquo;s neighbors, all A&rsquo;s unprobed neighbors that are not B&rsquo;s neighbors are flagged.</p>
<p><code>
? ? ? ? ! ? ? ?
? 3 1 2 =&gt; ! 3 1 2
2 2 . . 2 2 . .
</code></p>
<p>A and B are probed cells whose numbers are, respectively, 3 and 1. The count of A&rsquo;s unprobed and flagged neighbors that are not B&rsquo;s neighbors is two (left <code>?</code>s). Since B (1) == A (3) - the count (2), the left unprobed cells are flagged.</p>
<h4>Note</h4>
<p>Interestingly, these complex rules can be integrated to one simple rule. Analyze the code.</p>
<h4>One more thing</h4>
<p>You can also play with a prepared map.</p>
<pre><code>$ ./prog ioccc.txt
</code></pre>
<p>The format of the text is:</p>
<pre><code>width height number-of-mines priorities-of-each-cell...
</code></pre>
<p>There are mines in a cell whose &ldquo;priorities-of-each-cell&rdquo; is less than &ldquo;number-of-mines&rdquo;.
(But the mine in the first-clicked cell is removed.)</p>
<h4>Bug fixes and Credits</h4>
<p>The judges pointed out a bug of the original version that I submitted (prog.orig.c). Because this program does not provide a feature to flag unprobed cells manually, we can do nothing if the number of unprobed cells are equal to the number of mines remaining; unwinnable.txt is an example for such a case.
Thus, I implemented an additional rule to flag all unprobed cells in such a case into the final version (prog.c).</p>
<p>Ilya Kurdyukov also pointed out a warning &ldquo;ignoring return value of &lsquo;fscanf&rsquo;&rdquo; only when &ldquo;-O3&rdquo; is used. So I changed the code a little to pretend to use the return value of fscanf.</p>
<p>Don Yang (omoikane) contributed another example map &ldquo;megumin.txt&rdquo; which is the Explosion Arch-Wizard.</p>
<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 @@
25 9 44 80 44 101 194 220 134 60 144 183 223 149 81 131 59 55 146 57 113 114 63 75 135 91 52 177 99 100 192 216 126 54 206 51 106 176 128 85 105 208 104 219 98 205 160 211 197 152 93 204 76 127 171 25 147 173 17 29 40 185 153 30 41 20 132 193 31 33 42 161 186 26 27 9 137 138 48 121 11 108 174 5 190 19 214 133 14 201 50 97 142 4 129 136 74 191 21 199 109 164 130 62 94 28 170 64 7 116 38 182 200 37 123 86 92 215 23 224 112 102 165 18 218 73 178 163 120 124 36 222 148 24 217 22 69 89 16 49 119 158 202 2 187 156 196 212 12 111 175 115 107 169 70 0 79 72 3 34 35 103 77 10 6 1 209 122 13 15 32 56 61 43 39 8 53 78 88 117 207 210 150 71 125 139 87 143 155 141 68 90 65 140 47 203 168 67 84 172 96 195 66 110 162 221 181 166 154 180 198 184 45 95 167 46 145 213 159 189 118 82 151 83 179 157 188 58
+36
View File
@@ -0,0 +1,36 @@
64 35 363
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 0 1 2 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 3 4 5 587 588 589 6 7 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610
611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 8 9 10 643 644 645 646 647 648 649 650 11 12 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669
670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 13 14 15 699 700 701 702 703 704 705 706 707 708 709 710 711 16 17 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728
729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 18 19 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 20 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789
790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 21 22 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 23 24 836 837 838 839 840 841 842 843 844 845 846 847 848 849
850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 25 26 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 27 898 899 900 901 902 903 904 905 906 907 908 909 910
911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 28 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 29 961 962 963 964 965 966 967 968 969 970 971 972
973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 30 31 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 32 33 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032
1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 34 35 36 37 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 38 1083 1084 1085 1086 1087 1088 1089 1090 1091
1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 39 1110 1111 40 41 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 42 43 44 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 45 1141 1142 1143 1144 1145 1146 1147 1148
1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 46 47 48 1166 1167 1168 1169 49 50 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 51 52 53 54 55 1181 1182 1183 1184 1185 56 57 58 59 1186 1187 1188 1189 1190 60 1191 1192 1193 1194 1195 1196 1197
1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 61 62 1215 1216 1217 63 64 65 66 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 67 68 69 1230 1231 1232 1233 1234 1235 1236 70 1237 1238 71 72 73 74 1239 1240 75 1241 1242 1243 1244 1245 1246
1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 76 1267 1268 77 78 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 79 1283 1284 1285 80 1286 1287 1288 1289 81 1290 1291 1292 1293 1294 1295 1296 1297 1298 82 1299 1300 1301 1302 1303
1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 83 1320 1321 84 85 1322 1323 86 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 87 88 1334 1335 1336 1337 1338 1339 89 90 91 1340 1341 1342 92 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 93 94 1353 1354 1355
1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 95 96 1371 1372 1373 97 98 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 99 100 101 1386 1387 1388 1389 102 103 104 105 1390 1391 1392 1393 106 1394 1395 1396 1397 1398 1399 107 1400 1401 1402 108 1403 1404 1405
1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 109 110 111 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 112 113 114 115 1437 1438 1439 1440 116 117 118 1441 1442 1443 1444 119 1445 1446 1447 1448 1449 120 1450 1451 1452 1453 1454 121 1455 1456
1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 122 123 124 125 126 127 1468 128 129 130 1469 1470 131 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 132 133 134 1481 1482 1483 1484 1485 1486 135 1487 1488 1489 1490 1491 136 1492 1493 1494 1495 1496 137 1497 138 1498 139 1499 140 1500 1501
1502 1503 1504 1505 1506 1507 1508 1509 141 142 143 1510 1511 1512 1513 144 145 1514 146 147 1515 1516 1517 1518 148 149 150 1519 1520 1521 1522 1523 1524 1525 1526 151 1527 1528 1529 152 153 1530 1531 1532 1533 1534 1535 1536 1537 154 1538 1539 1540 1541 1542 155 1543 1544 1545 1546 1547 156 1548 1549
1550 1551 1552 1553 1554 1555 157 158 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 159 1566 1567 160 1568 161 162 163 164 165 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 166 167 168 169 1579 1580 1581 1582 1583 1584 1585 170 171 1586 1587 1588 1589 1590 172 1591 173 1592 174 175 1593 1594
1595 1596 1597 176 177 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 178 179 180 181 1612 1613 182 183 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 184 185 186 187 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 188 1639 1640 1641 1642 189 1643 1644
1645 1646 190 191 192 193 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 194 195 196 197 1660 1661 1662 1663 1664 1665 1666 1667 198 199 200 201 202 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 203 1681 1682 1683 1684 1685 1686 204 1687 1688 205 1689 206 1690 1691
1692 1693 1694 1695 207 208 209 210 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 211 212 213 1709 1710 1711 214 215 216 1712 1713 217 218 219 220 1714 1715 221 222 1716 1717 1718 1719 1720 1721 1722 1723 223 224 1724 1725 1726 1727 1728 1729 1730 225 1731 1732 1733 226 1734 1735
1736 1737 1738 1739 1740 1741 227 228 229 230 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 231 232 233 234 1759 1760 235 236 1761 237 238 239 240 1762 1763 1764 1765 1766 241 1767 1768 242 243 244 1769 1770 1771 1772 1773 1774 245 246 1775 1776 247 1777 1778
1779 1780 1781 1782 1783 1784 1785 1786 248 249 250 251 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 252 253 1804 1805 1806 1807 254 255 256 257 258 259 1808 1809 1810 260 261 262 1811 1812 1813 263 1814 1815 1816 1817 1818 1819 1820 264 265 1821 266 1822 1823
1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 267 268 269 270 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 271 1850 1851 1852 1853 272 273 274 275 276 277 1854 1855 278 279 280 281 282 1856 1857 1858 283 284 1859 1860 1861 1862 1863 1864 1865 285 1866 1867 1868
1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 286 287 288 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 289 290 291 292 293 1909 1910 1911 1912 1913 294 295 1914 1915 1916 1917 1918 1919 1920 1921 1922
1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 296 297 298 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 299 300 1975 1976 1977 1978 1979 1980 1981
1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 301 302 303 304 305 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 306 307 308 2034 2035 2036 2037
2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 309 310 311 312 313 314 315 316 317 318 319 320 321 322 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 323 324 325 326 327 328 329 330 331 2075 2076 2077 2078
2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 2104 2105 2106 2107 2108 2109 2110 2111
2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175
2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239
+39
View File
@@ -0,0 +1,39 @@
#include/**/<time.h>
#include <ncurses.h>
# include <stdlib.h>
/** */#define O()for(y-= !!\
y;y<H&& /*...Semi-Automatic.*/y< p/W+2;\
y++)for(x=p% W,x-=!!/*..MineSweeper...*/x;x<W&& x<p%W+2;x++)
#define _(x,y)COLOR_##x,COLOR_##y /* click / (R)estart / (Q)uit */
#define Y(n)attrset(COLOR_PAIR(n)),mvprintw(/* IOCCC2019 or IOCCC2020 */
typedef int I;I*M,W,H,S,C,E,X,T,c,p,q,i,j,k;char G[]=" x",U[256];I F(I p){ I
r=0,x,y=p/W,q;O()q=y*W+x,r+=M[q]^=p-q?(M[q]&16)<<8:0;return r;}I K(I p
,I f,I g){ I x=(g+ f/256)%16-(f+g/256)%16,y=p/W,c=0,n=g/4096
,m=x==n?0:x==g /16%16-f/16%16-n?256:-1; if(m+1)O()if
((4368&M[n=y*W +x])==4112){ M[c=1,n]=(M[n]&~16)|m; }
return c;}void D(){I p,k,o=0,n=C,m=0,q=0;if(LINES-1<H
||COLS/2<W)clear (),Y(4)LINES/2,COLS/2-16,"Make the ter\
minal bigger!");else{for (p=0;p<S;o+=k==3,Y(k)p/W+1,p%W*2,G),p++)G[1]=""
"_*!..12345678"[k=E?256&M[p ]?n--,2:E-2||M[p]%2<1?M[p]&16?q=p,m++,3:4+F(p)%16:
1:3];k=T+time(0);T=o||T>=0||E-1?T:k;k=T<0?k:T;Y(7)0,0,"%03d%*s%03d",n>999?999:n,W*
2-6,"",k>999?999:k);Y(9)0,W-1,E>1?"X-(":E-1||o?":-)":"8-)");M[q]|=256*(n==m&&n); }
refresh();}short B[]={_(RED,BLACK),_(WHITE,BLUE),_(GREEN,RED),_(MAGENTA,YELLOW),_(
CYAN,RED)};I main(I A,char**V){MEVENT e;FILE*f;srand(time(0));initscr();for(start\
_color();X<12;X++){init_pair(X+1,B[X&&X<10?X-1:2],B[X?X<3?2:1:0]);}noecho();cbreak
();timeout(9);curs_set(0);keypad(stdscr,TRUE);for(mousemask(BUTTON1_CLICKED|BUTTO\
N1_RELEASED,0);;){S=A<2?f=0,W=COLS/2,H=LINES-1,C=W*H/5,0:fscanf(f=fopen(V[A-1],"r"
),"%d %d %d",&W,&H,&C)>3; ;S+=W*H;M=realloc(M,S*sizeof(I)*2);for(i=0
;i<S;i++)!f?M[i]=i,i&&(k=M[j=rand()%i],M[j]=M[i],M[i]=k):fscanf(f,
"%d",M+i);if(f)fclose(f);T=E=X=0;for(clear();D(),c=getch(),c-'r'
&&(c-KEY_RESIZE||E);){ if(c=='q'){ return(endwin(),0); }if(c==
KEY_MOUSE&&getmouse(&e)==OK&&e.x/2<W&&e.y<=H){if(!e.y&&(W-2<e.x&&
e.x<W+2)){break;}p=e.x/2+e.y*W-W;if(p>=0){if(!E){for(i=0;i<S;i++)M[S+M
[i]]=i,M[i]=16+(M[i]<C);C-=M[p]&1;M[p]=16;E=1;T=-time(0);}if(E<2)M[p]&=(M[p]
&257)==1?T+=time(0),E=2,273:257;}}for(p=0;p<S&&E==1;M[p++]&=273){}for(i=
(X+S-1)%S;E==1&&i!=X;X=(X+1)%S){if(!(M[p=M[X+S]]&272)){if(K(p,c=F(p)
,0)){goto N;} for(k=p/W-2,k=k<0?0:k;k<p/W+3&&k <H;k++)for(j=
p%W-2,j =j<0?0:j;j<W&&j<p%W+3;)if (!(M[q=
k*W +j++]&272)){ if(K(p, c,F
(q))){ goto N; }F(q)
; }F(p); }}N:; } } }
/*(c)Yusukse Endoh*/
+39
View File
@@ -0,0 +1,39 @@
#include/**/<time.h>
#include <ncurses.h>
# include <stdlib.h>
/** */#define O()for(y-= !!\
y;y<H&& /*semi-automatic----*/y< p/W+2;\
y++)for(x=p% W,x-=!!/*-----minesweeper*/x;x<W&& x<p%W+2;x++)
#define _(x)COLOR_##x/*IOCCC2019IOCCC2019IOCCC2019IOCCC2019IOCCC20*/
#define Y(n)attrset(COLOR_PAIR(n)),mvprintw/*IOCCC2019IOCCC2019IOCCC20*/
int*M,W,H,S,C,E,X,T,c,p,q,i,j,k;char G[]=" x",U[256];int F(int p){int r=0,x,
y=p/W,q;O()q=y*W+x,r+=M[q]^=p-q?(M[q]&16)<<8:0;return r;}int K( int p,
int f,int g){int x=(g+f/256)%16-(f+g/256)%16,y=p/W,c=0,n=
g/4096,m=x==n ?0:x==g/16%16-f/16%16-n?256:-1;if(m+
1)O()if((M[n= y*W+x]&4368)==4112)M[n]=(M[n]&~16)|m
,c++;return c; }void D(){int p,k,o=0,n=C;if(LINES-1<
H||COLS/2<W)/*| */clear(),Y(4)(LINES/2,COLS/2-16,"Mak\
e the terminal window " "bigger!");else{for(p=0;p<S;o+=k==3,Y(k)(p/W+1
,p%W*2,G),p++)G[1]="_*!.." "12345678"[k=E?M[p]&256?n--,2:E-2||M[p]%2<1?M[p]&
16?3:4+F(p)%16:1:3];k=T+time(0);T=o||T>=0||E-1?T:k;k=T<0?k:T;Y(7)(0,0,"%03d%*s%03\
d",n>999?999:n,W*2-6,"",k>999?999:k);Y(9)(0,W-1,E>1?"X-(":E-1||o?":-)":"[-)");}re\
fresh();}int main(int A,char**V){short B[]={_(RED),_(BLACK),_(WHITE),_(BLUE),_(GR\
EEN),_(RED),_(MAGENTA),_(YELLOW),_(CYAN)};MEVENT e;FILE*f;srand(time(0));initscr()
;for(start_color();X<12;X++)init_pair(X+1,B[X&&X<10?X-1:2],B[X?X<3?2:1:0]);noecho(
);cbreak();timeout(9);curs_set(0);keypad(stdscr,TRUE);for(mousemask(BUTTON1_CLICK\
ED|BUTTON1_RELEASED,0);;){if(A-->1){f=fopen(V[A],"r");fscanf(f,"%d %d %d",&W,&H,&C
);}else{f=0;W=COLS/2;H=LINES-1;C=W*H/5;}S=W*H;M=realloc(M,S*2*sizeof
(int));for(i=0;i<S;i++)!f?M[i]=i:fscanf(f,"%d",M+i);for(i=0;!f&&i<
S;i++)k=M[j=i+rand()%(S-i)],M[j]=M[i],M[i]=k;if(f)fclose(f);T=E=
X=0;for(clear();D(),c=getch(),c-'r'&&(c-KEY_RESIZE||E);){if (c
=='q')return(endwin(),0);if(c==KEY_MOUSE&&getmouse(&e)==OK&&e.x/
2<W&&e.y<=H){if(!e.y&&(W-2<e.x&&e.x<W+2))break;p=e.x/2+e.y*W-W;if(p>=0
){if(!E){for(i=0;i<S;i++)M[S+M[i]]=i,M[i]=16+(M[i]<C);C-=M[p]&1;M[p]=16;E=1;
T=-time(0);}if(E<2)M[p]&=(M[p]&257)==1?T+=time(0),E=2,273:257;}}for(p=0;
p<S&&E==1;)M[p++]&=273;for(i=(X+S-1)%S;E==1&&i!=X;X=(X+1)%S){if(!(M[
p=M[X+S]]&272 )){if(K(p,c=F(p),0))goto N;for(k =p/W-2,k=k<0?
0:k;k<H &&k<p/W+3;k++)for(j=p%W-2 ,j=j<0?
0:j ;j<W&&j<p%W+3;j++)if (!(
M[q=j+k*W]&272)){if(
K(p,c,F(q)))goto N;F
(q);}F(p);}}N:;}}}
+6
View File
@@ -0,0 +1,6 @@
5 5 4
0 1 5 6 4
2 3 7 8 9
10 11 12 13 14
15 16 17 18 19
20 21 22 23 24