[Code Golf Challenge3] Can Bitshift Variations in C Minor be compressed down to less than 182 characters? (Ṁ520 subsidy)
11
233
730
resolved Jun 9
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).

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

In my previous market, a 182 characters version was found, by replacing gcc with cc and moveing putchar inside (;;):
cc -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=s>>4,8)+g(n,n^s/8,6)+g(n/3,n+s/2%3,6)+g(n/5,n-s%3,5)))s=++i>>10;}';./a|aplay

Will someone be able to shrink it down below 182 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 Ṁ200 play money

🏅 Top traders

#NameTotal profit
1Ṁ454
2Ṁ263
3Ṁ17
4Ṁ11
5Ṁ5
Sort by:
bought Ṁ361 of YES
cc -xc -oa -<<<'i;n;g(m,t,o){m=("GTj?TG?5"[7&t]+!(n&12|t&2)*9)*i>>o&m&24;}main(s){for(;;putchar(g(8,n=s>>4,8)+g(n,n^s/8,6)+g(n/3,n+s/2%3,6)+g(n/5,n-s%3,5)))s=++i>>10;}';./a|aplay

178 :)

(c basically always stores the return value in the first argument's register)

sold Ṁ0 of NO

@brubsby I'm speechless. It works!

I did not expect so much progress to happen in less than a week. 😅

bought Ṁ10 of NO

This might be my final market in this series. Esp if someone finds a 180-character version, which will blow my mind.

bought Ṁ100 of NO

@firstuserhere banged my head against it for a good while with no luck