C + Unix
Outputs a Shakespeare soliloquy before deleting itself:
#include <stdio.h>
#include <string.h>
#include <unistd.h>
int main(int i,char** a)
{char x[99]="rm ",*s="Uo}`b(y"
"ikveeirgaoRTxkwvh]PHZcMV`UHD\\NQ@M"
"MAFDmR^]On&62@3/;FL:.7A00\"+#/:$(7,}y3!z~"
"s.#{+}~nmkwDWjf~rjfjbmwYeZsUed`gbl\\RiY^\\YG"
"LIRWT^EMOPPH>v&HSHBPE1:3K-=7<F(-&-155>~<0!z8(|5"
"*'#(r{s\"8KKwl'h~$rrqorgkcy_g\\uj]Y`1o{zlA[iNRMqd"
"poaVP^RJBAKdWcbTs\"BP>?A3fJ,8-F)?C%A5-%$.;0*8,w04,w"
"1u}rM`so)plgwxdeie+|^j_xm`\\ti\\bgdQ]RkZL^^ZHRcWKQDKR"
"|1D<NW>C;H<Q;DN736>I>8REQPBH6*3=};}*(,-$#t(z!}NQq#y~|s!"
"%xr\"ce}ufoc!]&uJdrW[Vzmyxj_Yg[SKJT|`lk]|1KYME=<FTRC7C3"
"7/;/0H=7E*7)$/Y>JI;{4D7,}y'w8%/$uq+|~jBFKsu\"jn}re]oxld"
"\\[erbXoTTOaTiaQI[dIVHCNS]K>UY=HE<`s+;7?NF3K4,@.F:.:*).&"
"$=-#\"9.!!*4\"#%&pz-ozsu4GSzww\"hiuc{qnxiYliZ.qfYUaSr_i^"
"QMeXJWSGDT}2E=OXF9B;HR63=1<7AEI9/F:5C020(>+'#!TX]')4,z\""
"0(}$xo*kmhx%xkg!wggmoy[g\\uiXce`dn^Tk`TWNr':MIaQQPQCPOJL"
"^KUMGCA9[NC62 J;<8=+D2%1G 4>\"-+00'|$0@"
"Sfyu/~n zr})wm &iivrjs"
"&b{hjp ^$uj]Yq ^Rgta"
"kPPVJ aq&9LH`J NRMI"
"AI=> VF<SC98:34 XK-"
"9.G </+C7373.2\\o $z."
"7(v *|w!&/{r ~t~)wm&y lh\""
"vnvmo pcswlXaZg} 2HXT\\kTP hQQTYJPI`"
"NIFFQZCCLVHK>9GGDN</81 i!2</D&B%#3%=~,~&#'U5-"
"{#1)~%yp+~qmzk%jdtee kq{^`[k$7JdrZdf^clNZ"
"Oh\\_LGYbXPEEQ\\>Z R?:JPTA=97[noCAJ?2"
"*<E :-)A&3%~\" ;+!8,'$y) zz~"
"v.nr!o{( kkfxk.!-"
",|=Pc_wmeZ^gVagUasQjNY"
"^V[X^naHSOL\\TDJM>V9E"
"JFAp} ?MB?-A/54,8C6(662-1G:FE 7(,0/"
"~v%/$uq+# rts2EEqf!m`iboyolviW i\\XdoRTO_"
"j_RX[LdNPOU_WD \\E=Q?w,?7CR9>JNC"
"=K;?2.::D9,$6?7$<(* *17&v+zz'0~tLL_r~{'"
"itrvejemabz_i^ kucV_XpT_fO_P^hX"
"Ne[XbDNMy}}K@ YNAMJTI<8P?1C7"
"C1I2>-E5+B5'4/+31%*(W_*4({"
"t{{wrp+y0my&|mwj!tgc"
"{l\\f^vZWhhqaWncV\\aR"
"R]#''SHaGOTDPMN DM>KUE;R:D61CL="
"5?-1F(4)B01.%-2G Zp#-~5*{{&0#stm}n5("
"{njmu\"duqpbjomwllhcrTi ciy..ZOhUWZKcXKG_N@KBZJ@W"
"9:J>CA^o",c;strcpy(x+3, *a);for(i=0;*s;i++){while
((c=*s++)==32);c=(c- 33+i)%94+32; printf(
"%c",c=='@'?(sleep( 3),'\n'):c);}printf
("\n");system (x);sleep
(6);return c-c;}
I thought I'd better add a description for the benefit of anyone who's having second thoughts about running this program (can't say I blame you :-D). It consists almost entirely of a single text string
*s="Uo}`b(yikveeirgaoRT ... G_N@KBZJ@W9:J>CA^o"; /* 1459 bytes */
which is decoded in a for()
loop with an incrementing counter i
. After
stepping past any white space (while ((c=*s++)==32);
), the program retrieves the original character (c=(c-33+i)%94+32;
) and sends it to stdout, unless it encounters a "@" character, in which case it starts a new line and pauses for 3 seconds:
printf("%c",c=='@'?(sleep(3),'\n'):c);
On exiting the loop, the program deletes itself by making a system call with a string obtained by concatenating the delete command rm
with the name of the program (pointed to by the second argument to the main()
function):
int main(int i,char** a) {
char x[99]="rm " ...
:
strcpy(x+3,*a);
:
system(x);
The decoded text is from Hamlet.
@Dennis, how is this too broad? – OldBunny2800 – 2016-04-19T20:13:25.907
4@OldBunny2800 Do X creatively is already broad by today's standards. On top of that, the question literally says the answers don't even have to work. – Dennis – 2016-04-19T20:36:44.647
Perhaps edit your question to include that. I personally think this question is fine. – unclemeat – 2014-01-31T07:26:18.917
2Now, somebody will post code to wipe the entire hard drive and win. – cjfaure – 2014-01-31T13:47:30.083
possible duplicate of Write a program that deletes itself
– Gareth – 2014-01-31T15:04:35.2472
Duplicate of http://codegolf.stackexchange.com/questions/19355/a-program-that-deletes-itself which itself is a duplicate of http://codegolf.stackexchange.com/questions/17327/write-a-program-that-deletes-itself
– Gareth – 2014-01-31T15:06:00.6304@Gareth this one is [tag:popularity-contest], not [tag:code-golf]. – AJMansfield – 2014-01-31T16:13:42.433
2This question on meta suggests that being different in acceptance criteria alone is not enough to avoid being a duplicate. – Gareth – 2014-01-31T16:44:59.373
1
@Gareth actually, the answers suggest the opposite to me; a good answer to a [tag:popularity-contest] is usually nothing like a good answer to a [tag:code-golf]. While there is some overlap between the ones here, and the ones on others, this question exists for the purpose of answers like this one, that would be inappropriate for the other questions.
– AJMansfield – 2014-01-31T19:21:21.187@Gareth and if you look at the answers that are indeed copied from the other questions, like this and this, you can see they are still at 0 rep.
– AJMansfield – 2014-01-31T19:26:17.660