歌のコーディング-選択したプログラミング言語で音楽の歌詞を表現する[非公開]


13

読んだときに曲の歌詞となる、選択した言語でプログラムを作成します。これは、必要があり、エラーなしでコンパイルして実行することができ、有効なプログラムであること。画面にすべての歌詞を技術的に印刷することもできますが、スタイルを使用し、可能な限り文字列リテラルを避けることをお勧めします。

これ自体は難しいことを考えると、歌詞で読みやすくなることを考慮しない定型コードの1つのセクションを書くことができます。ただし、コードのブロックが始まると、それは歌の歌詞として読み取る必要があり、歌が終了するまで中断することはできません。コメントを使用して、ソングコードの開始と終了を示すことができます。コードを読むように歌詞自体も指定してください。書かれたものから遠く離れない限り、あなたはあなたの解釈に「リベラル」であることができます、さもなければそれはあなたにポイントを要します。

部分的な歌の歌詞は許可されますが、歌全体に言葉を付けると二重のポイントが得られます。審査は3つのカテゴリに分けられます。

  1. 10ポイント-独創性
  2. 10ポイント-歌の難易度
  3. 20ポイント-コードでのその歌の表現。

提出ごとに、以下のコメントでスコアをお伝えします。回答を編集する場合は、コメントインジケータを教えてください。それに応じて再評価します。ただし、公平にするために、各再評価では合計スコアから2ポイントが差し引かれます。

例は次のとおりです。

public class Song {
    public String play() {
        // Song begin
        try {
            if(this instanceof TheRealLife || this instanceof JustFantasy) {
                throw new InALandSlide();
            }
        } catch (InALandSlide e) {
        }
        return "No \"FromReality\"";
        // Song end
    }

    public static void main(String [] args) {
        Song song = new Song();
        song.play();
    }
}

読まれる:

Is this TheRealLife?
Or is this JustFantasy?
Caught InALandSlide.
No escape \"FromReality\"

インストゥルメンタルは許可されていません、賢者。;)


4
これは興味深い概念であり、結果を見ることに興味がありますが、これはあまり客観的ではありません。歌の「難易度」をどのように判断しますか?(など)
ガフィ

3
強力のことを思い出すこのIOCCCの勝者
ugoren

@Gaffi、主に長さだけでなく、言葉遣いも。0を記録する歌の例はこの歌がたった6語の長さであるかもしれません。
ニール

どの程度HQ9のプログラム9?:P
李アウンイップ

1
コーディングに適した歌を見つけようとする人へのヒント:「Voidへの脱出」は有望なタイトルのようです:)- lyricstime.com/sepultura-escape-to-the-void-lyrics.html
Cristian Lupascu

回答:


8

Python-8 + 4 + 15 = 27ポイント

ルイス・キャロルの「スナーク狩り」のスタンザがいくつかあります。
詩で提案されたアルゴリズムに基づいて数値を計算し、それを使用してジャブジャブの声に関する証明を述べます。

class taking:
    def __init__(self, n): convenient.val = (n)
    def __enter__(self): pass
    def __exit__(self, type, value, traceback): pass
def a(x,y): x.val = y(x.val); return True
class We:
    def __init__(self): self.val=0
    def __add(self, y): return y+sum(self.x)
    def add(self, *x): self.x = x; return self.__add
    def multiply(self,x,by,diminished_by): self.val *= by-diminished_by
    def proceed2divide(self,x,by): self.val /= by
    def subtract(self,x): self.val -= x; return True
perfectly = lambda x: x and not not x
def must_be(x):
    if x: 
        print "\n".join(["Tis the %s of the Jubjub!"%["voice","note","song"][x%3] for x in range(out.val)])
        return out.val
out=convenient=as_you_see=we=then=the=We()
_ = exactly = 15
with\
\
    taking(3) as the_subject_to_reason_about:
    a(convenient, #2 state
    we.add(7,_ & 10)) and then.multiply(out,
    by=1000, diminished_by=8)

    the_result = we.proceed2divide(as_you_see,
    by=992)
    then.subtract(17) and the; answer = must_be(
    exactly and perfectly(True))

元のテキスト:

「理由の主題として3を取り上げる-州
にとって都合の良い数-
私たちは7と10を足し
、8で1000分の1を掛けます。

「結果は、ご覧の
とおり、「ナインハンドレッドアンドナインティツー:By
17」を差し引くと、
正確に完全に真実でなければなりません。


それはいいです、私はそれが好きです。 Originality: 8/10Song difficulty: 4/10Representation of that song in code: 15/20、あなたの最終的なスコア27恥作るあなたは曲全体を使うことができませんでした。
ニール

