Tuesday 26 August 2014

I am now part of the 15.75%

... of members of Project Euler who have solved 25 coding problems and reached Level 1. (yay!)


But hang on, only less than 16% made it?  I think we should and can do better! So, join up and be entertained with quality puzzles.  How to solve?  Well, take a lesson from 'Transformer Owl':





Wednesday 13 August 2014

Sometimes, to fake is better than to make

#! /bin/bash                                                         
# Compile a test file without those noisy -Wunused* flags, but       
# everything else that may be useful.                                

# Usage: compileCTest <name of your file  without the '.c'>  
       
# give the executable an easy to spot and mass-delete friendly name
executable="$1-exe"

# remove the old executable if it exists                             
if [ -e $executable ]
then                                                                 
    rm $executable;                                                  
fi                                                                                                            
echo ""
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo ""

# all flags from -Wall and -Wextra minus the -Wunused flags
runGCC='gcc -g -std=c99 -Waddress -Warray-bounds -Wchar-subscripts -Wenum-compare -Wimplicit-int -Wimplicit-function-declaration -Wformat -Wmain -Wmaybe-uninitialized -Wmissing-braces -Wnonnull -Wparentheses -Wpointer-sign -Wreturn-type -Wsequence-point -Wsign-compare -Wstrict-aliasing -Wstrict-overflow=1 -Wswitch -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wvolatile-register-var -Wclobbered -Wempty-body -Wignored-qualifiers -Wmissing-field-initializers -Wmissing-parameter-type -Wold-style-declaration -Woverride-init -Wsign-compare -Wtype-limits -Wuninitialized $1.c -o $1-exe -lm -lgmp'

eval $runGCC                                                         

# check that compile resulted in executable and if so, run it  
if [ -e $executable ]                 
then                                                                 
# add a couple of dividing lines to make this easier to read 
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=";
./$executable;
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=";
fi         

Wednesday 6 August 2014

A gcc joke

$ gcc --help=common

...

  -pedantic                   This switch lacks documentation
  -pedantic-errors            Like -pedantic but issue them as errors




Sunday 3 August 2014

Remedial Reading for the 'C'onfused.

Programming from the Ground up is an easy going, fun read, and goes a long way towards explaining all those inconvenient miracles that occur when you first try to use pointers in C.




... and, for some reason, Holger Czukays' short video of 'Ode To Perfume' nicely matches the topic (and it's pretty good hacking music).  The longer version of that song is here

(and if this reminds you of Stockhausen's work, well, there's a reason for that)

Update: This here is also a useful read about C's peculiarities.