[ prog / sol / mona ]

prog


The Art of Code

1 2020-06-09 08:56

https://www.youtube.com/watch?v=6avJHaC3C2U
Very enjoyable video. I'll post some of the programs:
http://www.funiter.org/ocmjg/

#define COPY    "\nObfuscated C Mandelbrot-/Julia-set generator."\
                "\n(C)opyright 2000-2001 by Stijn Wolters (stijnw@xs4all.nl)"\
                "\nAll rights reserved. No warranties are given, use of this"\
                " code is at own risk."

#define USAGE   "\nUsage (see also http://www.xs4all.nl/~stijnw/ocmjg/):"\
                "\nrn rm in im xmax ymax esc maxiter type file a b invmode"



                                                        q(
                                                       r,i,a
                                                      ,b,e,m)
                                                     double(
                                                      r),i,a
                                                      ,b,e;{
                                                       int(
                                           l);    double(h),u,v ;
                                            for (l=m;l>0;l--){h=r ;
                                            u=r *r;v=i*i;if(e<=(u+  v))
                                             break;r=u-v+a;i=(h+h)*i+b;
                                             }return(l);}main(int(argc
                                         ), char*argv[]){FILE*f;double
                                         a,b,e,r,i,s,t,u,v,co[4]={0,0,
                                          0,0};long(x)=0,y=0,xm=(5<argc
                                          )?atoi(argv[5]):300,ym=(argc> 6
                                        )?atoi(argv[6]):300;int(c)=0,j=0,
                          k    ,        l,m=(argc>8)?atoi(*(argv+8)):100
                          ,n ,o,        p;char(hx)=xm%0x100,lx=xm>>8,(hy)
                          =ym%0x100,   ly=ym>>8;n=(argc>9)?(((*(argv+9))[
                          0]|0x20)==   'm'):1;o=(argc>9)?(('s'-(((*(argv+
                        9))[1])|0x20)  )+1):0;o=(o>2||o<0)?0:o;;do{co[c]
                         =((argc>c+1)? atof(*(argv+c+1)):((c%2)?2:-2));}
                        while(++c<=3); if(!(f=fopen(((argc>=11)?argv[10]
                      : (n)?"Mandel.pcx":"Julia.pcx"),"wb+")))return(1);
                    fprintf(f,"\x0a\x5\x1\x8%c%c%c%c%c%c%c%c%c%c%c%c",
 0,0,0,0,hx-1,lx,hy-1,ly,hx,lx,hy,ly);for(l=0;l<=47;l++)fputc(l<<2,f)
                    ;fprintf(f,"%c\x01%c%c\x01",0,hx,lx);for(l=0;l<=58
                      ; l++)fputc(0,f);e=(argc>7)?atof(*(argv+7)):4;u=(*
                        (co+1)-*co)/xm ;v=(*(co+3)-*(co+2))/ym;;for(y=0;
                         y<=ym-1;y++){ for(x=0;x<=xm-1;x++){s=*co+x*u;t=
                        *(co+3)-y*v;a  =(n)?s:((argc>11)?atof(*(argv+11)
                          ):-1);b=(n   )?t:((argc>12)?atof(*(argv+12)):0)
                          ;r=(!n)?s:   0;i=(!n)?t:0;l=q(r,i,a,b,e,m);(o==
                          2) ?(k        =q(r,n?i:i-v,a,!n?b:b-v,e,m),p=!(
                          (    !        j&&l)||(j&&!l)||(!k&&l)||(k&&!l)
                                        )):(p=l);j=l;fputc((o)?((!p)?(0):
                                          (63)):(!p)?(0):(63-(p%63)),f) ;
                                          }printf("\r%3d%%",(int)((y+1)
                                         /(ym/100.0)));}fputc(0x0C,f);
                                         j= (argc>13)?(((*(argv+13))[0
                                             ]|0x20)=='i'):(0);for(k=0
                                             ;k<=0xFF;k++){l=(j)?0xFF-k
                                            :k; fprintf(f,"%c%c%c"  ,(l
                                            <<2 ),(l<<2),(l<<2)); }
                                           if(    f){fclose(f); }
                                                       puts
                                                      (COPY)
                                                      ;puts(
                                                     USAGE);
                                                      return(
                                                       (0));
                                                         ;} 
