[Code Golf Challenge] Can Bitshift Variations in C Minor be compressed down to less than 185 characters? (Ṁ666 subsidy!)
12
996Ṁ4179
resolved Jun 5
Resolved
YES

Bitshift Variations in C Minor by Robert Miles is a Code Golf music piece wtitten in C (with some additional bash commands). It was originally presented in a 2016 Computerfile video Code Golf & the Bitshift Variations. You can listen to clean renderings of it here (by Lucia Ceionia).

My previous market was a challenge about decoding this music piece out of an 8x8 png image: /MayMeta/challenge-will-someone-decode-this, and this market is about the source code itself.

The original 2016 source code presented in the description under the YouTube video was 245 characters long:
echo "g(i,x,t,o){return((3&x&(i*((3&i>>16?\"BY}6YB6%\":\"Qj}6jQ6%\")[t%8]+51)>>o))<<4);};main(i,n,s){for(i=0;;i++)putchar(g(i,1,n=i>>14,12)+g(i,s=i>>17,n^i>>13,10)+g(i,s/3,n+((i>>11)%3),10)+g(i,s/5,8+n-((i>>10)%3),9));}"|gcc -xc -&&./a.out|aplay

A tweet from 2017 (or some other Rob Miles tweet, I'm not sure) stands 216 characters:
gcc -xc -oa -<<<'i;n;g(x,t,o){return(3&x&(i*((3&i>>16?"BY}6YB6%":"Qj}6jQ6%")[t%8]+51)>>o))<<4;}main(s){for(;;)putchar(g(1,n=++i>>14,12)+g(s=i>>17,n^i>>13,10)+g(s/3,n+(i>>11)%3,10)+g(s/5,8+n-(i>>10)%3,9));}';./a|aplay

With a month or two of work, I managed to shrink it down to 185 characters:
gcc -xc -oa -<<<'i;n;g(m,t,o){return("GTj?TG?5"[7&t]+!(n&12|t&2)*9)*i>>o&m&24;}main(s){for(;;)putchar(g(8,n=++i>>14,8)+g(n,n^(s=i>>10)/8,6)+g(n/3,n+s/2%3,6)+g(n/5,n-s%3,5));}';./a|aplay

Will someone be able to shrink it down below 185 characters, or the limit has been reached? This market resolves to YES as soon as someone posts a shorter version in bash+C, and I verify that it works. It resolves to NO on Jan 1st 2024 if no such version is found.

Conditions:
- The bash command should compile the source code and run + play it using aplay.
- You ARE allowed to slightly change the played notes, but their relative frequencies should not differ more than 1.4% from the original, and the entire piece should not be shifted more than one semitone (6%) from the original.
- You are allowed to use all sorts of tricks and hack in C language, as long as it compiles and works as intended on an average linux machine.
- Reading from pre-written files or from the internet is not allowed.
- I reserve the right to disqualify methods that I judge to be against the spirit of code golf, but I will hold a discussion about it in the comments section beforehand.

Useful links:
Deep analysis of Bitshift Variations in C Minor code
BitShift-Variations-unrolled
Bitshift Variations Humanized + Rust version

Get
Ṁ1,000
to start trading!

🏅 Top traders

#NameTotal profit
1Ṁ703
2Ṁ124
3Ṁ62
4Ṁ37
5Ṁ28
© Manifold Markets, Inc.TermsPrivacy