2
「歌全体」の基準にはかなりの重みがあると思います。1行の曲を選ぶ方がずっと簡単だったでしょう。
ウゴレン

「スナークの狩り」の長さが500行を超えることを考えると、それは実に印象的な偉業だったでしょう。
ブレッドボックス

1
@ breadbox、1回のフィットでも印象的な偉業になり、すべてが苦痛になります。
ウゴレン

6

Python(8 + 7 + 15 = 30)

有効なPythonコードは同期的に有効ですが、特に便利なことは何もしません;-)

from sys import exit as stops ; import os
thing = [] ; me = can = remember = False ; this = open(__file__)
def terrible(v): return v

# ==== start song snippet

me = can = remember = not any(thing)
can = not this.tell(), [True, "dream"]
locals()["deep"] = {"down":{"inside":{"feel_to":"scream"}}}
if `this` + (terrible("silence")): stops(me)

# ===== end song snippet

読み方:

何も思い出せません。
これが真実か夢かはわかりません。
心の奥深くで私は悲鳴を上げます。
このひどい沈黙は私を止めます。
...
(メタリカ-1)


うわー、難しい曲の選択ですが、どうやってそれをやってのけたかにとても感動しました。 Originality: 8/10Song difficulty: 7/10Representation of that song in code: 15/20、あなたの最終的なスコア30作る
ニール・

5

C

ややずさんな、笑いのために約15分でこれを書きました。G ++ / MinGWの最新バージョンでコンパイルして正常に動作します(ただし、実際にはあまり機能しません)。あなたはこれを自分でうまく理解することができます、私は思う:

class Rick {

public:

    struct us { bool you; bool me; };

    bool giveYouUp()  { return false; }
    bool letYouDown() { return false; }
    bool runAround()  { return false; }
    bool desertYou()  { return false; }
    bool makeYouCry() { return false; }
    bool sayGoodbye() { return false; }
    bool tellALie()   { return false; }
    bool hurtYou()    { return false; }

    bool thinkingOf(bool whatImThinkingOf) { return whatImThinkingOf; }
    bool justWantTo(bool whatIWantToDo) { return whatIWantToDo; }
    bool tellYou(bool whatIWantToTellYou) { return whatIWantToTellYou; }

    void roll() {
        bool gonna = false;
        while (gonna) {
            giveYouUp();
            letYouDown();
            gonna = (runAround() && desertYou());
            makeYouCry();
            sayGoodbye();
            gonna = (tellALie() && hurtYou());
        }

        bool strangersToLove = true;
        us we = {!strangersToLove, !strangersToLove};

        bool knowTheRules = true;
        bool you = knowTheRules, I = knowTheRules;

        bool aFullCommitment = true;
        we.me = thinkingOf(aFullCommitment);

        int me = 0;
        Rick* guys[] = {this, nullptr, nullptr, nullptr, nullptr};

        bool howImFeeling = true;
        we.me = justWantTo(tellYou(howImFeeling));

        bool understand = true;
        while (we.you != understand) {
            we.you = understand;
        }
    }

};

int main() {
    Rick rick;
    rick.roll();

    return 0;
}

2

Scala(48 = 2 *(7 + 4 + 13))

Linuxです!歌。

object Song extends App {
  // Compose a song
  trait Compose {
    override def toString = {
      val token = """^.*\$(.*)\$.*$""".r
      val token(verse) = super.toString
      verse.replaceAll("([a-z])([A-Z])", "$1 $2").capitalize
    }
    def excl(ex: String) = println(this + ex)
    def !!(c: Compose) = { excl("."); c }
    def ***(c: Compose) = { excl("..."); c }
    def !(c: Compose) = { excl("!"); c }
    def *(c: Compose) = { excl(","); c }
    def ! = excl("!")
  }
  // It's linux  - lyrics
  case object ItBootsUpFine extends Compose
  case object AllOfTheTime extends Compose
  case object TuxThePenguinIsGreat extends Compose
  case object aPieInTheFace extends Compose
  case object ToTheManIHate extends Compose
  case object EveryoneKnowsItsLinux extends Compose
  case object StableForYouAndMe extends Compose
  case object ItsLinux extends Compose
  case object NoMoreBSODs extends Compose
  case object BetterThanNT extends Compose
  case object BestOfAllItsFree extends Compose
  case object FreeSoftwareForYouAndMe extends Compose
  case object LinuxGPLd extends Compose

  // Singer to sing a song
  def sing(song: => Unit) = { song }

