Skip to content

Instantly share code, notes, and snippets.

Largest submatrix problem

A problem found on Linkedin.

Find the submatrix with the largest sum.

Example given:

A =
@hholst80
hholst80 / sumprod.m
Created August 14, 2018 11:44
summa produkt pussel
K = 100;
A = zeros(K);
B = zeros(K);
for x = 2:K
for y = 2:K
A(x,y) = x + y;
B(x,y) = x * y;
end
end
import time
import concurrent.futures
def worker(n):
time.sleep(n)
return 42
with concurrent.futures.ThreadPoolExecutor() as extor:
@hholst80
hholst80 / README-dev.md
Last active January 29, 2017 22:07
Development

Python

pip install a github repository

pip install git+https://github.com/hholst80/gym-air

It is also possible to pip install from a private repository using deploy keys, see:

@hholst80
hholst80 / dos
Created January 28, 2017 23:24
Docker on Steriods
#!/bin/bash
# trap "{ echo killing $$ > $HOME/test.log; }" SIGHUP
CID=$(docker run -tid alpine:latest /bin/sh -c "/bin/sleep 3600")
trap "{ docker stop $CID && docker rm $CID; }" SIGHUP
docker attach $CID
@hholst80
hholst80 / README-centos7.md
Last active January 28, 2017 15:32
Centos 7 notes
# Basic dumb abstraction.
class Base(object):
def name(self):
return self._name
# ....
# MegaBase: an abstraction that we can work with.
# Classic OO and derived from Base.
/* strtab.c */
#include <stdlib.h>
#include <stdio.h>
char *base = "";
#define STRING_ADDRESS(id) (base+id)
#define STRING_ID(address) (signed short)((address)-base)
signed short foo(void)