Looking for my 🎄 Advent of Code solutions? 🔗 https://code.up8.edu/pablo/aoc (mostly in 🐫 OCaml, using ocamllex)
This is an attempt to see how small a pure HTML playable TicTacToe game can be. The first script (ttt.py) generates a 560KB HTML file.
- The game is playable at https://pablo.rauzy.name/dev/ttt.html
I made it in reaction to this Hacker News post: Implementing Tic Tac Toe with 170MB of HTML – No JavaScript or CSS, because my reaction to "170MB" was "wait, WAT?".
The second script (ttt_smaller.py) is an attempt to go further, by shortening IDs to maximum 2 chars rather than using 9 characters for full board descriptions as IDs. It does so by using a custom base74, because 74 + 74 × 74 = 5550 which is just above the 5478 game states that have to be represented.
This optimization allows to get down to 412KB, that is a saving of 148Ko, i.e., a 26% size-reduction!
| ### Pablo Rauzy | |
| ### Compsci bachelor / 1st semester / fundamental compsci | |
| ### Lab session 1 : Seven-Segment Display | |
| import sys | |
| import ply.lex as lex | |
| import ply.yacc as yacc | |
| import pygame | |
| ### |
This project is a tiny compiler for a very simple language consisting of boolean expression.
The language has two constants: 1 for true and 0 for false, and 4 logic gates:
! (not), & (and), | (or), and ^ (xor).
It can also use parentheses to manage priorities.
Here is its grammar in BNF format:
expr ::= "0" | "1"
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <strings.h> | |
| #include <unistd.h> | |
| #include <sys/types.h> | |
| #include <sys/socket.h> | |
| #include <netinet/in.h> | |
| #include <errno.h> | |
| int |
| #include <stdlib.h> | |
| #include <stdio.h> | |
| #include <strings.h> | |
| #include <stdint.h> | |
| #include <unistd.h> | |
| #include <sys/socket.h> | |
| #include <netdb.h> | |
| #include <netinet/in.h> | |
| #include <netinet/ip.h> | |
| #include <netinet/ip_icmp.h> |