Skip to content

Instantly share code, notes, and snippets.

View payne911's full-sized avatar

payne911

  • Montréal (Canada)
  • 05:31 (UTC -04:00)
View GitHub Profile
@payne911
payne911 / dice_problem.r
Created December 28, 2019 22:07
R program for a small problem: probability to find 3 choices within 6 die-rolls (repetitions allowed, and counted)
roll <- function(rolls=6, die=1:6) {
dice <- sample(die, size = rolls, replace = TRUE)
}
verify <- function(a_roll=roll(), target=c(1,2,3)) {
if(length(a_roll) < length(target)) { # target requires more rolls
return (FALSE)
}
# cat("The roll being processed: ", a_roll, "\n")
for(choice in target) {
@payne911
payne911 / image_integral.py
Last active June 25, 2020 18:50
Convex test on binary images (Image integral for Pattern Matching)
import cv2 as cv
def integral_test(X): # returns True if X is convex
img_t = np.reshape(X, (28, 28)) # preprocess: reshaping
int_result = cv.integral(img_t.astype(np.uint8)) # calculating the integral-image
patterns_to_test = [block_patterns, big_block_patterns, horizontal_patterns, vertical_patterns,
horizontal_patterns2, vertical_patterns2, bigger_block_patterns, horizontal_patterns3,
vertical_patterns3, bbigger_block_patterns, bbbigger_block_patterns, bbbbigger_block_patterns]
for p in range(len(patterns_to_test)): # run test on all patterns until a match is found
@payne911
payne911 / hit_or_miss.py
Last active November 25, 2018 06:37
Pattern matching
# defining/generating all the patterns
pattern1 = np.asarray([[-1, -1, -1, 1],
[ 1, 1, 1, 1]])
pattern2 = np.rot90(pattern1)
pattern3 = np.rot90(pattern2)
pattern4 = np.rot90(pattern3)
pattern5 = np.fliplr(pattern1)
pattern6 = np.rot90(pattern5)
pattern7 = np.rot90(pattern6)
@payne911
payne911 / MainActivity.java
Created August 31, 2018 19:36
Buggy thing
package com.example.payne.simpletestapp.mainActivities;
import android.arch.lifecycle.ViewModelProviders;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.os.Vibrator;