This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Decription: A simulation of the cycle-following strategy for the 100-prisoners problem (https://en.wikipedia.org/wiki/100_prisoners_problem), which provides a survival probability of more than 30%. | |
Author: Abhinav Bhatia <[email protected]> | |
""" | |
using Random | |
using Base.Threads: @threads, Atomic, atomic_add! | |
"""returns whether successful or not""" | |
function simulate_cycle_strategy_for_all_prisoners(game::Vector{Int})::Bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Flux | |
using Flux: update! | |
using Zygote | |
using StatsBase | |
""" | |
WGAN with gradient penalty. See algorithm 1 in https://proceedings.neurips.cc/paper/2017/file/892c3b1c6dccd52936e27cbd0ff683d6-Paper.pdf. The following code is almost line by line identical. | |
""" | |
function train_WGAN_GP(𝐺, 𝐷, 𝐗::Array{Float32, N}, latent_size, num_iters, device_fn; m=32, λ=10f0, ncritic=5, α=0.0001, β₁=0, β₂=0.9) where N | |
n = size(𝐗)[end] # length of dataset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
A script to Fourier-ize drawings made using mouse/stylus. Or simply generate random art. | |
Author: Abhinav Bhatia | |
Email: [email protected] | |
Examples: https://i.imgur.com/c5EKAh6.gif, https://i.imgur.com/kpYHxho.gif | |
''' | |
import sys | |
import time | |
import numpy as np | |
import matplotlib.pyplot as plt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void rotateRight90(int* sourceArray, int* destArray, int side) | |
{ | |
int srcY, srcX, destY, destX, elem; | |
for (srcY = 1; srcY <= side; srcY++) | |
{ | |
for (srcX = 1; srcX <= side; srcX++) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "linklist.h" | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
LinkList linkList_createNew(int(*comparator) (void*, void*)) | |
{ | |
LinkList ll; | |
ll.head = NULL; | |
ll.tail = NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "DFA.h" | |
#include <stdlib.h> | |
#include <string.h> | |
void dfa_makeNextTransition(DFA* dfa, char c) | |
{ | |
int transitionID; | |
DFAState* pCurrentState = dfa->states[dfa->currentStateID]; | |
for (transitionID = 0; transitionID < pCurrentState->numberOfTransitions; transitionID++) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
struct _Node; | |
typedef struct _Node Node; | |
struct _Node | |
{ |