Programmazione creativa [chiusa]


12

Crea una storia dalla tua programmazione. Esempio in JavaScript:

self.book = {
    "story": function() {
        var once = "upon",
            aTime = setTimeout(function() {
                // Code would continue...
            }, 1000)
    }
};

self.book.story();

disposizioni:

  • Deve essere eseguito senza errori prima, durante e dopo la compilazione.
  • Puoi usare solo due parole per la storia per stringa / nome.
    • Esempio JavaScript:
      var story = "Once upon a"; // Wrong (Using more than two words)
      var story = "Onceupona"; // Wrong (Using more than two "words")
      var onceUponA = "time"; // Wrong (more than two words as a variable name)
      var onceUpon = "a time"; // This is fine
      var story = "Once upon"; // This is fine
  • La storia deve essere una frase completa (almeno).
  • Avere una sorta di output (come "stampare" la storia stessa) non è necessario, ma è un vantaggio.
  • Porta dentro un po 'di creatività.

Poiché non ci sono regole di lunghezza, vincerà la risposta con il maggior numero di voti / migliore creatività. :)


2
Questo tipo di mi ricorda questa voce IOCCC , che è scritta come uno scambio di lettere
Hasturkun,

Spero che intendi solo fino a 2 parole in letterali stringa? Altrimenti la combinazione di stringhe sarebbe illegale.
jpjacobs,

@jpjacobs Yup. Anche se qualcosa del genere "Hi how" + "are you" + "doing today"sarebbe zoppo. ;)
Shaz,

Nessun criterio vincente oggettivo.
dmckee --- ex gattino moderatore,

Risposte:


17

JavaScript

Non sono sicuro di quanto sia storicamente accurato, ma è una mini-storia di ECMAScript. Non esitate a suggerire miglioramenti.

function story() {
    var IE = {
        from: "Microsoft"
    },
        Netscape = {
            from: "Mozilla"
        };
    var setUp = {
        oncethere: "were two",
        browsers: IE + Netscape
    };
    var parts = {

        And: function() {
            var theyfought = "to be",
                theBest = "browser";
        },
        oneday: function() {
            var they = {
                added: function() {
                    var add = "scripting languages";
                    Netscape.language = add;
                    IE.language = add;
                    return add;
                },
                thought: function() {
                    if (what(they.added) === good) {
                        they.wouldBeat = "the other";
                    }
                }
            };

        },
        andso: function() {
            function callLanguage(name) { return name };
            Netscape.language = callLanguage("Javascript");
            IE.language = callLanguage("JScript");
        },
        butThen: function() {
            var ECMA = "Standards Committee";
            (function standardized(languages) {
                (function into() {
                    return "ECMAScript";
                })();
            })([IE.language, Netscape.language]);

        },
        theEnd: function() {
            return {
                andWe: "all lived",
                happilyEver: "after..."
            };
        },
        what: function(thing) {
            return thing;
        },
        good: true || false
    };
}
story();

1
Ora c'è un libro JavaScript. ;)
Shaz,

3
@Shaz HA yup. Immagina un libro che spiega JS scritto in quel modo. O_o
Thomas Shields,

1
Sì, sarebbe sicuramente interessante. : P Sono solo contento che l'inglese sia la mia lingua madre.
William,

14

JavaScript

'How';do{'computers'^Function}while(0);'they have'|'no power?'

L'output è: 0su console: D


Mi piace questo. :)
Shaz,

2
this.is,2,'show my',/appreciation/
William,

Quale console? Forse dovresti indicare quale lingua hai usato.
PhiLho,

È JavaScript, basta incollarlo in firebug/ console.
William,

Non fa niente qui. o sono solo io?
jpjacobs,

13

Non è tanto una storia , e ciò che fa il programma non ha nulla a che fare con ciò che dice il codice, ma ...

C ++

/* Preface (assuming nobody reads it anyway): */
#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <functional>
#include <time.h>
using namespace std;
int



