Skip to content

Instantly share code, notes, and snippets.

# before
if is_solved(square):
print("| {} ".format(solution(square)), end='')
else:
print("| ", end='') # unknown remains empty
# after
fill = str(solution(square)) if is_solved(square) else " "
print("| {} ".format(fill), end='')
# Sudoku! No solving, just getting started.
def init_board(template):
"""Given a template, returns a list of list of sets. The 2D grid
represents the board, and the sets represent remaining possible
values for that square.
Parameters
----------
/*
* Simple Test program for libtcc
*
* libtcc can be useful to use tcc as a "backend" for a code generator.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "libtcc.h"
@ChadSki
ChadSki / weap.py
Created March 5, 2016 23:44
Plugin Comparison
from basicstruct import field
from halolib.structs.halostruct import define_halo_struct
from halolib.structs import halofield
tag_types['weap'] = define_halo_struct(struct_size=0x504,
model=halofield.TagReference(offset=0x28),
animation=halofield.TagReference(offset=0x38),
collision=halofield.TagReference(offset=0x70),
physics=halofield.TagReference(offset=0x80),
magazines=halofield.StructArray(offset=0x4F0, struct_size=112,
@ChadSki
ChadSki / post635976.md
Created October 24, 2014 01:48
Discussion of the Implementation of No-Lead in SAPP

SAPP 5.0 Is out, by now every1 should got it by auto-update.

There are 1 main change in the engine, that hooking is now totally rewritten, code is more clear and hooking is faster. This means Sapp is some step closer to port to HPC. Sapp also got 2 new feature: arguments for custom commands and The no-lead mod. =)

Arguments for custom commands: Between the command name and the command, you can put arguments starting with the '#' character. Example: You add to the commands.txt the max #n 'sv_maxplayers #n' line and you execute the max 4 command, sapp will execute the sv_maxplayers 4 command. Or spawnw #n #weap 'spawn weap "weapons#weap#weap" #n; wadd #n' and you execute the spawnw 4 "sniper rifle" it will execute the spawn weap "weapons\sniper rifle\sniper rifle" 4 and the wadd 4 command, and gives a sniper for player 4. Here I had to note that lately kids using sapp to cheat on scrims. There is a feature to fix this already:

import field
from structs import BasicStruct, HaloStruct
MapHeader = \
BasicStruct("MapHeader",
integrity=field.Ascii(offset=0, length=4, reverse=True),
game_version=field.UInt32(offset=4),
map_size=field.UInt32(offset=4),
index_offset=field.UInt32(offset=16),
metadata_size=field.UInt32(offset=20),
@ChadSki
ChadSki / kyloren.md
Last active December 31, 2015 20:35
STAH WAHS

Deleted scene with important dialogue between Snoke and Ren

“Kylo Ren, I watched the Galactic Empire rise, and then fall. The gullible prattle on about the triumph of truth and justice, of individualism and free will. As if such things were solid and real instead of simple subjective judgments. The historians have it all wrong. It was neither poor strategy nor arrogance that brought down the Empire. You know too well what did.” Ren nodded once. “Sentiment.” “Yes. Such a simple thing. Such a foolish error of judgment. A momentary lapse in an otherwise exemplary life. Had Lord Vader not succumbed to emotion at the crucial moment—had the father killed the son—the Empire would have prevailed. And there would be no threat of Skywalker’s return today.” Ren has this interesting concept of being seduced by the light side of the force

kinda inverse Luke

@ChadSki
ChadSki / gist:7251222
Created October 31, 2013 15:02
Open Sauce SLOC
D:\Users\Chad\Downloads> .\cloc-1.60.exe .\open-sauce-0260d0c62a2d
1980 text files.
1886 unique files.
836 files ignored.
http://cloc.sourceforge.net v 1.60 T=4.14 s (373.4 files/s, 91464.7 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
C# 593 19588 33592 117596
@ChadSki
ChadSki / gist:7012482
Created October 16, 2013 18:28
List Comprehensions
index_entries = []
for i in range(index_header.tag_count):
ie = IndexEntry(
FileAccess(
IndexEntry.struct_size * i + index_location,
IndexEntry.struct_size),
map_magic,
halomap)
index_entries.append(ie)
@ChadSki
ChadSki / gist:6912939
Created October 10, 2013 04:12
load_map_common proposal
def load_map_common(access_type, map_path=None):
# access_type is either 'file' or 'mem'
halomap = {
'file': lambda: HaloMap(open(map_path, 'r+b')),
'mem': lambda: HaloMap(None)
}[access_type]()
# class for reading/writing bytes to a delineated area
ByteAccess = {