2 2020-06-09 08:58

1K JavaScript chess game
https://nanochess.org/chess4.html

<script>//(c)2009 Oscar Toledo G.
var B,i,y,u,b,I=[],G=120,x=10,z=15,M=1e4,l=[5,3,4,6,2,4,3,5,1,1,1,1,1,1,1,1,9,9
,9,9,9,9,9,9,13,11,12,14,10,12,11,13,0,99,0,306,297,495,846,-1,0,1,2,2,1,0,-1,-
1,1,-10,10,-11,-9,9,11,10,20,-9,-11,-10,-20,-21,-19,-12,-8,8,12,19,21];function
X(w,c,h,e,S,s){var t,o,L,E,d,O=e,N=-M*M,K=78-h<<x,p,g,n,m,A,q,r,C,J,a=y?-x:x;
y^=8;G++;d=w||s&&s>=h&&X(0,0,0,21,0,0)>M;do{if(o=I[p=O]){q=o&z^y;if(q<7){A=q--&
2?8:4;C=o-9&z?[53,47,61,51,47,47][q]:57;do{r=I[p+=l[C]];if(!w|p==w){g=q|p+a-S?0
:S;if(!r&(!!q|A<3||!!g)||(r+1&z^y)>9&&q|A>2){if(m=!(r-2&7))return y^=8,I[G--]=
O,K;J=n=o&z;E=I[p-a]&z;t=q|E-7?n:(n+=2,6^y);while(n<=t){L=r?l[r&7|32]-h-q:0;if(
s)L+=(1-q?l[(p-p%x)/x+37]-l[(O-O%x)/x+37]+l[p%x+38]*(q?1:2)-l[O%x+38]+(o&16)/2:
!!m*9)+(!q?!(I[p-1]^n)+!(I[p+1]^n)+l[n&7|32]-99+!!g*99+(A<2):0)+!(E^y^9);if(s>h
||1<s&s==h&&L>z|d){I[p]=n,I[O]=m?(I[g]=I[m],I[m]=0):g?I[g]=0:0;L-=X(s>h|d?0:p,L
-N,h+1,I[G+1],J=q|A>1?0:p,s);if(!(h||s-1|B-O|i-n|p-b|L<-M))return W(),G--,u=J;
J=q-1|A<7||m||!s|d|r|o<z||X(0,0,0,21,0,0)>M;I[O]=o;I[p]=r;m?(I[m]=I[g],I[g]=0):
g?I[g]=9^y:0;}if(L>N||s>1&&L==N&&!h&&Math.random()<.5){I[G]=O;if(s>1){if(h&&c-L
<0)return y^=8,G--,L;if(!h)i=n,B=O,b=p;}N=L;}n+=J||(g=p,m=p<O?g-3:g+2,I[m]<z|I[
m+O-p]||I[p+=p-O])?1:0;}}}}while(!r&q>2||(p=O,q|A>2|o>z&!r&&++C*--A));}}}while(
++O>98?O=20:e-O);return y^=8,G--,N+M*M&&N>-K+1924|d?N:0;}B=i=y=u=0;while(B++<
120)I[B-1]=B%x?B/x%x<2|B%x<2?7:B/x&4?0:l[i++]|16:7;for(a=
"<table cellspacing=0 align=center>",i=18;i<100;a+=++i%10-9?
"<th width=40 height=40 onclick=Y("+i+") style='border:2px solid #aae' id=o"+i+
" bgcolor=#"+(i*.9&1?"9090d0>":"c0c0ff>"):(i++,"<tr>"));
a+="<th colspan=8><select id=t><option>Q<option>R<option>B";
document.write(a+"<option>N</select></table>");
function W(){B=b;for(p=21;p<99;++p)if(q=document.getElementById("o"+p)){q.
innerHTML="<img width=40 src="+(I[p]&z)+".gif>";q.
style.borderColor=p==B?"#ff0":"#aae";}}W();
function Y(s){i=(I[s]^y)&z;if(i>8){b=s;W();}else if(B&&i<9){b=s;i=I[B]&z;if((i&
7)==1&(b<29|b>90))i=14-document.getElementById("t").selectedIndex^y;X(0,0,0,21,
u,1);if(y)setTimeout("X(0,0,0,21,u,2/*ply*/),X(0,0,0,21,u,1)",250);}}
</script>
3 2020-06-09 09:01

