View magicsquare2.cpp
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <ctime>
#include <omp.h>
#include <unordered_set>
using namespace std;
const char* outputfile = "result";
View magicsquare4.cc
#include <iostream>
const int s = 34;
constexpr int eq(int a, int b) { return a != b ? 0 : a; }
constexpr int check(int used, int x1, int x4, int x13, int x16, int x2, int x3, int x5, int x6, int x7, int x8, int x9, int x10, int x11, int x12, int x14, int x15) {
return (x15 < 1 || x15 > 16) ? 0 :
(((used & (1 << x15)) ? 0 : 1));
}
constexpr int check(int used, int x1, int x4, int x13, int x16, int x2, int x3, int x5, int x6, int x7, int x8, int x9, int x10, int x11, int x12, int x14) {
return (x14 < 1 || x14 > 16) ? 0 :
(((used & (1 << x14)) ? 0 : check(used + (1 << x14), x1, x4, x13, x16, x2, x3, x5, x6, x7, x8, x9, x10, x11, x12, x14, eq(s - x13 - x14 - x16, s - x3 - x7 - x11))));
View magicsquare5.cc
#include <iostream>
const int s = 65;
constexpr int eq(int a, int b) { return a != b ? 0 : a; }
constexpr int check(int used, int x7, int x9, int x17, int x19, int x13, int x1, int x25, int x5, int x21, int x2, int x3, int x4, int x12, int x22, int x24, int x14, int x23, int x8, int x18, int x6, int x10, int x11, int x15, int x16, int x20) {
return (x20 < 1 || x20 > 25) ? 0 :
(((used & (1 << x20)) ? 0 : 1));
}
constexpr int check(int used, int x7, int x9, int x17, int x19, int x13, int x1, int x25, int x5, int x21, int x2, int x3, int x4, int x12, int x22, int x24, int x14, int x23, int x8, int x18, int x6, int x10, int x11, int x15, int x16) {
return (x16 < 1 || x16 > 25) ? 0 :
(((used & (1 << x16)) ? 0 : check(used + (1 << x16), x7, x9, x17, x19, x13, x1, x25, x5, x21, x2, x3, x4, x12, x22, x24, x14, x23, x8, x18, x6, x10, x11, x15, x16, eq(s - x16 - x17 - x18 - x19, s - x5 - x10 - x15 - x25))));
View pythagoras3body.m
(*Mass*)
m = {3, 4, 5};
(*Coordination*)
p = {{px1[t], py1[t]}, {px2[t], py2[t]}, {px3[t], py3[t]}};
q = {{x1[t], y1[t]}, {x2[t], y2[t]}, {x3[t], y3[t]}};
(*Kinetic energy*)
T = Total[MapThread[Total[#2^2]/2/#1 &, {m, p}]];
View pedestrian-eraser.pde
import processing.video.*;
Capture capture;
int t = 0;
int mask = (1 << 8) - 1;
void setup() {
size(640, 480);
background(0);
capture = new Capture(this, 640, 480);
View interactive-mandelbrotsetplot.nb
Manipulate[MandelbrotSetPlot[
{center[[1]] - 10^scale + I (center[[2]] - 10^scale),
center[[1]] + 10^scale + I (center[[2]] + 10^scale)},
MaxIterations -> iterations],
{{center, {-0.5, 0}}, Locator},
{{scale, 0, "Scale"}, -9, 1},
{{iterations, 20, "MaxIterations"}, 10, 2000, 10}]
View onepage-aj16.tex
\documentclass[a4paper]{jsarticle}
\usepackage[top=5mm,right=0mm,bottom=0mm,left=4mm]{geometry}
\usepackage{otf}
\usepackage{color}
\usepackage{pgffor}
\pagestyle{empty}
\openup -0.2mm
\newlength{\unit}
\setlength\unit{1.4mm}
\newcount \i
View floyd.cpp
//Are Toy Problems Useful?
//in Selected Papers on Computer Science by Knuth (p.172)
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_map> // faster than map
#include <algorithm>
View donut.nb
roll = 10;
surface[s_, t_] :=
RotationMatrix[s, {0, 0, 1}].{3 + t Cos[t]/(roll Pi), 0, t Sin[t]/(roll Pi)}
donut[t_] :=
ParametricPlot3D[surface[s, u], {s, 0, 2 Pi}, {u, 0, t},
Axes -> False, Boxed -> False, Mesh -> None, PlotPoints -> 40]
bugs[t_, n_] :=
View primefactorization.nb
factor[n_] := Reverse[Flatten[
Map[Table[#[[1]], {#[[2]]}] &, FactorInteger[n]]]]
On[Assert];
Assert[factor[24] == {3, 2, 2, 2}];
draw[origin_, frame_, delta_, {p_, rest___}, start_] := {
Circle[origin, frame],
With[{r = If[p == 1, 1, frame Sin[Pi/p]/(1 + Sin[Pi/p])]},
Table[