노래 코딩-선택한 프로그래밍 언어로 음악 가사 표현 [닫기]


13

노래를 읽을 때 가사를 선택하는 언어로 프로그램을 작성하십시오. 그것은 해야한다 컴파일 오류없이 실행할 수있는 유효한 프로그램합니다. 기술적으로 모든 가사를 화면에 인쇄 할 수는 있지만 가능하면 스타일을 사용하고 문자열 리터럴을 피하는 것이 좋습니다.

이것이 그 자체로는 어렵다는 것을 감안할 때, 가사 판에서 읽을 수있는 것으로 간주되지 않는 단일 부분의 상용구 코드를 작성할 수 있습니다. 그러나 노래의 가사로 읽어야하는 코드 블록이 시작되면 노래가 끝날 때까지 중단 할 수 없습니다. 곡 코드의 시작과 끝을 주석으로 표시 할 수 있습니다. 코드를 읽을 때 가사 자체도 지정하십시오. 쓰여진 내용에서 너무 멀리 벗어나지 않는 한 해석에 "자유"적일 수 있습니다. 그렇지 않으면 포인트가 부과됩니다.

부분 노래 가사는 허용되지만 전체 노래에 단어가 있으면 두 배의 포인트를 얻습니다. 심사는 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
이것은 흥미로운 개념이며 결과를보고 싶습니다. 그러나 이것은 객관적이지 않습니다. 노래의 '어려움'을 어떻게 결정합니까?
Gaffi


@Gaffi, 주로 길이뿐만 아니라 wordiness. 0 점을받는 노래의 예는 이 노래의 길이가 6 단어에 불과 합니다.

방법에 대한 HQ9프로그램 9? : P
Li-aung Yip

1
코딩에 적합한 노래를 찾으려고하는 사람을위한 힌트 : "공허로 탈출"은 유망한 제목 인 것 같습니다 :)- lyricstime.com/sepultura-escape-to-the-void-lyrics.html
Cristian Lupascu

답변:


8

파이썬-8 + 4 + 15 = 27 포인트

여기는 Lewis Carroll 의 Snark사냥 에서 온 몇 가지 스탠자에 있습니다 .
시에서 제안한 알고리즘을 기반으로 숫자를 계산하고 jubjub의 음성에 대한 증거를 나타내는 데 사용합니다.

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을 더한 다음
1 천을 곱하여 8로 줄었다.

"우리가 아시다시피, 우리는 결과
를 나인 백과 나 인티 2 : 으로 나눕니다 :
그리고 나서 열일곱을 빼면 그 답은
정확하고 완전 해야 합니다.


좋아요, 좋아요 Originality: 8/10, Song difficulty: 4/10, Representation of that song in code: 15/20, 최종 점수 27 부끄러운 만드는 당신은 전체 노래를 사용할 수 없습니다.

2
"전체 노래"기준이 너무 무겁다 고 생각합니다. 한 줄 곡을 선택하는 것이 훨씬 쉬웠을 것입니다.
ugoren

Snark의 Hunting이 500 줄 이상인 것을 감안할 때, 그것은 실제로 인상적인 업적이었습니다.
breadbox

1
@ breadbox, 심지어 단일 맞춤조차도 인상적인 업적 일 것입니다. 모든 것이 고통 스럽습니다.
ugoren

6

파이썬 (8 + 7 + 15 = 30)

유용한 파이썬 코드는 동 기적으로 유효하지만 특별히 유용한 것은 없습니다. ;-)

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

읽는 방법 :

아무것도 기억 나지 않습니다.
이것이 사실인지 꿈인지 알 수 없습니다.
깊은 곳에서 나는 비명을 지른다.
이 끔찍한 침묵은 나를 멈춘다.
...
(메탈리카-하나)


와우, 어려운 노래 선택, 그러나 당신이 그것을 뽑아내는 방법에 매우 감동했습니다. Originality: 8/10, Song difficulty: 7/10, Representation of that song in code: 15/20, 최종 점수 (30) 만들기

5

다소 엉뚱한, 나는 이것을 약 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

스칼라 (48 = 2 * (7 + 4 + 13))

리눅스입니다! 노래.

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/10, Song difficulty: 4/10, Representation of that song in code: 13/20. 전체 노래를 내려 놓으면 점수가 두 배가되므로 최종 점수는 48입니다. :)
Neil

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

}

읽는 방법 :

반짝이는 것이 모두 금이라고 확신하는 여성이 있습니다.
그리고 그녀는 천국의 계단을 사고 있습니다.
그녀가 그곳에 도착했을 때, 별들이 모두 가까이 있다면,
그녀는 그녀가 온 것을 얻을 수 있습니다.
오, 그리고 그녀는 천국으로가는 계단을 사요.

벽에 표시가 있지만 그녀는 확신하기를 원합니다.
왜냐면 때때로 단어에는 두 가지 의미가 있다는 것을 알기 때문입니다. 개울가
의 나무에는 노래하는 새가 있는데,
때때로 우리의 모든 생각이 잘못되었습니다.
오, 정말 궁금해,
오, 정말 궁금해


1

다음은 완전한 노래입니다. Mama Lisa 's World
에서들을 수 있습니다 . 문장 부호를 포함하여 노래가있는 그대로 포함되어 있습니다.

#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 뼈 깡패 -N- 하모니

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 아트에 대해 사과하지 않습니다!
Skizz

1
상당히 인상적이지만 도전과 어떻게 일치합니까? 소스를 노래로 읽을 수 있다고 생각했습니다.
ugoren

1
@ugoren : 시작 맥주 수인 단일 매개 변수로 실행 파일을 컴파일하고 실행하십시오. 그런 다음 프로그램은 노래의 첫 번째 구절을 소스 코드 (최고 주석의 가사)로 출력합니다. 다음 구절을 얻기 위해 출력을 컴파일하고 다시 실행하십시오.
Skizz

아주 좋지만 아이디어는 노래를 인쇄하는 프로그램이 아닙니다. 소스를 읽을 때 노래가되는 프로그램입니다.
우고 렌

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.