Skip to content

Instantly share code, notes, and snippets.

View amakukha's full-sized avatar

Andriy Makukha amakukha

  • Toronto
View GitHub Profile
@saweiss
saweiss / Phase1Contest2020.dyalog
Created August 9, 2020 17:18
Dyalog APL Contest 2020 solutions as submitted by Sam Weiss
P1←(1≠(×⊣))⌽↑{⊆⍺⍵}↓
P2←(128∘>∨191∘<)⊂⊢
P3←26⊥⎕A∘⍳
P4←≠⌿0=400 100 4∘.|⊢
P5←⊢{⍵,⍵-(××⍳∘|)-/⍺}⊃
P6←(⊣(⌿⍨)(+⌿=))⍪~⍨
P7←{⍺=2⊥∧/(2∘⊥⍣¯1)⍺⍵}
P8←¯1∧.=2×/(×2-/10∘⊥⍣¯1)
P9←{1∧.=≢∘∪¨⊆⍨2@(¯1∘=)×0~⍨(+\⍣¯1)⍵}
P10←↑((⊢⍴⍨(×/⍴))~((⊂' '⍴⍨(⍴⊃))))∘(↓(↑⍕¨))
@rodrigogiraoserrao
rodrigogiraoserrao / P9Phase2_2020.dyalog
Created August 6, 2020 16:19
RGS's array-oriented solution to Problem 9, Phase 2 of 2020 APL competition (see https://mathspp.com/blog/2020-apl-competition for my thoughts on it)
⍝ PROBLEM 9.1, array-oriented solution, faster for the 3 examples provided.
Weights ← {
(⎕IO ⎕ML ⎕WX) ← 0 1 3
⍝ Reads the mobile data from the file ⍵ and returns its weights.
⍝ Monadic function expecting a character vector and returning an integer vector.
⍝ Returns the weights ordered from left to right, top to bottom.
⍝ How it works:
⍝ We will build a square coefficient matrix where each variable is the weight of a left (┌) or right (┐) corner.
⍝ Let's say n is the number of leafs in the mobile; then n is also the number of pivots and by the lengths of the arms
@karpathy
karpathy / min-char-rnn.py
Last active April 23, 2024 17:55
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@FiloSottile
FiloSottile / 32.asm
Last active March 23, 2024 12:28
NASM Hello World for x86 and x86_64 Intel Mac OS X (get yourself an updated nasm with brew)
; /usr/local/bin/nasm -f macho 32.asm && ld -macosx_version_min 10.7.0 -o 32 32.o && ./32
global start
section .text
start:
push dword msg.len
push dword msg
push dword 1
mov eax, 4
@Ricket
Ricket / brainfucc.c
Created April 24, 2011 16:47
Brainfuck to C translator
/*
* A simple, non-optimizing brainfuck to C translator.
* 2010-08-31 - Version 1.0 (Cory Burgett)
*
* This code is hereby placed into the public domain.
*
* Originally located at: http://www4.ncsu.edu/~cmburget/brainfucc.c
*/
#include <stdio.h>