Skip to content

Instantly share code, notes, and snippets.

View flatcap's full-sized avatar

Richard Russon flatcap

View GitHub Profile
L=$((LINES/2))
function f()
{
for A in $(seq $L); do
for B in $(seq $L); do
[ $A -lt $B ] && C=' ' || C=x
echo -n "$C "
done
echo
@flatcap
flatcap / max.awk
Last active August 29, 2015 14:19
galaxywatcher's max field length: http://www.commandlinefu.com/commands/view/14164
#!/usr/bin/awk -f
BEGIN {
FS = "|";
OFS = "|";
}
(NR == 1) {
for (b = 1; b <= NF; b++) {
hdr[b] = $b;
@flatcap
flatcap / hymn.awk
Created April 26, 2015 13:21
Sunday Times Teaser 2742 (2015-04-12)
#!/usr/bin/awk -f
BEGIN {
}
{
top = $1$2$3;
mid = $4$5$6;
bot = $7$8$9;
@flatcap
flatcap / permute.pl
Created April 26, 2015 13:23
Sunday Times Teaser 2744 (2015-04-26)
#!/usr/bin/perl
use strict;
use Algorithm::Permute;
Algorithm::Permute::permute {
print "@ARGV\n";
} @ARGV;
@flatcap
flatcap / puzzle.txt
Created May 10, 2015 18:38
Sunday Times Teaser 2746 (2015-05-10)
5 digit combination
sum of the cubes of the first three digits is equal to the first three digits
sum of factorials of the latter three digits is equal to the last three digits
@flatcap
flatcap / marbles.sh
Last active August 29, 2015 14:21
Sunday Times Teaser 2747 (2015-05-17)
#!/bin/bash
for sum in {399..350..-1}; do
for red in {4..200}; do
blue=$((sum-red))
num1=$red
den1=$((blue+red))
num2=$((red-1))
@flatcap
flatcap / puzzle.txt
Created May 24, 2015 13:37
Sunday Times Teaser 2748 (2015-05-24)
arithmetic progression
digits replaced by letters
progression includes term 10000
progression starts
I, GO, UP, AND
what's the value of POUND?
@flatcap
flatcap / puzzle.txt
Created June 28, 2015 17:03
Sunday Times Teaser 2753 (2015-06-28)
sign
l = length in cm
w = width in cm
l = 2w
(sum length digits)^2 - l = w
(sum width digits)^2 - w = l
@flatcap
flatcap / puzzle.txt
Created August 23, 2015 23:17
Sunday Times Teaser 2761 (2015-08-23)
cards numbered 1-9
laid out in ascending order
cards redealt, no card in original place
last 6 digits form the square of the first three digits
@flatcap
flatcap / gen.sh
Created September 13, 2015 15:21
Sunday Times Teaser 2764 (2015-09-13)
#!/bin/bash
rm -f list{1,2}
for ((a = 1; a < 20; a++)); do
for ((b = a+1; b < 20; b++)); do
for ((c = b+1; c < 20; c++)); do
for ((d = c+1; d < 20; d++)); do
for ((e = d+1; e < 20; e++)); do
echo $a $b $c $d $e >> list-number