/*Beginning   the*/ main(){//story:

#define   a   string
ofstream ing___water;   a   river;

#define   the
long   rivers,
each,  is
(a ( river +"of").length() > 4 );
a   normal ( river +"has   the");
a bility;   for ( float ing;  short (~1 - - 2 );){
char coal,  loaded,  ships,  on,  its,  water;
coal = is;  a   lot,   lighter;
if ( lighter  .compare ( normal ))water = 'H'*2+'O'; }

a   heavier,  ship,  may;  do { a   worse,  job;  a nd,  run;
a ground; }while ( "you"&&false)//ly
;try { a nd ( "navigate   through");
a ny, such ( normal.size()==rivers     ? 

the  "ship" : may + "then"); }
catch ( exception ally ) { a wful;}} struct ural___damage {
long   before ( the   time_t o)                                                                                               const{
return "to" == a( "harbour");
for ( a   rescue ("from   leaking"),
its ("load   or");o<the'r';) {
ofstream ing,  substances;
if ("not"=="even"||substances/*that*/.put( 'a').bad())
double   damage,  to,  both   the ((short) "river"[1]);
a nd   the ("overall   environment[2].");}}

a   sentient,  ship_owner,  should,  h;int //to
the operator<( struct ural___damage   might)                                                                                  const{
a lso( "occur"), to( "his   own"),health( "when   not");
using   the ::map;
to  .find(  a ( "river   that's"),long( ~3 ) );
(to+="avoid")+=the "trouble   and";
(to+="cause")+=(less</*r*/ural___damage>()
(*this,/*seems like*/*this)?"is": a( "good   idea"));


return before ( the   time(0))||"is"==to +"late";}};

Come testo normale:

Inizio della storia principale:
definire una stringa di torrente d'acqua un fiume;
definire i fiumi lunghi, ognuno è un fiume di lunghezza> 4;
un fiume normale ha la capacità di galleggiare sulle sue acque navi corte (~ 1--2) caricate con carbone; il carbone è molto più leggero se più leggero confronta l'acqua normale = H2O;
una pesante nave può fare un lavoro peggiore e arenata mentre si falsamente tenta e navigare attraverso tali fiumi normalsize, la nave potrebbe poi prendere danni strutturali exeptionally terribile molto prima del tempo per const ritorno ad un porto per un salvataggio dalla fuoriuscita suo carico o altre sostanze correnti, se non addirittura sostanze che presentano un grave doppio danno sia per il fiume corto [1] che per l'ambiente generale [2].
un proprietario di una nave senziente dovrebbe accennare all'operatore che un danno strutturale potrebbe costare anche alla propria salute quando non si utilizza la mappa per trovare un fiume lungo (~ 3) per evitare problemi e causare meno danni rurali. sembra che questa sia una buona idea. ritorno prima che sia troppo tardi.

12

Mi ricorda LOLCode , tutto è una specie di storia (o almeno una "conversazione"):

HAI
PU H AVERE STDIO?
HO UN VAR
IM IN YR LOOP
    UPZ VAR !! 1
    VAR VISIBILE
    IZ VAR BIGR THAN 10? GTFO. KTHX
KTHX
KTHXBYE

Interessante mai sentito parlare di LOLCode. Tuttavia, puoi trovare qualcosa di originale o è l'unica sintassi disponibile? oO
Shaz,

2
Questo mi ricorda il linguaggio di programmazione di Shakespeare. lol.
JiminP,


Downvoted per non essere né interessante né innovativo. Avrebbe dovuto essere un commento, non una risposta.
cemper93,

1
"segnala questo post per gravi problemi o attenzione del moderatore" - questo tipo di mi spaventa;) E mi piace la domanda anche se è soggettiva. È interessante e non credo che devi sempre avere un criterio vincente oggettivo. Guarda i Code Golf: tutti sanno in anticipo che Golfscript sarà il vincitore, ma ci sono altre voci. Se tutti giocassero solo per obiettività, questo sito sarebbe presto morto.
cemper93,

11

Brainfuck

+++++ +   + +++++ +++++ +++++   +++++ +++++ 
  +   +   + +     +   + +         +   +     
  +   +++++ +++   +++++ +++       +   +++++ 
  +   +   + +     + ++  +         +       . 
  +   +   + +++++ +   + +++++   +++++ +++++ 

+++++ +   + +     +   +   +++++ +   + +.+++ 
[   + ]+  + +      + +    +   + ++  + +     
+   + + [ + ]       +     +   + + + + +++   
+   + +  ++ +       +     +   + +  ++ +     
+++++ +   + +++++   +     ++++. +   + +++++ 

