Skip to content

Instantly share code, notes, and snippets.

Avatar
🏀
Rolling around

Vincent Tam VincentTam

🏀
Rolling around
View GitHub Profile
@VincentTam
VincentTam / .gitlab-ci.yml
Last active Aug 26, 2020 — forked from florentchauveau/.gitlab-ci.yml
GitLab CI yaml file for building docker images
View .gitlab-ci.yml
# This is a GitLab CI configuration to build the project as a docker image
# The file is generic enough to be dropped in a project containing a working Dockerfile
# Author: Florent CHAUVEAU <florent.chauveau@gmail.com>
# Mentioned here: https://blog.callr.tech/building-docker-images-with-gitlab-ci-best-practices/
# do not use "latest" here, if you want this to work in the future
image: docker:18
stages:
- build
@VincentTam
VincentTam / mse2192864.mkd
Last active Aug 22, 2020
My answer to a deleted question from WayneXMayersX on math.SE
View mse2192864.mkd

Interpretation of exponentation and permutation

Question

I have $3^3$, can I call it a permutation/permutation with repetition?

As written in here:

@VincentTam
VincentTam / mse2706068.jl
Created Mar 24, 2018
Sum of digits of p^2016 for some prime p
View mse2706068.jl
using Primes
plist = primes(1,10000)
sumdigits(n, base=10) = sum(digits(n, base))
for p in plist[1:100]
sdgit = sumdigits(big(p)^2016)
println("$(p), $(log(p)), $(sdgit)")
if sdgit == 2017
break
end
end
View msetopo.m
figure
title('A connected not path connected set')
hold on
% Plot set A
for i = 1:10
plot([0,1], [0,1/i], "linewidth", 2)
end
% Plot set B
plot([0.5,1],[0,0],'--', "linewidth",2)
@VincentTam
VincentTam / swap.py
Last active Jan 27, 2018
Echange "pythonique" de deux nombres
View swap.py
# input
a = int(input("Donner la valeur de a: "))
b = int(input("Donner la valeur de b: "))
# avant échange
print("a = ",a)
print("b = ",b)
# échange
a, b = b, a
View rrsum.m
Nvec = 10000:10000:1000000; % no of intervals
rrsumvec = zeros(size(Nvec));
for ind = 1:length(Nvec)
N = Nvec(ind);
dx = 5 / N;
x = (1:N) * dx;
fx = sqrt(25 - x.^2);
rrsum(ind) = sum(fx * dx);
end
View 2192864.mkd

My answer to a deleted question Interpretation of exponentation and permutation on math.SE

WayneXMayersX asked this question.

Question

I have $3^3$, can I call it a permutation/permutation with repetition?

@VincentTam
VincentTam / mydual.m
Last active Feb 21, 2017
My Octave dual simplex tableau generator
View mydual.m
# Show dual simplex tableau
# Prereq: matrix A, vectors b,c, basis
printf("Current basis:"); printf(" %2i", basis); disp("");
B = A(:,basis); cB = c(basis);
Bm1A = B\A; xB = B\b; zrow = cB'*Bm1A-c'; zval = cB'*xB;
if length(xB(xB<0)) >= 1
ovp = find(xB==min(xB(xB<0)))(1);
r = zrow./Bm1A(ovp,:); # ratio for display
T = [0:size(A)(2) 0; basis' Bm1A xB; 0 zrow zval; 0 r 0]
# compute min ratio
@VincentTam
VincentTam / mytest.m
Last active Feb 20, 2017
My Octave simplex tableau generator
View mytest.m
# Show simplex tableau
# Prereq: matrix A, vectors b,c, basis
printf("Current basis:"); printf(" %2i", basis); disp("");
B = A(:,basis); cB = c(basis);
Bm1A = B\A; x_B = B\b; zrow = cB'*Bm1A-c'; zval = cB'*x_B;
nv = find(zrow==min(zrow(zrow<=0)))(1);
r = x_B./Bm1A(:,nv);
T = [0:size(A)(2) 0 0; basis' Bm1A x_B r; 0 zrow zval 0]
if length(r(r>=0)) >= 1
ovp = find(r==min(r(r>=0)))(1);
@VincentTam
VincentTam / bday-prblm.c
Last active Jan 27, 2017
Catalan no. & Pascal Triangle use GNU MP
View bday-prblm.c
#include <stdio.h>
float myfct(int i) {
return i == 1? 1 : (366.0-i)/365.0*myfct(i - 1);
}
int main() {
int i;
double ans;
printf("Enter a value: ");