  // Song begins
  sing {
      ItBootsUpFine!
      AllOfTheTime!!
      TuxThePenguinIsGreat!
      aPieInTheFace*
      ToTheManIHate***
      EveryoneKnowsItsLinux!
      ItsLinux!
      ItsLinux!
      StableForYouAndMe!
      ItsLinux!
      ItsLinux!
      NoMoreBSODs!
      ItsLinux!
      ItsLinux!
      BetterThanNT!
      ItsLinux!
      ItsLinux!
      BestOfAllItsFree!
      FreeSoftwareForYouAndMe***
      LinuxGPLd!
  }
  // Song ends
}

出力:

It Boots Up Fine!
All Of The Time.
A Pie In The Face,
Tux The Penguin Is Great!
To The Man IHate...
Everyone Knows Its Linux!
Its Linux!
Its Linux!
Stable For You And Me!
Its Linux!
Its Linux!
No More BSODs!
Its Linux!
Its Linux!
Better Than NT!
Its Linux!
Its Linux!
Best Of All Its Free!
Free Software For You And Me...
Linux GPLd!

Originality: 7/10Song difficulty: 4/10Representation of that song in code: 13/20。曲全体を書き留めるので、スコアは2倍になり、最終スコアは48になります。いいですね。:)
ニール

1

PHP

私の好きな歌、天国への階段を試しました。

$GLOBALS['sign']= 'words';

class lady extends me // there is a lady
{
  function __construct(){   // who is sure
    global $glitters = 'gold'; // all that glitters is gold
    $buy('stairway_to_heaven'); // and shes buying the stairway to heaven
  }
  $know[] = 'stars are close'; // when she get's there she knows, the stars are close
  function word(){  // with a word she can get
    debug_backtrace(); // what she come for
  }

  $this->buy('stairway_to_heaven'); // and she's buying the stairway to heaven

  $sign = 'words'; // there is a sign on the door
  if(!$sign === $GLOBALS['sign']) // but she want to be sure, cause you know sometimes words have 2 meanings
    exit();

  in_array($tree / $brook, $songbird ? 'sings'); // (literal) in a tree by the brook, there is a songbird who sings

  mysql_real_escape_string($_GET['thoughts']); // sometimes all of our thoughts are misgiven
  for ($i=0;$i<2;i++)
    parent::wonder(); // makes me wonder , makes me wonder

}

読み方:

きらきら輝くものはすべて金だ
と確信している女性がいて、天国への階段を買っています。
彼女がそこに
着いたとき、彼女は知っています、星がすべて近いなら、彼女は言葉で彼女が来たものを得ることができます。
ああ、ああ、彼女は天国への階段を買っています。

壁にはサインがありますが、彼女は
「言葉には2つの意味があることを知っているからです」と確信したいと思っています。
小川のそばの木に、歌う鳴き鳥がいます。
時々、私たちの考えのすべてが間違っています。
おお、それは私を不思議に思う、
おお、それは私を不思議にさせる。


1

C

これが完全な歌です。
あなたはママ・リサの世界でそれを聞くことができます。
句読点を含め、曲はそのまま含まれていることに注意してください。

#define breath,
#define smell breath
#define an;}Englishman; main(){printf("%d\n",sizeof
struct x{int
// Song starts here
Fee, fa, fie, fo, fum,
I smell the breath of an Englishman.
// Song ends here
I);}

数字4を印刷します。


1

ルビー

私は可能な限り厳密な表現を取り入れています。Rubyのコールチェーンを使用すると簡単です。

$lines = []

def thisline n=2
    caller(n).first.match(/:(\d+):/)[1].to_i
end

