Kirjautuminen

Haku

Tehtävät

Keskustelu: Yleinen keskustelu: Merkkijonohaaste

Tronic [19.08.2019 13:16:18]

#

Tee suosikkikielelläsi ohjelma, joka tulostaa ruudulle seuraavan tekstin:

"text", 'text' and ´text´ usually end before the next \n, while

"""multi       '''or this     <<EOF                    ":
   line"""        one'''      as well as heredocs        and string
                              EOF                        block literals
may include newlines.

Python's "foo""""bar""" and "foo""bar" are foobar but strangely enough,
"""""bar""" is ""bar and """bar"  # waits for """ (like this 'comment')

\\ is usually used to mark \ which itself is used for various escape
sequences. /Raw strings/ such as r'this\not\escaped' try to treat \ as \
but may add other escapes like ""/'' for "&' and often they still escape
depending on location. You may have been bitten by C:\Windows\

Tekstiä ei saa lukea tiedostosta tai vastaavaa, vaan se pitää sisällyttää lähdekoodiin.

Sitten tee ohjelma, joka tulostaa ensimmäisen ohjelmasi lähdekoodin ruudulle,
ja postaa se tänne :)

Lisäys:

Hommaan palkinnon eniten fucked up, mutta toimivan ja järkeenkäyvän ratkaisun postanneelle.

Itse puuhailen parhaillaan Nim-ohjelmointikielen parissa, joten referenssiratkaisuna siitä miten ei ainakaan voita:

stdout.write r":
  stdout.write r":
    "text", 'text' and ´text´ usually end before the next \n, while

    """multi       '''or this     <<EOF                    ":
       line"""        one'''      as well as heredocs        and string
                                  EOF                        block literals
    may include newlines.

    Python's "foo""""bar""" and "foo""bar" are foobar but strangely enough,
    """""bar""" is ""bar and """bar"  # waits for """ (like this 'comment')

    \\ is usually used to mark \ which itself is used for various escape
    sequences. /Raw strings/ such as r'this\not\escaped' try to treat \ as \
    but may add other escapes like ""/'' for "&' and often they still escape
    depending on location. You may have been bitten by C:\Windows\

jukkah [19.08.2019 13:55:19]

#

Tässäpä SQL-versio sillä rajoituksella, että SQL ei itsessään tulosta mitään ja useimmat clientit esittää queryn tuloksen jonkinlaisena taulukkona. Mutta jos queryn tulos lasketaan outputiksi, niin sitten tämän pitäisi ajaa asiansa.

select '"text", ''text'' and ´text´ usually end before the next \\n, while

"""multi       ''''''or this     <<EOF                    ":
   line"""        one''''''      as well as heredocs        and string
                              EOF                        block literals
may include newlines.

Python''s "foo""""bar""" and "foo""bar" are foobar but strangely enough,
"""""bar""" is ""bar and """bar"  # waits for """ (like this ''comment'')

\\\\ is usually used to mark \\ which itself is used for various escape
sequences. /Raw strings/ such as r''this\\not\\escaped'' try to treat \\ as \\
but may add other escapes like ""/'''' for "&'' and often they still escape
depending on location. You may have been bitten by C:\\Windows\\' as temp;
select 'select ''"text", ''''text'''' and ´text´ usually end before the next \\\\n, while

"""multi       ''''''''''''or this     <<EOF                    ":
   line"""        one''''''''''''      as well as heredocs        and string
                              EOF                        block literals
may include newlines.

Python''''s "foo""""bar""" and "foo""bar" are foobar but strangely enough,
"""""bar""" is ""bar and """bar"  # waits for """ (like this ''''comment'''')

\\\\\\\\ is usually used to mark \\\\ which itself is used for various escape
sequences. /Raw strings/ such as r''''this\\\\not\\\\escaped'''' try to treat \\\\ as \\\\
but may add other escapes like ""/'''''''' for "&'''' and often they still escape
depending on location. You may have been bitten by C:\\\\Windows\\\\'' as temp;' as temp;

Tronic [04.09.2019 11:05:07]

#

Erikoisesta kielestä huolimatta suhteellisen normaalit escapoinnit ja etenkin backslashit paukkuvat kivasti. Rivinvaihdot sellaisenaan ja yksinkertainen lainausmerkki literaalina helpottivat tilannetta verrattuna moniin muihin kieliin.

Olisi mukava nyt kuitenkin nähdä vielä jokin muukin toteutus, jonkin muun kielen erityispiirteillä höystettynä.

Tronic [11.10.2019 07:50:41]

#

Jukkah voitti parhaana suorituksena... Lähetä osoite pm niin laitan palkinnon tulemaan :)

jukkah [11.10.2019 09:49:54]

#

Otetaan nyt vielä JavaScriptillä toinen esimerkki, niin ei voida sanoa, että voitin ainoalla suorituksella. :D

console.log(`"text", 'text' and ´text´ usually end before the next \\n, while

"""multi       '''or this     <<EOF                    ":
   line"""        one'''      as well as heredocs        and string
                              EOF                        block literals
may include newlines.

Python's "foo""""bar""" and "foo""bar" are foobar but strangely enough,
"""""bar""" is ""bar and """bar"  # waits for """ (like this 'comment')

\\\\ is usually used to mark \\ which itself is used for various escape
sequences. /Raw strings/ such as r'this\\not\\escaped' try to treat \\ as \\
but may add other escapes like ""/'' for "&' and often they still escape
depending on location. You may have been bitten by C:\\Windows\\`)
console.log(`console.log(\`"text", 'text' and ´text´ usually end before the next \\\\n, while

"""multi       '''or this     <<EOF                    ":
   line"""        one'''      as well as heredocs        and string
                              EOF                        block literals
may include newlines.

Python's "foo""""bar""" and "foo""bar" are foobar but strangely enough,
"""""bar""" is ""bar and """bar"  # waits for """ (like this 'comment')

\\\\\\\\ is usually used to mark \\\\ which itself is used for various escape
sequences. /Raw strings/ such as r'this\\\\not\\\\escaped' try to treat \\\\ as \\\\
but may add other escapes like ""/'' for "&' and often they still escape
depending on location. You may have been bitten by C:\\\\Windows\\\\\`)`)

Ps. Hankala ilmoittaa sulle mun osoitetta, kun en nää sun sähköpostiosoitetta. Ei kai tänne ole kuitenkaan mitään chattia rakennettu?

Tronic [11.10.2019 12:41:53]

#

Vai puuttuu täältä se toiminto. No nakkaa sitten ljkarkk2@cc.hut.fi.

Missäköhän vaiheessa tuon haasteessa olleen tekstin ` oli kääntynyt väärinpäin... Meni ehkä liian helposti Javascriptissä nyt sen vuoksi :)

Vastaus

Aihe on jo aika vanha, joten et voi enää vastata siihen.

Tietoa sivustosta