++++  +++++ +++++ +++++  +   +              
+   + +   + +   +   +    ++  +              
++++  +++++ +++++   +    + + +              
+   + + +   +   +   +    +  ++     +        
++++  +   + +   + +.[+]  +   +    +         

+++++ +   + +++++ +   + +++++ +++++ +++++ . 
+     +   + +     +  +  +     +   + +     + 
+++   +   + +     +++   +++   +++++ +++++ + 
+     +   + +     +  +  +     + ++      +   
.     +++++ +++++ +   + +++++ +   + +++++ . 

Ho "accidentalmente" attraversato questo bfe quello è venuto fuori

It's Me

* SCNR * :)


Interessante! : P
Shaz,

10

DI BASE

leggermente semplicistico, ma molto vero per quelli di noi che restano in piedi fino alle 3 del mattino ...

On Error GoTo sleep

molto più bello di quello di PHPor die
TSH

8

Python Love

def inizialmente (c'erano)
    se non nessuno:
        atLeast = not "many"
    who.made ("il mio cuore")
    "beat as", you.do (_, _)
    restituisci il tuo sorriso
warm = "ly"

provare:
    toKeep = "it" + warm
    mentre cammini Home: passa
    Ing (emptyWindows)
tranne: ionally = "triste"
infine: it = "'s over"

your = not any ([1, "to me"]) o "just my toy" e \
type ("", (), {"youWere": "more"}) ()

your.smile = "mi ha tenuto"
_ = caldo in "in questi giorni"

ma, tu = "hai fallito", il tuo #love: me

se _: solo (I)
hadKnown, you.were = "innocente come un", lambda \
giovani, blueEyed: \
[("ma", "la punizione") per i risultati di myMisdoings #
in tempo"]

a volte, you.do = ("fammi", #pensiero di chi
tu eri) 
"" in "un'altra storia"

I, who = "I'm been", your # 's
"sedersi" nella "mia stanza"
"guarda" in "g" #vecchie fotografie
# ricordando inesorabilmente
the, love = you.do, "dai a me"
who.made = tutti # questi errori

"Aveva pensato" + it + "sarebbe andato"
on = "inf" + inizialmente (
"Oh !, il", "sciocco che ho") # stato
rimpiangere = all ("i miei errori") #today

_, im = "hold" in "paraly", "sys"
_ = aperto; "lattine" e "lattine di"
_ = _ (__ import __ (# ed birra
im). # nell'annuncio
argv [0] #id
) .read () #sad poems

amore, is_ = the, "cosa I" #miss per sempre
iTake = "la mia macchina fotografica"
go = "out to have"
nuovo, foto = "guardare", _ #at

print ("them" se 0 # sono noiosi
altro _); "fanno" + "me think of", love ("lost", "for me")

EDIT: Questo è ora un quine (se imbrogliato).



2

Non posso davvero rivendicare questo per me, ma penso che sarebbe davvero un bene per tutti voi poterlo guardare.

Questo si chiama PHP Sad Poem, e viene da qui .

$timeWaiting = 0;
while (!$you->near($me)) {
    $me->thinkAbout($you);
    switch (true) {
        case $timeWaiting < 5:
            $me->wait($you);
            break;
        case $timeWaiting < 10:
            $me->worry();
            break;
        case $timeWaiting < 20:
            $me->lookFor($you);
            break;
        case $timeWaiting < 40:
            $me->worry();
            $me->lookFor($you);
            break;
        case $timeWaiting < 80:
            $me->worry();
            $me->cry();
            $me->lookFor($you);
            $me->lookFor($you);
            $me->lookFor($you);
            break;
        case $timeWaiting < 160:
            $me->worry();
            $me->cry();
            $me->drink();
            $me->lookFor($you);
            $me->lookFor($you);
            $me->lookFor($you);
            $me->thinkAbout($you);
            $me->thinkAbout($you);
            $me->cry();
            $me->lookFor($you);
            $me->lookFor($you);
            $me->drink();
            $me->drink();
            break;
        default:
            throw new CantLiveWithoutYou();
            die(“alone”);
        }
    $timeWaiting++;
}
$me->happy = true;

Utilizzando il nostro sito, riconosci di aver letto e compreso le nostre Informativa sui cookie e Informativa sulla privacy.
Licensed under cc by-sa 3.0 with attribution required.