class Chain < Array
    def method_missing method, *args
        $lines[thisline] = Chain[first, self[1], [method, thisline, args]]
    end

    def -(arg)
        $lines[thisline] = Chain[' - ', thisline, self, arg]
    end

    def tokens
        if size < 3
            if first == :_
                []
            else
                [first.to_s.tr(?_, ?\s).strip]
            end
        elsif size < 4
            [first.to_s.tr(?_, ?\s)] + at(2).tokens
        else
            lhs = case el = at(2)
            when Chain then el.tokens
            when String
                el.empty? ? [?'] : [?', el, ?']
            end

            rhs = case el = at(3)
            when Chain then el.tokens
            when Range then el.first.tokens + ['... '] + el.last.tokens
            end

            lhs + [first.to_s.tr(?_, ?\s)] + rhs
        end
    end
end

def self.method_missing method, *args
    line = thisline(3)

    if args.length > 1
        newlines = args.first.is_a?(String) ? args.first.count(?\n) : 0
        $lines[line] = false
        $lines[line-newlines] = Chain[method, line, Chain[', ', line, *args]]
    else
        $lines[line] = Chain[method, line, *args]
    end
end

####################

The pest in_the eyes of death follows us
Through the dirty streets of blood
It begins to eat inside us, decaying_our_bones
How will we escape_if the void covers our lungs?
We are buried_in the spewed trash_for ourselves

Blood _, pain - nothing_to_say
Why then_- must_we_die?

Escape to the void
Escape to the void

I look at my face on the other side of the mirror
My face falls down_in pieces full of worms
I burst my rotten heart with my own hands
I'm dying and I can',t_help_myself

Blood _, pain - nothing_to_say
Why then_- must_we_die?

What have I been running from?
I'',m_not_guilty
You've shown me the worst way
Cause you',re_my_victim... the_next_one

The pest in_the eyes of death follows us
Through the dirty streets of blood
It begins to eat inside us, decaying_our_bones
How will we escape if_the void covers our lungs?
We are buried in_the spewed trash_for ourselves

Blood _, pain - nothing_to_say
Why then_ - must_we_die?

Escape to the void
Escape to the void

####################

$lines.drop_while {|line| !line }.each_with_index {|line, i|
    puts if line.nil?
    next if not line

    line = line.tokens
    line.map!.with_index {|el, j|
        punct = [', ', ' - ', '... ', ?']

        if line[j-1] == ?' and el == ', '
            ''
        elsif punct.include?(el) or punct.include?(line[j+1])
            el
        else
            el + ?\s
        end
    }

    puts line.join
}

出力

The pest in the eyes of death follows us 
Through the dirty streets of blood 
It begins to eat inside us, decaying our bones 
How will we escape if the void covers our lungs? 
We are buried in the spewed trash for ourselves 

Blood, pain - nothing to say 
Why then - must we die? 

Escape to the void 
Escape to the void 

I look at my face on the other side of the mirror 
My face falls down in pieces full of worms 
I burst my rotten heart with my own hands 
I'm dying and I can't help myself 

Blood, pain - nothing to say 
Why then - must we die? 

What have I been running from? 
I'm not guilty 
You've shown me the worst way
Cause you're my victim... the next one 

The pest in the eyes of death follows us 
Through the dirty streets of blood 
It begins to eat inside us, decaying our bones 
How will we escape if the void covers our lungs? 
We are buried in the spewed trash for ourselves 

Blood, pain - nothing to say 
Why then - must we die? 

Escape to the void 
Escape to the void

やること

  1. 複数行のコンマ(引数)
  2. 複数行のドット(メソッド呼び出し)

0

T-SQLボーンサグスアンドハーモニー

DECLARE @line1 varchar(25);
DECLARE @line2 varchar(25);
DECLARE @line4 varchar(25);
DECLARE @line5 varchar(25);

SET @line1 = 'Wake up, wake up, wake up,';
SET @line2 = 'its the';
SET @line4 = 'to get up, get up get up';
SET @line5 = 'so cash your checks and get up';

SELECT @line1 as Layzie, @line2 as Bizzy,
CONVERT(date,DATEADD(day, -
(SELECT
DATEPART(day, GETDATE()) 
- 1), GETDATE())) as FirstOfTheMonth,
@line4 as Layzie, @line5 as Bizzy;

うん、少しだまされたのは知っているし、間違ったラインを歌ったメンバーもいるかもしれない。


0

C-ビールの瓶

これをコンパイルして実行します。歌詞はソースコードに入れられます。出力をコンパイルして実行し、曲の次の行を取得します。「Time to go ....」と表示されたら、コマンドラインで指定された数のボトルでコンパイルして実行します。例:

cl prog.c
prog 32 > prog1.c
cl prog1.c
prog1 > .... etc

VS2005を使用してテストしたコード:-

// Time to go to the shop and get some beer
//
//
//
//
// #####.#####.#####.#####.#####.#####.#####
// ##.#####.#####.#####.#####.#####.#####.##
// #####.#####.#####.#####.#####.#####.#####
// ##.#####.#####.#####.#####.#####.#####.##

char *z [] = {
"void l(char *s,int b){int i;printf(\"// \");for(i=0;i<b;++i)printf(s);",
"printf(\"\\n\");}\nint main(int argc, char *argv[]){\nint i,j,k,x=%d;",
"char*p;\nif(!x&&argc==2)x=atoi(argv[1]);\nif(!x){printf(\"// Time to ",
"go to the shop and get some beer\\n//\\n//\\n//\\n//\\n\");k=7;\n",
"}else{printf(\"// %%d bottles of beer on the wall, %%d bottles of beer",
".\\n\",x,x);printf(\"// Take one down and pass it round, \");\n",
"if(x>1)printf(\"%%d bottles of beer on the wall.\\n//\\n\",x-1);\n",
"else printf(\"no more bottles of beer on the wall.\\n//\\n\");\n",
"k=x>2?x:2;l(\"  ^   \",x);l(\" / \\\\  \",x);l(\"/   \\\\ \",x);",
"l(\"|   | \",x);l(\"|Duf| \",x);l(\"|   | \",x);l(\"----- \",x);}\n",
"for(i=0;i<4;++i){\nprintf(\"// %%s\", i&1 ? \"##.\" : \"\");\n",
"for(j=i&1;j<k;++j)\nprintf(\"%%s#####\",j!=(i&1)?\".\":\"\");\n",
"printf(\"%%s\\n\",i&1?\".##\":\"\");}\nprintf(\"\\nchar *z [] = {\\n\");\n",
"for(i=0;i<sizeof z/sizeof z[0];++i){\nprintf(\"\\\"\");\n",
"for(p=z[i];*p;++p)\nswitch (*p){\ncase '\\n':printf(\"\\\\n\");break;\n",
"case '\\\\':printf(\"%%c%%c\",92,92);break;\n",
"case '%%':printf(\"%%c\",37);break;\ncase '\"':printf(\"%%c%%c\",92,'\"');break;\n",
"default:printf(\"%%c\", *p);break;}\nprintf(\"\\\",\\n\");}\n",
"printf(\"};\\n\");\nfor(i=0;i<sizeof z/sizeof z[0];++i)\n",
"printf(z[i],x?x-1:0);}\n",
};
void l(char *s,int b){int i;printf("// ");for(i=0;i<b;++i)printf(s);printf("\n");}
int main(int argc, char *argv[]){
int i,j,k,x=0;char*p;
if(!x&&argc==2)x=atoi(argv[1]);
if(!x){printf("// Time to go to the shop and get some beer\n//\n//\n//\n//\n");k=7;
}else{printf("// %d bottles of beer on the wall, %d bottles of beer.\n",x,x);printf("// Take one down and pass it round, ");
if(x>1)printf("%d bottles of beer on the wall.\n//\n",x-1);
else printf("no more bottles of beer on the wall.\n//\n");
k=x>2?x:2;l("  ^   ",x);l(" / \\  ",x);l("/   \\ ",x);l("|   | ",x);l("|Duf| ",x);l("|   | ",x);l("----- ",x);}
for(i=0;i<4;++i){
printf("// %s", i&1 ? "##." : "");
for(j=i&1;j<k;++j)
printf("%s#####",j!=(i&1)?".":"");
printf("%s\n",i&1?".##":"");}
printf("\nchar *z [] = {\n");
for(i=0;i<sizeof z/sizeof z[0];++i){
printf("\"");
for(p=z[i];*p;++p)
switch (*p){
case '\n':printf("\\n");break;
case '\\':printf("%c%c",92,92);break;
case '%':printf("%c",37);break;
case '"':printf("%c%c",92,'"');break;
default:printf("%c", *p);break;}
printf("\",\n");}
printf("};\n");
for(i=0;i<sizeof z/sizeof z[0];++i)
printf(z[i],x?x-1:0);}

1
ASCIIアートについては謝罪しません!
スキズ

1
かなり印象的ですが、それはどのように挑戦にマッチしますか?アイデアは、ソースを歌として読むことができると思った。
ウゴレン

1
@ugoren:単一のパラメーター(ビールの開始数)で実行可能ファイルをコンパイルして実行します。次に、プログラムは歌の最初の詩をソースコードとして出力します(一番上のコメントの歌詞)。出力をコンパイルし、再度実行して次の詩を取得します。
スキズ

とてもいいですが、アイデアは歌を印刷するプログラムではありません。それは、そのソースが読まれたとき、歌であるプログラムです。
ウゴレン

0

PerlはBarnes&Barnesを実行します

私が最初にPerlを学んで以来、この-Pオプションを使用する言い訳が必要でした。今日、その言い訳がついに到着しました。

#define cry $$
#define people $_
#define some kill
#define we people
#define whenyoudie END
sub yeah{}

# "When You Die", Barnes & Barnes

whenyoudie { you stop drinking beer }
whenyoudie { you stop being here }
whenyoudie { some people,cry }
whenyoudie { we=say "goodbye" }

                yeah

次のよう-M5.010に、-Pオプションに加えてそれを実行します:

$ perl -PM5.010 whenyoudie
goodbye
Hangup
$ 
弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.