Skip to content

Instantly share code, notes, and snippets.

@talbergs
talbergs / index.php
Created January 9, 2020 19:13
100 balls, 10 colors and 10 buckets each of whom can hold 10 balls of one or two color kind problem
<?php
// 10 buckets and 10 types of color and 100 balls
// Each color will have at least one ball.
// Each bucket can hold up to ten balls (in result).
// Place all balls in buckets so that each bucket at most containst two variants of color.
// This function should return list of buckets.
// Each bucket is a list of color ids (integers).
$scale = 10;
@talbergs
talbergs / nc.php
Last active October 21, 2022 22:27 — forked from miguelmota/nc.php
PHP send message to socket server (netcat)
<?php
$payload = 'hello world';
$stream = stream_socket_client("tcp://127.0.0.1:5555", $errno, $errstr);
if (!$stream) {
echo "{$errno}: {$errstr}\n";
die();
}
fwrite($stream, $payload);
stream_socket_shutdown($stream, STREAM_SHUT_WR);