Skip to content

Instantly share code, notes, and snippets.

int swit(int num)
{
switch (num) {
case 0xA1:
case 0xA2:
case 0xA3:
case 0xA4:
case 0xB2:
case 0xB3:
case 0xB4:
#include <stdio.h>
int p(int a, int b) {
(a > b && printf("%d\n", a) && p(a - 1, b)
|| a == b && printf("%d\n", a)
|| a < b && printf("%d\n", b) && p(a, b - 1));
return 0; // Useless return value. Only here to evaluate recursed p().
}
int main(void) {
if (rtn == RESULT_A || rtn == RESULT_B || rtn == RESULT_C || rtn == RESULT_D) {
Do1();
} else {
Do2();
}
switch (rtn) {
case RESULT_A:
case RESULT_B:
case RESULT_C:
@b4284
b4284 / k.c
Created December 30, 2016 06:21
#include <inttypes.h>
void encrypt1(uint8_t *tmp, uint8_t *iv, uint8_t *in, uint32_t len)
{
for (uint_fast32_t pos = 0; pos < len; pos += 8) {
for (uint_fast8_t i = 0; i < 8; i++) {
tmp[i] = in[pos + i] ^ iv[i];
}
}
}
@b4284
b4284 / digit5.ml
Last active December 29, 2016 17:25
(* To build: corebuild digit5.native *)
(* To test-run: seq 10000 99999 |./digit5.native *)
open Core.Std
type t = int Char.Map.t
let empty = Char.Map.empty
let rec read_loop proc =
match In_channel.input_line In_channel.stdin with
@b4284
b4284 / k.c
Created November 30, 2016 10:14
#include <stdio.h>
#include <inttypes.h>
void print_bit(uint8_t c, FILE* s) {
uint_fast8_t i = 8;
AGAIN:
if (i > 0) {
putc(((c & 0x80) ? '1' : '0'), s);
c <<= 1;
open Core.Std
let rec q2 () =
print_endline "Enter a 7-digit number: ";
let input_str = input_line stdin in
if String.length input_str <> 7 then
q2 ()
else
String.to_list input_str
|> List.map ~f:Char.to_string
@b4284
b4284 / q2.c
Created November 22, 2016 16:35
ptt freshman mid-exam question 2
void q2(int n) {
bool shown = false;
char one_zero;
int n2 = 0x80;
CAL:
if (n >= n2) {
n -= n2;
one_zero = '1';
} else {
@b4284
b4284 / k.c
Created November 22, 2016 16:34
void q2(int n) {
bool shown = false;
char one_zero;
int n2 = 0x80;
CAL:
if (n >= n2) {
n -= n2;
one_zero = '1';
} else {
/* -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- */
// DO NOT EDIT THIS FILE, it will be overwritten on update
//
// Default rules for polkit
//
// See the polkit(8) man page for more information
// about configuring polkit.
polkit.addRule(function(action, subject) {