html quine


<html>
<body>
<p>This page looks the same rendered and in source view.</p>
<p>Made possible by these 10 style rules:</p>
<style>* {display: block; font-family:Monospace; margin: 0;}</style>
<style>a[href]::before {content: "<a href='" attr(href) "'>"}</style>
<style>a::after {content: "</a>"}</style>
<style>body::before {content: "<body>"}</style>
<style>body::after {content: "</body></html>"}</style>
<style>html::before {content: "<html>"}</style>
<style>p::before {content: "<p>"}</style>
<style>p::after {content: "</p>"}</style>
<style>style::before {content: "<style>"}</style>
<style>style::after {content: "<\/style>"}</style>
<a href="https://twitter.com/marekgibney">Follow me on Twitter</a>
</body></html>
4 2020-06-09 09:09

Flutter art
https://www.youtube.com/watch?v=DEppSs_ko48
https://github.com/Solido/flutter-d-art

Sonic Pi (music creation)
https://sonic-pi.net/
https://github.com/samaaron/sonic-pi

                                       ╘
                                ─       ╛▒╛
                                 ▐╫       ▄█├
                          ─╟╛      █▄      ╪▓▀
                ╓┤┤┤┤┤┤┤┤┤  ╩▌      ██      ▀▓▌
                 ▐▒   ╬▒     ╟▓╘    ─▓█      ▓▓├
                 ▒╫   ▒╪      ▓█     ▓▓─     ▓▓▄
                ╒▒─  │▒       ▓█     ▓▓     ─▓▓─
                ╬▒   ▄▒ ╒    ╪▓═    ╬▓╬     ▌▓▄
                ╥╒   ╦╥     ╕█╒    ╙▓▐     ▄▓╫
                           ▐╩     ▒▒      ▀▀
                                ╒╪      ▐▄

             _____             __        ____  __
            / ___/____  ____  /_/____   / __ \/_/
            \__ \/ __ \/ __ \/ / ___/  / /_/ / /
           ___/ / /_/ / / / / / /__   / ____/ /
          /____/\____/_/ /_/_/\___/  /_/   /_/
5 2020-06-09 09:24

polyquine.c.rb.pl.py (prints its own source code in C, Ruby, Perl, Python)

 #include/*
s='''*/<stdio.h>
main(){char*_;/*==;sub _:lvalue{$_}<<s;#';<<s#'''
def printf(a,*b):import sys;sys.stdout.write(a%b),
s
#*/
_=" #include/*%cs='''*/<stdio.h>%cmain(){char*_;/*==;sub _:lvalue{%c_}<<s;#';<<s#'''%cdef printf(a,*b):import sys;sys.stdout.write(a%%b),%cs%c#*/%c_=%c%s%c;printf(_,10,10,36,10,10,10,10,34,_,34,10,10,10,10);%c#/*%cs='''*/%c}//'''#==%c";printf(_,10,10,36,10,10,10,10,34,_,34,10,10,10,10);
#/*
s='''*/
}//'''#==

small JavaScript quine

$=_=>`$=${$};$()`;$()

quine relay
https://github.com/mame/quine-relay
This is a Ruby program that generates Rust program that generates Scala program that generates ...(through 128 languages in total)... REXX program that generates the original Ruby code again.

6 2020-06-13 08:04

Is there any music synthesis program that isn't just a front-end to SuperCollider? (serious question)

7 2020-06-13 11:29

>>6
There is the Music V family of which Common Lisp Music is a member: https://ccrma.stanford.edu/software/clm/

8


VIP:

do not edit these