# Question
Title: Valentine's day greetings card generator
Create a program that, given a name as input, will generate a Valentine’s day greeting card featuring that name, with its source code also having a Valentine’s day theme. The greeting can be either ASCII art or a generated picture.

Additional conditions:

* The source code has to **look** like something Valentine's day themed (like a heart, or a poem or anything. Be creative)
* All code and related assets need to fit into your answer.
* You can use network connections, but you can only download this page (in case this question acquires multiple pages you can download them as well). You can use the StackApps API if you want to.
* The "has to look like something Valentine's day themed" rule also applies to anything you try to use from this page (if using network connections).
* No other external files are permitted.
* You can use the standard library of your language, but no external packages are allowed.

Other restrictions:

* None. This is a popularity contest.

Scoring:

* Each visible vote (= upvotes minus downvotes) is worth 10 points
* For every two upvote on a comment on your answer you get 1 points
* Answer having the most score will be accepted on Valentine's day (14 Feb 2014)

\**This contest is now closed, thanks for participating! \** You can still add answers if you'd like though

# Answer
> 43 votes
## C

What can be more romantic than syntax highlighting?

```
  *xx=       "De"
 "ar %"     "s:\n"
"Consta"   "nts ar"
"e red, " "variable"
"s are blue.\nIf lo"
"ve had a syntax, I"
 "'d highlight you"
  ".\n",n[9];main(
    ){printf(xx,
      gets(n))
        ;xx;
         }

```

Output:

```
$ echo Ilana | ./vanentine
Dear Ilana:
Constants are red, variables are blue.
If love had a syntax, I'd highlight you.

```

# Answer
> 36 votes
# Java 8, 500 lines of code

This is the longest entry that I had ever did here in codegolf. It is in the form of a java program constituted from the concatenation of the lyrics of 7 different songs that I composed just for this competition. Looking back in time, I am convicted that I am really crazy to create this thing just for this competition, and some verses are still repeating over and over with rhymes in my head.

Comments were very abused, so I could write **everything in the program to be within verses**, except for a short guitar solo in the end of the second song. There is no blobs of characters left hidden somewhere. In fact, I did not thought that to write music as poems with rhymes that could be compiled and run by a java compiler to do something not trivial was damn so hard, specially writing poems with terms like `AffineTransform`, `BufferedImage`, `Graphics2D` and `newScheduledThreadPool`.

The program itself is somewhat complex. It does show a screen with an animation of a rotating heart, some stars and a message for your beloved-one. All of that is done with linear algebra, primitives drawing, setting pixels, text drawing and sprites.

EDIT: Bugfix to reduce the font size to avoid text cuttings.

To run it:

```
java that_day <The name of your girlfriend/boyfriend>

```

If you omit your girlfriend/boyfriend name, it will show the usage and default to my name (Victor) instead. This is some sort of mark I left as a form of some personal signature.

Here is its source:

```
// ******************************************
// TRACK 1: THE GREAT LOVE IN THE JAVA ISLAND
// ******************************************

/* Do you ever */ import /* ?
|* If in the */ java /* island */.
/* There was a sign that once said:
*/ awt. /* what is this crazyness?*/*;

/* Or maybe instead,
|* Do you really */ import /* if in the */ java /* island */.
/* they really said */ awt.geom. /* instead? */*;

// Or even maybe,
/* Do you */ import /* if all that */ java.awt. /* had some */ image/*? */.*;
/* Do you */ import /* if that */ java /* has a */ .util.concurrent/*? */.*;
/* Do you */ import /* if that */ java /* has some */ .util.Random; // game?
/* Do you */ import /* if that */ static java /* has some */. lang/*uage or */. Math /* class? */.*;

// And then
/* We do */ import /* about all those */ javax // stuff
/* So, lets play in the school */ .swing /* like the old times, oh my honey?*/.*;

// In the school
/* I were in my */ class that_day{ //
/* And some */ Random stuff // the teacher were saying
=/* all that I wanted was a*/ new Random /* game to play*/(

); // But then you came!!!! */
/* And I felt the */ GreatLove /* in my */ heart,
/* you, were my */ star, /* you were all my */ life;

/* In that */ class
/* I saw my */ GreatLove // in your face
/* I was so happy that i wanted to */ extends /* a */ BufferedImage //!!!
{/* that */ GreatLove /* was */( int resting, /* and so */ int tense

/* i felt */){ super(//!!!
/* no */ resting, /* I was so */ tense,
/* I was sure that I wanted*/ 2 /*love you*/);

}}/* I would */ boolean your_heart(
/* a day */ long /*in*/ YourArms, long /*in*/ your_arms, long /*IN*/ YOUR_ARMS // OH YEAH!
){ /* I want to*/ return /*to*/ YourArms * /*, to return to */ YourArms +/* to return to*/ your_arms // OH YEAH!
/* to return to*/* your_arms </* to return to*/ YOUR_ARMS /*to return to*/* YOUR_ARMS;} // OH YEAH

// *******************************************
// TRACK 2: THE STRING GUIDING MY LIFE, PART I
// *******************************************

/* In the */ public//, you said you did not wanted me!
/* I frooze */ static /* and felt a */ void /* inside */
/* coz you were the */ main (String[] guiding_my_life

){ if (guiding_my_life /* was a string with such */ .length
/* I felt like I was */ == 0 // in that date.
){ /* That was the */ System. /* and i were */ out.
/* So i */ print//d this letter for you,
/* Remember, */( "usage is java that_day and-put-here-yours-love-name");

/* I was in a cinema's */} EventQueue.
/* I got your number, was going to */ invokeLater(()
-> /* But this day is a */ new //day
/* A day like */ that_day

/* Are you */ ((guiding_my_life/*? Even when its */. length == 0?
/* You are the */ new String[] /* of my life?
   Would I be a */ {"Victor"} : /* with my string */guiding_my_life)//?
[  0-0-0-0-0-0/*HHHHHH YEAH!*/]))

;} that_day
/* you are the */( String guiding_my_life) {
/* a */ int tense /* feeling with a level */ = 1000;
/* a */ long missed /* one with a number */ = 466,

/* I looked for your */ door /*. Now I know, its number is */ = 279,
/* but missed */ because /* I was looking for */ = 379,
/* I was so */ crazy /* that i looked even at the number */= 261, /* and */ number = 534;

/* And my */ heart /* was */ = /* that */ new GreatLove
/* Oh I was so */(tense, /* Oh I was so */ tense); // Oh yeah!

/* And then I am */ for/*ever*/ (int erested /* in you */ =000000000 ;// YEAH;
/* int*/erested </*in your in*/tense /*love*/;
/* int*/erested ++ // forever!

){ for/*ever */(int/*erested */ i_was =0-0-0-0-0-0//0-0-0-0-H-H-H-H-H-H YEAH
 ; i_was </*so*/ tense; i_was ++ // so tense, oh yeah!

){/* but, I knew that */ if (i_was +/* so */ missed >// by you
/* and you were too int*/erested
   & i_was -/* so */ missed </* and */ tense-
/* so int*/erested

   & (/*in*/ your_heart(
   i_was -/* looking at that */door,
/* int*/erested /*in you*/- because, /* i am */ crazy /* for you */)|

   your_heart
(  i_was -/* so */ tense +/*at your*/ door,
/* int*/erested /*in you*/- because, /* i am */ crazy )/* for you */|
/* int*/erested /*in your*/> number
|( i_was /**/> missed /* that much */ & i_was </* so */ tense
-  missed /* you too much */ & /*I am so int*/erested /*and*/> crazy)))

/* To your */ heart.
/* I would */ setRGB /* there */(
/* because */ i_was, /*int*/erested,

        // GUITAR SOLO:
        0XFFFF000___0 //0XF00_00X0__XF0F_0F0F0___00 F0X_F0F0X__FFF0X0__F000!!!
);      //F0000 0XF0_0XF0_0XF0 F0F0F0__F0F0F0__F0F0F000000000!
}}      // 0xFFFFFF000000000-0-0-0-00000000000000  X0_X0_X0_X000 YEAH!

/* You are my */ star=
// like you, no one will go so far
/* my */ new GreatLove( // you are

/* I was so */ tense, /* I was so */ (int)tense);
// OH YEAH!

// ****************************************
// TRACK 3: INTREPID INTUITIVE INTELLIGENCE
// ****************************************

   int[]repid /* I am, this is */ = /* my */ new int/*elligence*/[
/* Just */ 5 /* days I wait */];
/* This is my new */ int[]elligence
=/* my */ new int/*elligence*/

[  5 /* years */]; for // now
(  /* Is this */ int uitive // or nah?
=  0//r nah?
;  /*int*/uitive </*for*/ 5 //years
;  /*int*/ uitive
++ // Or nah?

){ /*int*/repid [/* or int*/uitive]
/* Is this */ = /* to */ (int)//elligence?
(  cos /* the */ (toRadians( 90+ // aliens came
// They came! they came!

/* From the */ 144 *
/* How this is int*/uitive)) /* how???

1- Oh, this */ * /* is so */ tense /
2- /* It is so */ -tense /( /*
3- /* It is so tense */
4- /* It is like */ 2 /* times so tense.*/)

); /* This is my int*/elligence[
/* My int*/uitive /* intelligence*/]=
(  int/*elligence*/)

(/* And the */ sin /* of the */( toRadians (90+ // aliens
/* is that they did not got my int*/uitive * // intelligence
1__44 /* times */)) /* that was so */* tense /
2  + /* the times this was so in*/tense /
   2 /* intense*/);}

// *******************************************
// TRACK 4: THE GRAPHICS OF THE LOVE IS A STAR
// *******************************************

/* The */ Graphics of_the_love /* is */ = /* to a */ star.
   getGraphics /**/();/**/ of_the_love /* and then */.setColor( // of the star
/* A */ Color /* that was something like */ .YELLOW
); /* The shape */ of_the_love /* is draw when you */.fillPolygon // of the star.

/* You have your reputation id, its the */( repid,
/* And you use it with much d*/elligence,
   5 /* times each day */);
/* You do discover */ life // again
= /* Its happy to see my */ new GreatLove // everyday

(/* I am so excited and a bit*/ tense,
/* I had that feeling so in*/tense);
/* The */ Graphics of_your_heart /* is*/ = /* to the */ life // of a star
.  getGraphics /**/();/**/ of_your_heart /* and then */.setColor( // of the sky
/* A */ Color /* that was something like */ .CYAN

); /* In the letters */ of_your_heart /* you */ .setFont
(/* And when you remember */ of_the_love /* you */.getFont().
/* In the happiness, please */ deriveFont /* everyday */(
/* You might do it only */ 1 /* time or even */, 67));
/* But do remember */ of_your_heart /* everyday */.

// ********************************************
// TRACK 5: THE STRING GUIDING MY LIFE, PART II
// ********************************************

/* Yesterday, I have */ drawString
 ( "Hey, " + /* I have to say that you are the string that was */ guiding_my_life
   + /* I say, plus I say, hey: */ ", I love you",
   20 /* times that I will say */,
   /* it was so */ tense /* but i will say it *// 2 -
   50 /* times that I will say */);

/* John */ JFrame /* is the name of my */ neighbour // in the next door
   = // him, I had no such friend as before
/* Some day I asked him for some */ new//s
/* Then */ JFrame /* said I got a letter and the sender was: */(

        "I love you, "+

/* it was nobody else but the string */ guiding_my_life);
/* I am so grateful to my */ neighbour /* coz he */ .setBounds(
/* I was */ 10 /* times excited and */, 10 // times happy
/* My emotion was at */, 500 /* percent */,
/* When I read the letter I falled in love */ 500 /* rounds */);

   MY_TRUE_LOVE /* was */ back_for_me
/* There is nothing */ = /* or even like this */
/* So I had a */ new /* chance, */ MY_TRUE_LOVE(); // finally came
/* And was my */ neighbour /* who */ .add(/* she */ back_for_me);
/* My */ neighbour. /* was great, he */ setVisible( /* me again
|| my */ true /* love was back to me! */);

// So I defined a new plan
/* and */ Executors /* it then */.
/* with a */ newScheduledThreadPool( /* For */ 1 /* time I had my love back again */).
/* and I */ scheduleWithFixedDelay(()
-> /* back in the cinema's */ EventQueue. /* I came
|| and then I */ invokeLater(() // her cellphone again!
-> /* She was finally */ back_for_me /*,
|| and the only difference was that her hair got a */ .repaint()),

/* I was feeling as a */ 0 /* before */,
/* Now I feel */ 50 // times more worth.
/* in each */, TimeUnit. /* of just some */ MILLISECONDS /* I'm love.*/);

/* And I won't forget my */ neighbour.
/* Just to */ setDefaultCloseOperation(
/* Now that I have a love and a great friend, we */ 3 /* really rocks!*/);}

// *************************************
// TRACK 6: HOMEWORK ABOUT A BORING BOAT
// *************************************

/* Last year in my */ class I_MET{ /* my */ GreatLove
   she; /* was so lovely that I knew: */ I_MET( /* my */ GreatLove
/* I was sure that she was really */ my_love
){ she /* is */ = /* to an angel, she is all */ my_love;}

/* Oh yeah, man she is */ double pretty, very_nice, /* and much */ talented,
/* She just should be my, beloved */ girl,friend;
/* But the teacher would */ void /* my weekend, he gave a homework:
/* to */ draw /* some stupid */(Graphics2D/*, of a boring */ boat) {

/* What I didn't knew, was that weekend would, */ AffineTransform my_life
=/*that */ new AffineTransform /* happened, really */()/*vernight. */;
/* The teacher said, the homework should be done in */ double//s
// And that was really when my chance came.

// I invited she, to join me in the homework
/* And she came to my house, because a */ boring //boat
= /* And */ she ./* measured the boat and */ getHeight
  (),vernight /* I managed */= she /* to */.getWidth ()/*n the same! */;

   my_life /* would change and then */ .rotate(
/* When she said that she had trouble in convert */ toRadians (
/* But in that stuff, I was really */ talented//!!!

),/* And because of that */ boring /* homework *//
/* We */ 2, /* got together O*/vernight /*, working on that boat. *//
/* The life of we */ 2 /* was about to */); AffineTransform // in that day
/* When she */ kissed_my_mouth // at midnight and ten.

/* For us both, that feelling was */ =/*lly*/ new
/* An */ AffineTransform ()/*n that night, that was for real */;
/* When she */ kissed_my_mouth/*, the feeling I can't */ .translate(-
   my_life. /* was */ transform/*ed*/( /* to a */ new // plane!

/* Working in a */Point2D. /*A homework in */Double(
/* She was really */ talented /*, but with */ >90 // percent done
/* I was so sad when she needed to go back to her home!

*/ & /* had i already said how she is */ talented/*?*/<
/* Had we kissed in */ 6 /* hours and */* 45 /* minutes of work*/?
/* O*/vernight /* working */: 0/*n the same boat.*/,
/* Man, had I already said how she is */ talented/*?*/<

/* Without her, could that be */ 180 /* times or worse of boring homework*/?
/* So */ boring: 0/*n that boat in an otherwise */), null // weekend
). /*But I had to */getX ()/*n*/ ,-my_life /*and*/. transform(
/* In a much better thing a */new Point2D /*homework to be done in */.Double//s

(/* Was she */ talented /* like something */ >180 /*percent*/?
/* O*/vernight : 0/*n the boat, I and my */, talented /* girl finished */ > 90 /* percent.
*/ & /* she is so*/ talented /* that in */ < 6 /*hours and */*45 /* minutes of */ ?boring /* homework
*/: 0/*n an otherwise */), null // weekend, we got a love!

)./* And now, we both */ getY//a new life!
()/*n that night */); my_life /* was */. preConcatenate//d
/* She */( kissed_my_mouth /* and she though me CorelDraw */);
/* However, she didn't knew about */ BufferedImage/*!!!

*/ i_knew =/*lly well right from the start */
/* that I would had a */ new AffineTransformOp /* in */( my_life,
/* and */ 2 /* that working to */).filter( /* out the boringness */
   she /* too did not got a */, null /* weekend */);

/* I had an */ AffineTransform on_my_life
/* She */ =/*lly had a */ new AffineTransform ()/*n*/ ,her_life
/* Oh, she really */ =/*lly had a */ new AffineTransform ()/*n*/ ;her_life
// OH YEAH!

/* I can't */.translate (/* how */ very_nice, /* and */ pretty /* she is.*/);
/* I got */ on_my_life /* a new */ .scale( /* of bliss. */
/* with a */ girl /* that kissed me, *// /* working a */ boring /* homework */,
/* got a girl*/friend /*O*//vernight )/* in a work about a boat. */;

   on_my_life /* I can't */.translate
/* How I became so live */((
/* from a */ boring -/* homework,
*/ i_knew. /* how to */getWidth(
)) /* We *// 2, /* working */( /*O*/vernight
-  // Until the night was high
   i_knew /* to */.getHeight
   ()//n the night when she came
)/ /* We gotta to be */ 2//gether
); //OH YEAH!

   on_my_life /* I */.preConcatenate(
/* And */ her_life // Would never be the same
); /* Looking the net for a */ boat. // page
/* To finally */ drawImage(

   i_knew, /* that with this girl */ on_my_life, /* I would never get a */ null // weekend!!!
); /* OH YEAH! */}}

/* And monday back in the */ class
   MY_TRUE_LOVE extends /* the */ JComponent
{  I_MET a_great_love
/* And */ =/*lly for her was this a */ new // love
   I_MET /* with her */( heart
); I_MET love // in her heart
/* And I */ =/*lly met a */ new // life!
   I_MET /* a new */ (life);

// *****************************************************
// TRACK 7: DOUBLE TROUBLE IN MY GIRL'S FATHER CARD SHOP
// *****************************************************

/* I was in */ double trouble, last_year, at_my_phone;
// The dad of my girl had a shop in his home.
/* He were open to the */ public // that day. But no customers came
/* Just a */ void // on the shop, that was all then.

/* He */ paintComponent/*s of some */(Graphics cards){
/* But */ trouble /* is */ = trouble + /* all that */ stuff.
/* The */ nextDouble /* trouble */ ()//ff the week
/* Was like */* 5 /* times as so big */-
   5 /* times *// 2. /* the dad of my girl. */

;  if (/* he was really bad to sell all that */ stuff.
/* The */ nextDouble /* trouble he had was */ ()/*nce a big */</**/ 1./
/* He had bad sells for more than */ 20 /* days */)
/* The truth is that */ trouble /* is */ = /* to */- trouble; // no matter when

/* As */ a_great_love /* my girl is so */. talented
/* To */ =lize (a_great_love/*,*/. talented // also I am!
/* But love */ + /* all that */ trouble // is really hard then
); /* And */ last_year /* to */ =lize(// the bills, that was a real pain

   last_year + 1 /* or maybe *//2. // months
); at_my_phone /* her dad called to */ =lize(// the bills ongoing
   at_my_phone /* he complained, and asked money to*/-/* give back in */ 7 /* days or maybe *// 10.);
// And that put me in trouble with my girlfriend!

/* But that */ Graphics2D CARDS // were really cool stuff!
=/*But that */(Graphics2D)cards;// were really-really cool stuff!
   int eresting // they were
=/* You could */ getWidth ()//f that
,  a_great_card_pile =/*lly was possible to make it */ getHeight /* very high*/

   ()/*n all those*/; CARDS. /* They */ setColor // very careful.
(/* and the */ new Color//s her father painted, all of them were very cool.
(/* But in the end, they only selled */ 15 /* or */* 17, // each day
/* But could produce more then */ 200 // everyday
/* And I counted */, 225 /* boxes of cards and paint abandoned in the store at that day. */));

/* Her dad in the */ CARDS/*, he did it */.fillRect
/* All that stuff was very */((int)eresting
-  (int)eresting, (int)eresting -/* very */ (int)eresting, /* really really */ (int)eresting,
// OH YEAH!

/* But my heart broke with such */ a_great_card_pile
);/* he weren't selling enough, and I had */ a_great_love /* to my */.girl
= /* I could not see a great */ (int)eresting // card shop end
; /* And I had */ a_great_love. /* to my girl*/friend
= /* And I decided that such */ a_great_card_pile /* should finally get an end! */;

/* My girl had */ a_great_love /* in */ .draw/*ing all those */(CARDS);
// OH YEAH!

   for (/* that situation, i did needed */int elligence
=/*from n*/0/*w on, I used my */; (int)elligence
<  2 /* sell everything*/ + /* handle all the bills and */ stuff.
   /* my */ nextInt//elligent move was to buy the card shop! */

(/*My girl was surprised, */ 5 /* times she said*/);
/* And she admired all that my int*/elligence /**/++
){ I_MET her_father /* he was */ =//lly surprised!

/* And after that I got to the shop a */ new // life. OH YEAH!
// But he imposed a condition: We had to merry, that was the reason

/* So in that church */ I_MET (/* my loving */star /*!!!!*/);
// OH YEAH!

/* And */ her_father. /* was my */ friend
= /* And to */ a_great_card_pile /* I had it to end. *//
/* For */ 6 /* dollars each card, */ + /* a few cents. */
/* With that */ stuff // done,
/* the */ .nextDouble /* trouble was gone! */
()/*n that day */* a_great_card_pile /* will never again be the reason to ring my phone! *//6;/*

*/ her_father /* was happy */.
/* His */ girl // was married!
=/*And how int*/eresting
/  6+ /* times we are selling all that */stuff.
   nextDouble /* tr*/()/*uble we had no more. */*

/* and look how */(int)eresting /
/* For just */ 6 /* bucks a card we selled */;

   her_father. /* was */ very_nice
=// The man was very nice.
// OH YEAH!

/* And */ stuff. /* was done. */
/* The */ nextDouble /* tr*/()/*uble was gone. */*(
/* And how int*/eresting-
   her_father /* was happy */.
/* coz his */ girl /* was married. */

); her_father/*s cards are */ .pretty
= /* he produces all that */stuff.
// And then I selled everything
// Until the last one!

/* The */ nextDouble /* tr*/()/*uble was gone. */*(
/* And to sell such */ a_great_card_pile // was a job done.

-  her_father /* were my old */. friend
); her_father /* were so much */ .talented
=/*And all those */ stuff // we happy worked together!

/* But indeed the */.nextDouble /* tr*/()/*uble then come! */*
/* For */ 360 /* days I could even not imagine! */;
   her_father /* used to */.draw( /* all those */ CARDS);}
// He did it pristine!
/* But now my */ love.girl /* was crying! */=
// Because her father was died.

/* And see how */ (int)eresting;
/* Is to feel */ love /* to a */ .friend
// But we do only perceive this
/* when it had come to the end */=
// But live goes on now.
   a_great_card_pile /* entirely new was set on now. */;

/* That was my */ love.
/* A girl very */ talented
/* She */ =lize//d her father
// artistic scent.

(/*My */ love /* girl is so */.talented
   +5 // times pround her father would now be then.
); /* And she */ love /* to */.draw(/* all those */ CARDS);}
/* She do it */ double // better
// of what did the old man.

/* Sometimes we rea*/lize(double /* times */ indeed){
/* That could her father has */ return//d
(( indeed </* in */0/*ur first kid*/)?
/* The boy is */ indeed //an artist.
+/* As was his grandpa */ 360 // months in the past.

:// When we do sell all those cards
/* I am very grateful */ indeed)
%// To that old man
// who once married his daughter to me.

/* I am */ 360 // times so grateful forever.
;} /* This is why I love so much his daughter
in his memory respect. */ }}

```

# Answer
> 18 votes
# Befunge-93

Run as `echo '[NAME]!' | ./befungee.py test` (assuming the code below is in a file named 'test') for the output "Happy Valentine's day \[NAME\]!"

The top few lines are for reading in the name; if you remove them and just leave the heart it will simply say "Happy Valentine's day".

```
v
v      _ v            _v#                                 1<
>~:"!"-^ >10g1+:10p0p:^>" "37*2+2p"v"63*2+:"g"\2p2+2p" "10p^
         |        -" "<
v        <

>     92+:*91+9*v                  v:+19*2*5+<
   v*66*5+2*37*<>7+v            v1*<>*91+9*7v^29<
 v3<>*7+89*v   4  <>9v        v+<>*3^       >+9v^*<
v<>9^      v,_@^8*:+<>v      v<>9^             >1v^<
v*+       *>:^      ^<>v    v<>^                 +.^
>v^<                 ^<>v  v<>^                 v<>^
 >v^1<                ^1<**>4^                v4<>^
  >+v^9<                                    v*<>4^
    >9v^*7<                              v+3<>+^
      >1+v^*<                          v2<>*1^
         >:v^44<                    v8*<>7^
           >*1v^*<                v4<>*4^
              >+v^7*<          v9*<>7^
                >92v^4<      v2<>5*^
                   >+v^4<  v+<>3^
                     >5v^*:<>*^
                       >*v>2^
                         >^

```

# Answer
> 14 votes
# Extended Brainfuck

This is by no means the shortest code that does this. Actually not used any EBF feature except for the same as `BF-RLE`.

```
              +[->,10-]>>5+[-<6+>]                            <++.........>8+[-<8+
        >]<-.>7+[-<7->]<.-.6-.>9+[-<10+               >]<3-......>5+[-<6->]<.>7+[-<7->]<--
    .+.>7+[-<7+>]<.>9+[-<9->]<4-.>4+[-<5+>        ]<++........>4+[-<4+>]<-.>4+[-<4->]<+......>
   9+[-<10+>]<++..>9+[-<10->]<--......>7+[-<    8+>]<4+.>9+[-<9->]<-.>4+[-<5+>]<++.......>4+[-<
  4+>]< -.>4+[-<4->]<+.......>9+[-<10+>]<++..>9+[-<10->]<--.......>7+[-<8+>]<4+.>7+[-<8->]<4-...
  .....>6+[-<6+>]<.>5+[-<6+>]<3+.4-.>4+[-<4+>]<+.>9+[-<9->]<-.[-]<<[11+<]>[.>]10+.>4+[-<5+>]<++.
 .....>9+[-<10+>]<++.>9+[-<10->]<--........>9+[-<10+>]<++..>9+[-<10->]<--........>9+[-<10+>]<++.>
 10+[-<11->]<4-.>4+[-<5+>]<++......>9+[-<10+>]<++.>9+[-<10->]<--.>8+[-<8+>]<-.......>5+[-<6+>]<-.
 .>5+[-<6->]<+.......>8+[-<8->]<+.>9+[-<10+>]<++.>10+[-<11->]<4-.>4+[-<5+>]<++......>9+[-<10+>]<+
 +.>8+[-<9->]<5-.>4+[-<4->]<+.13+.....13-.>7+[-<8+>]<4+.>6+[-<7->]<3-.>4+[-<4->]LOVEME<+.13+.....
13-.>7+[-<8+>]<4+.>5+[-<6+>]<++.>9+[-<10->]<--.......>6+[-<7+>]<.>6+[-<6+>]<+.6-.5+.>9+[-<9->]<3+.
>8+[-<9+>]<5+.8-.>8+[-<9->]<3+.>8+[-<8+>]<+.13+.10-.>8+[-<8->]<4-.>9+[-<9+>]<3+.5-.8-.--.>4+[-<4+>
]<-.12-.3-.13+.>10+[-<10->]<4-.>4+[-<5+>]<++.....>4+[-<4+>]<-.>4+[-<4->]<+..8+.8-.....9+.9-..8+.8-
.....9+.9-..>7+[-<8+>]<4+.>7+[-<8->]<4-......>9+[-<10+>]<3-.>4+[-<4->]<--.>8+[-<9->]<3+.>9+[-<9+>]
<++.11-.7-.11+..>8+[-<9->]<4-.>9+[-<9+>]<+.3+.9-.7-.>8+[-<9->]<3+.>9+[-<9+>]<3+.12-.3-.>8+[-<9->]<
 3+.>8+[-<9+>]<-.6-.11+.11-.>4+[-<5+>]<3+.+.>9+[-<10->]<++.-.>4+[-<5->]<--.>4+[-<5+>]<++....>4+[-
 <4+>]<-.>4+[-<4->]<+.>7+[-<8+>]<4+.>7+[-<8->]<4-..13+.....13-.8+.+.9-.13+.....13-..>4+[-<4+>]<-.
  >4+[-<4->]<+.>7+[-<8+>]<4+.>9+[-<9->]<-.>4+[-<5+>]<++...>4+[-<4+>]<-.>4+[-<4->]<+...>7+[-<8+>]
  <4+.>7+[-<8->]<4-......>4+[-<4+>]<-.>8+[-<9+>]<5+..>5+[-<6->]<--.>7+[-<8->]<4-......>4+[-<4+>]
   <-.>4+[-<4->]<+...>7+[-<8+>]<4+.>9+[-<9->]<-.>4+[-<5+>]<++..>4+[-<4+>]<-.>4+[-<4->]<+.....>@
    7+[-<8+>]<4+.>7+[-<8->]<4-....>4+[-<4+>]<-.>8+[-<9+>]<5+....>5+[-<6->]<--.>7+[-<8->]<4-..
     ..>4+[-<4+>]<-.>4+[-<4->]<+.....>7+[-<8+>]<4+.>9+[-<9->]<-.>4+[-<5+>]<++.>4+[-<4+>]<-.>
      4+[-<4->]<+.......>7+[-<8+>]<4+.>7+[-<8->]<4-..>4+[-<4+>]<-.>8+[-<9+>]<5+......>5+[-<
       6->]<--.>7+[-<8->]<4-..>4+[-<4+>]<-.>4+[-<4->]<+.......>7+[-<8+>]<4+.>9+[-<9->]<-.>
        6+[-<6+>]<+.>7+[-<7+>]<-.>8+[-<8->]<+........>7+[-<8+>]<4+.>4+[-<5+>]<-.>7+[-<7->
          ]<-........>7+[-<7+>]<+.>8+[-<8->]<.>4+[-<4->]<+........>8+[-<8+>]<-.3-.>9+[
             -<9->]<-.>4+[-<5+>]<++..>8+[-<8+>]<.>7+[-<7->]<--..+...>7+[-<7+>]<..>
                5+[-<6+>]<-.>5+[-<6->]<++.>7+[-<7->]<--.+.>7+[-<7+>]<.>8+[-<8->
                   ]<+..>8+[-<8+>]<-.>7+[-<7->]<.-.6-.>9+[-<9+>]<4+.>5+[-<6-
                       >]<+..>7+[-<7->]<...-..6-.>5+[-<6->]<+.>4+[-<5+>]<
                             ++..........>9+[-<10+>]<++.>9+[-<10->]
                                 <--....>8+[-<8+>]<.>7+[-<8->]<
                                     -.7-....>9+[-<10+>]<++.
                                         >10+[-<11->
                                             ]<4-.

```

Usage:

```
bf ebf.bf < valentine.ebf > valentine.bf
echo "Code Golf" | bf valentine.bf

```

Output:

```
         _.-'~~~~~~`-._
        /      ||      \
       /       ||       \        Dear Code Golf
      |        ||        |
      | _______||_______ |
      |/ ----- \/ ----- \|       Join me and together
     /  (     )  (     )  \      we shall rule the galaxy!
    / \  ----- () -----  / \
   /   \      /||\      /   \
  /     \    /||||\    /     \
 /       \  /||||||\  /       \
/_        \o========o/        _\
  `--...__|`-._  _.-'|__...--'
          |    `'    |

```

Ascii art is not made by me but just picked up here.

# Answer
> 12 votes
# Perl

awfully looking heart 2:

```
eval's unable to compute a hint,
when I write perl, I think of you;
I think of you at every '. print'
just be with me, since I love you
'
   ;;@_=       split//,
 $@;$"=$^I,  $_=0.00.106.
117.115.116.032.0115.0105.
110.99.101.32.116.104.101.
32.118.105.111.108.101.116
 .115.32.97.114.0101.032.
  98.108.117.101.10."@_[
   14,11] @_[20,49] @_[
     46,1,6,11,2,4,33
       ,02,013], @{[
         shift]}$/"
          ,print

```

The poem thingy at the beginning is not *fully* used, but it is *somewhat* used, so cannot be removed;
Output:

```
$ perl valentine.pl \$NAME

just be with me, since I love you
just since the violets are blue
be my valentine, $NAME

```

# Answer
> 11 votes
## Processing

Almost entirely based on this answer of mine. And the input part is taken from here with modifications.

```
public static final int px=25;
public static final int rectRad = 3;
PFont font;
public boolean[][] used;
public int[] heart = {

               65, 66, 67,                 72, 73, 74,
           84, 85, 86, 87, 88,         91, 92, 93, 94, 95,
      103,104,105,106,107,108,109,110,111,112,113,114,115,116,
  122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,
  142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,
  162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,
      183,184,185,186,187,188,189,190,191,192,193,194,195,196,
          204,205,206,207,208,209,210,211,212,213,214,215,
          224,225,226,227,228,229,230,231,232,233,234,235,
              245,246,247,248,249,250,251,252,253,254,
                  266,267,268,269,270,271,272,273,
                      287,288,289,290,291,292,
                          308,309,310,311,
                              329,330
                                 };

void setup( ) {                                  size(500,500);
background(255);                                 stroke(190+1);
strokeWeight(1.75); fill(0); font=createFont("Purisa",28,true);
textFont(font,28); frameRate(50); used = new boolean [width/px]
[height/px];} void keyReleased(){ if(key!=CODED){ switch(key) {
case BACKSPACE:name=name.substring(0,max(0,name.length() - 1));
break; case 0xA:                                 case RETURN:fd
=1==0;background                                 (0xFF); break;

                         case ESC: case DELETE:
                    break; default: name+=key; }}}
            boolean fd=true;String name=""; int c=0;
         void draw(){if(fd){background(255);text("Ple"
      +"ase enter a name:",35, 30); text(name,35,70);c=
   frameCount;return;}int i, j, df = width*height/px/px
 ,tf = (int)(500 * frameRate/1000);do{i=(int)random(
0, width/px);j=(int)random(0,height / px);} while
 (used[i][j] &&frameCount-c<= df);used[i][j] = true;
  if(frameCount-c > df+tf) {noLoop(); return;} else if(
     frameCount-c == df+tf) { fill(63+32); text("Dear "
         + name + ",", 10, 50); text("Happy Valentin"+
             "e's Day!", 80, 200);text("Love,\nAce",
                    10, 0xA * 43); return;} else if
                         (frameCount-c>=df+1) {

   return;} int R=(int)random(64,255-64); int G = (int)
 random(128,255); int B=(int)random(128,255); int alpha
=(int)random(55,85);int hash=j*width/px+i;if(java.util.
Arrays.binarySearch(
heart,hash)>=0) {R=
(int)random(128+64,
255);G=(int)random(
0,63);B=(int)random
(0,63); alpha=(int)random(70, 100);} fill(R,G,B,alpha);
 rect(i*px,j*px,px,px,rectRad,rectRad,rectRad,rectRad);
   }///////////////////////////////////////////////////

```

See the animation online here. (You may have to click on the canvas in order to be able to type input. The easiest way would be to click on the input prompt. Note that the code used in this online demo is slightly different due to differences between Processing (the program above) and Processing.js (the one used in the demo).)

Alternatively, here is one possible output, given the input "Sample Input":

# Answer
> 4 votes
# Zozotez LISP

Zozotez is a LISP interpreter written in Extended BrainFuck.

```
          ;((((((((((((((((((((()))))))))))))))))))))
       ((\(even to know my programming language) ;(())
    (to (my programming language) 'Lisp);(((((())))))
(to (know |I love |) 'parentheses);(((((((())))))))
   (to (even you more than there are) c);(((((())))))
      (to (know |parentheses in my heart ()()()|)));()
         (~ w (c "(c w))) p " c 'Dear (r));((((()))))

```

How to run:

```
jitbf zozotez.bf

```

Paste in code with only one trailing newline. Then your \*friends name. Output looks like this:

```
Dear Max Love
I love you more than there are
parentheses in my heart ()()()

```

Needless to say, this text displays a lot of love since who doesn't love lispy parentheses?

# Answer
> 1 votes
# Java

```
           public       class
     Vale {public       static void
    main(         String      []args)
   {int a;         char       c,d,r,g;
   String            s        ="hi";//
    double                    x,y,z=0;
     System                .out.print          ("hi  ");
      String[            ]parts=s.split(      "///////");
        String          string="This is  -for-  ";double w;
         System        .out.print         ("")    ;int g1,a1;
           System     .out.println(        );       System.out
            .print(string);System.                  out.print("")
                    ;       System.                out.println
                            ("you and             me,two heart"
                                +" combine        together "
                                    +"always     till "
                                       +"end  of life"
                                           );}}

```

Result:

```
hi  This is  -for-  you and             me,two heart combine        together always     till end  of life

```

# Answer
> 1 votes
## Javascript

Working Demo

```
             var t = '<span class'+                              '="t">░</span>', r =
          '<span class="r">▓</span>',                          b = '<span class="b">█'+
        '</span>', w = '<span class="w">'+                '▒</span>', n = '<br>', heart = [ t,
       t, t, t, t, t, t, t, t, t, t, t, t, t,          t, n, t, t, t, b, b, b, t, t, t, b, b, b, t,
    t, t, n, t, t, b, r, r, r, b, t, b, r, r, r,       b, t, t, n, t,  b, r, w, w, r, r, b, r, r, r,
   r, r, b, t, n, t, b, r, w, r, r, r, r, r, r, r,   r, r, b, t, n, t, b, r, r, r, r, r, r, r, r, r, r,
  r, b, t, n, t, t, b, r, r, r, r, r, r, r, r, r, b, t, t, n, t, t, t, b, r, r, r, r, r, r, r, b, t, t,
  t, n, t, t, t, t, b, r, r, r, r, r, b, t, t, t, t, n, t, t, t, t, t, b, r, r, r, b, t, t, t, t, t, n,
    t, t, t, t, t, t, b, r, b, t, t, t, t, t, t, n, t, t, t, t, t, t, t, b, t, t, t, t, t, t, t, n, t,
     t, t, t, t, t, t, t, t, t, t, t, t, t, t, n ], space = function(n, c){ var a = [], i = 0; while
       ( i < n ){a.push(c);++i;} return a.join(''); }, card = function(name){ var e = name.length
            % 2, sp = (13 - name.length) / 2; return space(15, t) + n + space(sp, w) + name.
            toUpperCase() + ' I' + space(sp + (e?1:0), w) + n + heart.join('') + space(6, w)
             + 'YOU!' + space(6, w) + n + space(15, t) + n; }, out = document.getElementById
               ('card'), inp = document.getElementById('name'), plot = function(){out.
                    innerHTML =  card(inp.value)}; inp.addEventListener('change',
                           plot); out.style['font-family'] = 'monospace';
                               out.style['text-align']  = 'center';
                                   out.style['line-height'] =
                                      '12px'; out.style
                                        ['font-size']
                                          = '15px';
                                           plot
                                            ()
                                             ;

```

# Answer
> 1 votes
# Python 9,459 bytes

Try it Online!

```
exec"""
        exec''           'print
      "".join(ma       p(chr,map(
    int,"32_32_32_   32_32_32_32_32
  _32_32_32_32_32_3 2_32_32_46_32_32_
 32_32_32_32_32_32_32_32_32_32_32_32_3
2_32_32_32_32_32_32_32_32_32_32_32_32_3
2_32_32_32_32_32_32_32_32_32_32_32_32_3
2_32_32_32_46_32_32_32_32_32_32_32_32_3
 2_32_32_32_32_32_13_10_32_32_32_32_32
  _42_32_32_32_46_32_32_32_32_32_32_3
   2_32_32_32_32_32_32_32_32_32_32_3
    2_46_32_32_32_32_32_32_32_32_32
      _32_32_32_32_32_46_32_32_32
        _32_32_32_32_32_46_32_3
          2_32_42_32_32_32_32
            _32_32_32_32_32
              _32_46_32_3
                2_32_32
                  _32
                   _
        32_32_           32_13_
      10_32_32_4       6_32_32_32
    _32_32_32_32_3   2_32_46_32_32_
  32_32_32_32_32_32 _32_32_32_32_32_3
 2_32_32_32_32_32_32_32_46_32_32_32_32
_32_32_32_46_32_32_32_32_32_32_32_32_32
_32_32_46_32_32_32_32_32_32_46_32_32_32
_32_32_32_32_32_46_32_32_32_32_32_13_10
 _32_32_32_32_32_32_32_32_111_32_32_32
  _32_32_32_32_32_32_32_32_32_32_32_3
   2_32_32_32_32_32_32_32_32_32_32_3
    2_32_32_32_46_32_32_32_32_32_32
      _32_32_32_32_32_32_32_32_32
        _32_32_32_32_46_32_32_3
          2_32_32_32_32_32_32
            _32_32_32_32_32
              _32_32_32_1
                3_10_32
                  _32
                   _
        32_32_           32_32_
      32_32_32_4       6_32_32_32
    _32_32_32_32_3   2_32_32_32_32_
  32_32_46_32_32_32 _32_32_32_32_32_3
 2_32_32_32_32_32_32_32_32_32_46_32_32
_32_32_32_32_32_32_32_32_32_46_32_32_32
_32_32_32_32_32_32_32_32_32_32_32_32_32
_32_32_32_32_13_10_32_32_32_32_32_32_32
 _32_32_32_48_32_32_32_32_32_46_32_32_
  32_32_32_32_32_32_32_32_32_32_32_32
   _32_32_32_32_32_32_32_32_32_32_32
    _32_32_32_32_32_32_32_32_32_32_
      32_32_32_32_32_32_32_32_32_
        32_32_32_32_32_32_32_32
          _32_32_32_32_32_32_
            32_13_10_32_32_
              32_32_32_32
                _32_32_
                  32_
                   3
        2_32_3           2_32_3
      2_32_32_32       _46_32_32_
    32_32_32_32_32   _32_32_32_46_3
  2_32_32_32_32_32_ 32_32_32_32_32_32
 _32_32_32_32_32_44_32_32_32_32_32_32_
32_32_32_32_32_32_32_32_32_32_44_32_32_
32_32_44_32_32_32_32_32_32_32_13_10_32_
46_32_32_32_32_32_32_32_32_32_32_92_32_
 32_32_32_32_32_32_32_32_32_46_32_32_3
  2_32_32_32_32_32_32_32_32_32_32_32_
   32_32_32_32_32_32_32_32_32_32_32_
    46_32_32_32_32_32_32_32_32_32_3
      2_32_32_32_32_32_32_32_32_3
        2_32_32_32_32_32_32_32_
          13_10_32_32_32_32_3
            2_32_46_32_32_3
              2_32_32_32_
                92_32_3
                  2_3
                   2
        _44_32           _32_32
      _32_32_32_       32_32_32_3
    2_32_32_32_32_   32_32_32_32_32
  _32_32_32_32_32_3 2_32_32_32_32_32_
 32_32_32_32_32_32_32_32_32_32_32_32_3
2_32_32_32_32_32_32_32_32_32_32_32_32_3
2_32_32_13_10_32_32_32_46_32_32_32_32_3
2_32_32_32_32_32_111_32_32_32_32_32_46_
 32_32_32_32_32_32_32_32_32_32_32_32_3
  2_32_32_32_32_46_32_32_32_32_32_32_
   32_32_32_32_32_32_32_32_32_32_32_
    32_32_46_32_32_32_32_32_32_32_3
      2_32_32_32_32_46_32_32_32_3
        2_13_10_32_32_32_32_32_
          46_32_32_32_32_32_3
            2_32_32_32_92_3
              2_32_32_32_
                32_32_3
                  2_3
                   2
        _32_32           _32_32
      _32_32_32_       32_32_44_3
    2_32_32_32_32_   32_32_32_32_32
  _32_32_32_46_32_3 2_32_32_32_32_32_
 32_32_32_32_32_32_32_32_32_46_32_32_3
2_32_32_32_32_32_32_32_32_13_10_32_32_3
2_32_32_32_32_32_32_32_32_32_32_32_32_3
5_92_35_35_92_35_32_32_32_32_32_32_46_3
 2_32_32_32_32_32_32_32_32_32_32_32_32
  _32_32_32_32_32_32_32_32_32_32_32_3
   2_32_32_32_32_32_46_32_32_32_32_3
    2_32_32_32_46_32_32_32_32_32_32
      _32_32_13_10_32_32_32_32_32
        _32_32_32_32_32_32_32_3
          2_35_32_32_35_79_35
            _35_92_35_35_35
              _32_32_32_3
                2_32_32
                  _32
                   _
        32_32_           32_32_
      32_32_32_3       2_32_46_32
    _32_32_32_32_3   2_32_32_32_32_
  32_32_32_32_32_32 _32_32_32_32_32_3
 2_32_32_46_32_32_32_32_32_32_32_32_32
_32_13_10_32_32_32_46_32_32_32_32_32_32
_32_32_35_42_35_32_32_35_92_35_35_92_35
_35_35_32_32_32_32_32_32_32_32_32_32_32
 _32_32_32_32_32_32_32_32_32_32_32_32_
  46_32_32_32_32_32_32_32_32_32_32_32
   _32_32_32_32_32_32_32_32_32_32_44
    _32_32_32_32_32_13_10_32_32_32_
      32_32_32_32_32_46_32_32_32_
        35_35_42_35_32_32_35_92
          _35_35_92_35_35_32_
            32_32_32_32_32_
              32_32_32_32
                _32_32_
                  32_
                   3
        2_32_4           6_32_3
      2_32_32_32       _32_32_32_
    32_32_32_32_32   _32_32_32_32_3
  2_32_32_32_46_32_ 32_32_32_32_32_32
 _32_32_32_32_32_32_13_10_32_32_32_32_
32_32_46_32_32_32_32_32_32_35_35_42_35_
32_32_35_111_35_35_92_35_32_32_32_32_32
_32_32_32_32_46_32_32_32_32_32_32_32_32
 _32_32_32_32_32_32_32_32_32_32_32_32_
  32_32_32_32_32_32_32_32_32_44_32_32
   _32_32_32_32_32_46_32_32_32_13_10
    _32_32_32_32_32_32_32_32_32_32_
      46_32_32_32_32_32_42_35_32_
        32_35_92_35_32_32_32_32
          _32_46_32_32_32_32_
            32_32_32_32_32_
              32_32_32_32
                _32_32_
                  32_
                   3
        2_32_3           2_32_4
      6_32_32_32       _32_32_32_
    32_32_32_32_32   _32_32_46_32_3
  2_32_32_32_32_32_ 32_32_32_44_32_13
 _10_32_32_32_32_32_32_32_32_32_32_32_
32_32_32_32_32_32_32_32_32_32_32_92_32_
32_32_32_32_32_32_32_32_32_46_32_32_32_
32_32_32_32_32_32_32_32_32_32_32_32_32_
 32_32_32_32_32_32_32_32_32_46_32_32_3
  2_32_32_32_32_32_32_32_32_32_32_32_
   32_32_13_10_95_95_95_95_94_47_92_
    95_95_95_94_45_45_95_95_95_95_4
      7_92_95_95_95_95_79_95_95_9
        5_95_95_95_95_95_95_95_
          95_95_95_95_47_92_4
            7_92_45_45_45_4
              7_92_95_95_
                95_95_9
                  5_9
                   5
        _95_95           _95_95
      _95_45_45_       45_95_95_9
    5_95_95_95_95_   95_95_95_95_95
  _95_95_32_13_10_3 2_32_32_47_92_94_
 32_32_32_94_32_32_94_32_32_32_32_94_3
2_32_32_32_32_32_32_32_32_32_32_32_32_3
2_32_32_32_32_94_94_32_94_32_32_39_92_3
2_94_32_32_32_32_32_32_32_32_32_32_94_3
 2_32_32_32_32_32_32_45_45_45_32_32_32
  _32_32_32_32_32_32_13_10_32_32_32_3
   2_32_32_32_32_32_45_45_32_32_32_3
    2_32_32_32_32_32_32_32_45_32_32
      _32_32_32_32_32_32_32_32_32
        _32_45_45_32_32_45_32_3
          2_32_32_32_32_45_32
            _32_32_32_32_32
              _32_32_32_4
                5_45_45
                  _32
                   _
        32_95_           95_32_
      32_32_32_3       2_32_32_94
    _32_32_32_32_3   2_13_10_32_32_
  32_45_45_32_32_95 _95_32_32_32_32_3
 2_32_32_32_32_32_32_32_32_32_32_32_32
_32_32_32_32_32_95_95_95_45_45_32_32_94
_32_32_94_32_32_32_32_32_32_32_32_32_32
_32_32_32_32_32_32_32_32_32_32_32_32_32
 _32_32_45_45_32_32_95_95_32_82_67_13_
  10_32_32_32_32_32_32_32_32_32_32_32
   _32_32_32_32_32_32_32_32_32_32_32
    _32_32_32_32_32_32_32_32_32_32_
      32_32_32_32_32_32_32_32_32_
        32_32_32_32_32_32_32_32
          _32_32_32_32_32_32_
            32_32_32_32_32_
              32_32_32_32
                _32_32_
                  32_
                   3
        2_32_3           2_32_3
      2_32_32_32       _32_13_10_
    32_32_32_32_68   _101_97_114_32
  _116_58_13_10_13_ 10_32_32_32_32_87
 _69_32_74_85_83_84_32_76_65_78_68_69_
68_32_65_32_80_82_79_66_69_32_79_78_32_
77_65_82_83_32_33_33_33_33_33_33_32_73_
83_78_39_84_32_84_72_65_84_32_69_88_67_
 73_84_73_78_71_32_63_33_63_33_63_33_3
  2_32_13_10_32_32_32_32_32_32_32_32_
   32_32_32_32_32_32_32_32_32_32_32_
    32_32_32_32_32_32_32_32_32_32_3
      2_32_32_32_32_32_32_32_32_3
        2_32_32_32_32_32_32_32_
          32_32_32_32_32_32_3
            2_32_32_32_32_3
              2_32_32_32_
                32_32_3
                  2_3
                   2
        _32_32           _32_32
      _32_32_32_       32_32_32_3
    2_13_10_32_32_   32_32_73_32_71
  _85_69_83_83_32_7 3_84_32_87_79_85_
 76_68_32_66_69_32_73_70_32_87_69_32_7
2_65_68_78_39_84_32_68_79_78_69_32_73_8
4_32_65_84_32_76_69_65_83_84_32_70_73_8
6_69_32_84_73_77_69_83_32_66_69_70_79_8
 2_69_32_32_32_32_32_13_10_32_32_32_32
  _32_32_32_32_32_32_32_32_32_32_32_3
   2_32_32_32_32_32_32_32_32_32_32_3
    2_32_32_32_32_32_32_32_32_32_32
      _32_32_32_32_32_32_32_32_32
        _32_32_32_32_32_32_32_3
          2_32_32_32_32_32_32
            _32_32_32_32_32
              _32_32_32_3
                2_32_32
                  _32
                   _
        32_32_           32_32_
      13_10_32_3       2_32_32_66
    _85_84_32_73_8   4_39_83_32_65_
  32_42_42_42_68_73 _70_70_69_82_69_7
 8_84_42_42_42_32_80_82_79_66_69_32_65
_78_68_32_87_69_32_68_73_68_32_73_84_32
_42_42_42_68_73_70_70_69_82_69_78_84_76
_89_42_42_42_32_33_33_33_49_49".split()
 ))).replace("t",raw_input("Name:"))''
  '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
      @@@@@@@@@@@@@@@@@@@@@@@@@@@
        @@@@@@@@@@@@@@@@@@@@@@@
          @@@@@@@@@@@@@@@@@@@
            @@@@@@@@@@@@@@@
              @@@@@@@@@@@
                @@@@@@@
                  @@@
                   @""".replace("@","").replace(" ","").replace("\n","").replace("raw_input","input").replace("_", " ").replace("input","raw_input")
```

Output(www.asciiartfarts.com/20120820.html).

```
                .                                            .

     *   .                  .              .        .   *          .

  .         .                     .       .           .      .        .

        o                             .                   .

         .              .                  .           .

          0     .

                 .          .                 ,                ,    ,

 .          \          .                         .

      .      \   ,

   .          o     .                 .                   .            .

     .         \                 ,             .                .

               #\##\#      .                              .        .

             #  #O##\###                .                        .

   .        #*#  #\##\###                       .                     ,

        .   ##*#  #\##\##               .                     .

      .      ##*#  #o##\#         .                             ,       .

          .     *#  #\#     .                    .             .          ,

                      \          .                         .

____^/\___^--____/\____O______________/\/\---/\___________---______________

   /\^   ^  ^    ^                  ^^ ^  '\ ^          ^       ---

         --           -            --  -      -         ---  __       ^

   --  __                      ___--  ^  ^                         --  __ RC

    Dear Code Golf:

    WE JUST LANDED A PROBE ON MARS !!!!!! ISN'T THAT EXCITING ?!?!?!

    I GUESS IT WOULD BE IF WE HADN'T DONE IT AT LEAST FIVE TIMES BEFORE

    BUT IT'S A ***DIFFERENT*** PROBE AND WE DID IT ***DIFFERENTLY*** !!!11

```

Not really Valentine's day themed ... But just under 10 kb :)

---
Tags: popularity-contest, ascii-art, graphical-output
---


title: Find all Number Relations

text:
# Question
Title: Find all Number Relations
Inspired by: Find an Unrelated Number

---

## Challenge

Given two positive integers as input, output the mathematical operations that can be used on those inputs to generate every number from `1` to `n` inclusive where `n` is the smallest prime greater than the sum of the two inputs. If the number cannot be generated using the list of mathematical operations below, the output for that number should indicate that it is "unrelated".

For example, for the inputs `2` and `3`, `n=7` so one valid output would be
`Subtraction, Modulus, Bitwise OR, Unrelated, Addition, Multiplication, Unrelated`
(see Output section below for clarification on valid outputs)

(If Erik the Outgolfer's answer is valid, the last term will always be `unrelated`.)

Operations that must be considered are:

```
Addition        (a + b)
Subtraction     (a - b) and (b - a)
Multiplication  (a * b)
Division        (a / b) and (b / a)
Modulus         (a % b) and (b % a)
Bitwise OR      (a | b)
Bitwise XOR     (a ^ b)
Bitwise AND     (a & b)

```

In cases where an operation would lead to a non-integer (such as `2/3`), always floor. So `2/3=0` and `3/2=1`.

Exponentiation is not included because it is never *required*. `a**b` and `b**a` will always be larger than `2(a+b)-2` (which is (probably) the largest possible `n`) *except* for the cases `a=1|b=1` or `a=b=2`. The cases `a=b=1` and `a=b=2` have valid solutions that do not use exponents: `*` and `/|U+U`, respectively. For the rest of the cases where `a=1,b>1`, `a**b=1` which can also be found with `a%b` and `b**a=b` which can also be found with `b*a`.

Concatenation is not included because it was shown to always be larger than `n`.

## Input

2 positive integers.
Standard I/O methods are accepted. Standard loopholes are forbidden.
You can assume the input will always be within a valid range for your given language.

## Output

A list or array of the mathematical operations that can be used with the inputs to generate every number from `1` to `n` inclusive where `n` is the smallest prime larger than the sum of the two inputs. (You do not need to output the value of `n`.)

Output can be in any format valid for your language so long as it is clearly understood. For instance, it can be an array where each value is a separate operation, a string with a delimiter between each value, or even just a solid string where each character is a different value.

You can use any character(s) so long as each possible result has a unique representation. For instance, `+-*/%|^&U` will work and so will `123456789`, `UNRELATID`, and `CODEgolf!`. You are advised to include a legend or explanation of how the output can be read.

If more than one operation can be used to generate a given number, you may output any one of them. Do not output all of them.

## Testcases

```
Input  |   n  |   Example Valid Output
-----------------------------------------
2, 3   |   7  |   Subtraction, Modulus, Bitwise OR, Unrelated, Addition, Multiplication, Unrelated
2, 3   |   7  |   -%|U+*U
2, 3   |   7  |   2579139
1, 1   |   3  |   [*,+,U]
6, 6   |  13  |   ["/","U","U","U","U","&","U","U","U","U","U","+","U"]
6,12   |  19  |   U/U&U-UUU^UUU|UUU+U
12,6   |  19  |   U/U&U-UUU^UUU|UUU+U
7,11   |  19  |   /U&-UU%UUUU^UU|UU+U
7,15   |  23  |   %/UUUU%-UUUUUU|UUUUUU+U  (2nd value is a floor divide)

```

(I can easily add more test cases if someone finds an interesting one.)

I *think* the test case outputs are all valid but I've been known to mistakes. Please tell me if you spot one.

## Scoring

This is so fewest bytes wins!

# Answer
# Jelly, ~~52~~ ~~49~~ 35 bytes

```
:;%;ạ;+;×;|;^;&;:@;%@
³çi
+ÆnRç@€%8

```

Try it online!

**Explanation**

```
:;%;ạ;+;×;|;^;&;:@;%@ - helper link 0, finds related numbers
:;%;ạ;+;×;|;^;&;:@;%@ - just lists all of the operations, separated by
                         `;` which appends each result to the previous
                         results. Uses `@` to reverse args on : and %

³çi                   - helper link 1, saves a byte in control flow
 ç                    - helper link 0, called on
³                     - first program input and
                         (implicit) second program input
   i                  - find the index of the input whole number in
                         the output list from helper link 0
+ÆnRç@€%8
+Æn                   - find the nearest prime greater than the sum
   R                  - all whole numbers less than or equal to the prime
    ç@€               - for each whole number, call helper link 1
                         with first argument second program input and
                         second argument the whole number
       %8             - modulo 8 each index: Maps the reversed argument
                         functions to the non-reversed functions

```
> 2 votes

# Answer
# JavaScript (ES6), 134 bytes

```
(a,b)=>eval("for(t=a+b,i=0;i=i<t;)for(++t;t%++i;);for(q=n='';n++<t;)[...'+-*/%^&|>'].every(o=>n^eval(a+(p=o)+b)&&n^eval(b+o+a)),q+=p")

```

Using the standard symbols for operations in JavaScript, except for `unrelated` that is `>`

*Less golfed*

```
(a,b)=>
{
  // find the smallest prime greater than the sum of a and b
  for (t = a + b, i = 0; i < t; )
    for(i=1, ++t; t % ++i; );

  // loop from 1 to t
  // accumulate output in q
  for(q='', n = 0; n++ < t; )
  {
    // try all binary operators
    // to avoid error in 'eval', I need a binary operator for 'unrelated', so I choose '>'
    [...'+-*/%^&|>'].every( // every terminates early if the result is false
      o => (
        p = o,
        n ^ eval(a+o+b) && n ^ eval(b+o+a)
      )
      // using xor to check for equality, the result is cast to integer
      // eventually flooring the division result
    )
    q += p
  }
  return q
}

```

**Test**

```
F=
(a,b)=>eval("for(t=a+b,i=0;i=i<t;)for(++t;t%++i;);for(q=n='';n++<t;)[...'+-*/%^&|>'].every(o=>n^eval(a+(p=o)+b)&&n^eval(b+o+a)),q+=p")

console.log(2,3,F(2,3))
console.log(1,1,F(1,1))
console.log(6,6,F(6,6))
console.log(6,12,F(6,12))
console.log(7,15,F(7,15))
```
> 5 votes

# Answer
# Ruby, ~~131~~ 129+7 = ~~138~~ 135 bytes

Uses the `-rprime` flag.

`C` for concatenation and `U` for unrelated.

```
->a,b{(1..Prime.find{|i|i>a+b}).map{|i|("C+-*/%|^&".chars+["**",""]).find{|o|o.tr!?C,'';eval([a,b]*o)==i||eval([b,a]*o)==i}||?U}}

```

Try it online!
> 3 votes

# Answer
# Jelly, 37 bytes

```
⁾ðɓ;@€”⁹;€“+ạ×d|^&”j”,¤v€⁸F
+Æni@€¢%8

```

**Try it online!** (footer formats the output from the native list of numbers to print a representation using the operation symbols from the question)

### How?

Ignores checking of string concatenation and exponentiation as they are unnecessary.

Creates two (similar) links of Jelly code and evaluates them to evaluate to find the values of applying each of the **9** dyadic operations with the arguments in both orders. Flattens this into a single list and finds the index at which each value in the range `[1,p]` is first found, or **0**. Takes the result modulo **8** to collapse the two values for each of reversed subtraction, reversed `div` and reversed `mod` to a single values.

```
⁾ðɓ;@€”⁹;€“+_×d|^&”j”,¤v€⁸F - Link 1: evaluate all operations: number a, number b
⁾ðɓ                         - literal "ðɓ"
      ”⁹                    - literal '⁹'
   ;@€                      - concatenate for €ach -> ["⁹ð","⁹ɓ"]
                      ¤     - nilad followed by link(s) as a nilad:
          “+_×d|^&”         -   literal "+_×d|^&"
                    ”,      -   literal ','
                   j        -   join -> "+,_,×,d,|,^,&"
        ;€                  - concatenate for €ach -> ["⁹ð+,_,×,d,|,^,&","⁹ɓ+,_,×,d,|,^,&"]
                         ⁸  - link's left argument, a
                       v€   - evaluate €ach with argument a:
                            - 1 ⁹ð+,_,×,d,|,^,&
                            -   ⁹               - right argument, b
                            -    ð              - dyadic chain separation
                            -      , , , , , ,  - pair results (yields a list like [[[[[[a+b,aạb],a×b],adb],a|b],a^b],a&b])
                            -     +             - addition
                            -       _           - subtraction
                            -         ×         - multiplication
                            -           d       - divmod (returns a pair of values)
                            -             |     - bitwise-or
                            -               ^   - bitwise-xor
                            -                 & - bitwise-and
                            -
                            - 2 ⁹ɓ+,_,×,d,|,^,& - just like above except:
                            -    ɓ              - dyadic chain separation
                            -                   - ...with argument reversal
                            -
                          F - flatten the two into one list

+Æni@€¢%8 - Main link: number a, number b
+         - addition -> a+b
 Æn       - next prime
      ¢   - call last link (1) as a dyad -> Link(1)(a, b) = [b+a,b-a,b*a,b/a,b%a,b|a,b^a,b&a,a+b,a-b,a*b,a/b,a%b,a|b,a^b,a&b]
   i@€    - first index for €ach (e.g. if a=8, b=3 and n=5 the first index of 5 is 10, a-b)
       %8 - modulo 8             (... 10%8 = 2, aligning with b-a. Same goes for / and %)

```
> 3 votes

# Answer
# Python 2, ~~175~~ ~~173~~ 172 bytes

This doesn't handle exponentiation or concatenation, because I don't think there will ever be a case where they are necessary. ``a`+`b`` should always be greater than `n`. Same with `a**b`. If someone proves this one way or another, let me know.

```
a,b=input()
n=a+b+1
while 0 in[n%m for m in range(2,n)]:n+=1
for i in range(n):
 for o in'+-*/%|^&':
    x='a'+o+'b==i+1'
    if eval(x)+eval(x[::-1]):print o;break
 else:print 0

```

**Try it online**

Prints the operator for a solution, or `0` if unrelated.
> 2 votes

# Answer
# Haskell, ~~163~~ 162 bytes

```
import Data.Bits
f a b=[last$0:[n|(n,(#))<-zip[1..][(+),(-),(*),div,mod,(^),(.|.),(.&.),xor],a#b==c||b#a==c]|c<-[1..head[p|p<-[a+b+1..],all((>0).mod p)[2..p-1]]]]

```

Output is given as a list of integers, which correspond to operations as follows:

0 = Unrelated
1 = Addition
2 = Subtraction
3 = Multiplication
4 = Division
5 = Modulo
6 = Exponentiation
7 = Bitwise OR
8 = Bitwise AND
9 = Bitwise XOR

It will never output concatenation, since I've proven that it will never occur.

-1 byte by replacing `/=` with `>` in the primality test.
> 2 votes

# Answer
## JS (ES6), ~~249~~ ~~194~~ 188 bytes

```
(a,b)=>{
  p=n=>{for(i=n;n%--i;);return i-1};    // return 0 if n is prime, non-zero otherwise
  for(n=a-~b;p(n);)n++;                 // increment n until it is prime
  for(z=Array(n).fill(0),               // set all to 'unrelated' (0) and ...
      o="+-*/%|^&",c=0;h=o[c];c++)      // loop through the various operators
    for(v="ab",q=2;q--;)                // try both a?b and b?a
      i=~~eval(v[q]+h+v[1-q]),          // calc the value and floor it
      i>n||i>0&&(z[i-1]=h);             // if within limits, record it
  return z
}

```

This is a complete overhaul of my original answer which was a 249 byte solution.

Technically this does potentially include exponentiation and concatenation, but since they never show up in the answers, I culled out the code. Heh.

A single line answer:

```
(a,b)=>{p=n=>{for(i=n;n%--i;);return i-1};for(n=a-~b;p(n);)n++;for(z=Array(n).fill(0),o="+-*/%|^&",c=0;h=o[c];c++)for(v="ab",q=2;q--;)i=~~eval(v[q]+h+v[1-q]),i>n||i>0&&(z[i-1]=h);return z}

```

```
f=
(a,b)=>{p=n=>{for(i=n;n%--i;);return i-1};for(n=a-~b;p(n);)n++;for(z=Array(n).fill(0),o="+-*/%|^&",c=0;h=o[c];c++)for(v="ab",q=2;q--;)i=~~eval(v[q]+h+v[1-q]),i>n||i>0&&(z[i-1]=h);return z}

console.log(f(2,3))
console.log(f(1,1))
console.log(f(6,6))
console.log(f(6,12))
console.log(f(7,15))
```

Recently, switched to stack snippet instead of tio.run and changed `console.log(z)` to `return z`. I was returning at first then switched to console.log because I though returning was against the rules. Its never quite clear to me when I'm allowed to return values rather than outputting them directly, but I see other golfers do it this way.

Also, Try it online! (redundant, I know, but I finally figured out tio.run.)
> 1 votes

---
Tags: code-golf, math, number, integer
---


title: Discord large text generator

text:
# Question
Title: Discord large text generator
**Input:**

The input will be a string of any characters.

**Output:**

the output will be an emojified (discord emojis) version of the input string. The way it will work is as so:

**Letters:** a-z (case insensitive) will become ':regional\_indicator\_**lowercase letter here**:'

e.g 'A' will become ':regional\_indicator\_a:'

**Digits:** any digits (0-9) will become the word version of the digit like so ':**digit**:'

e.g '0' will become ':zero:'

**Whitespace:** any whitespace character that's matched with the regex: /\s/ will become ':white\_large\_square:'

e.g ' ' will become ':white\_large\_square:'

**Important notes:**

* The ':' surrounding the emoji's are necessary or else it won't display correctly in discord.
* Each emoji needs to be separated by 1 space or else it won't display correctly in discord.
* Trailing whitespace is allowed in the final output.
* Any other characters that it comes across should not be in the final output and will be ignored.

**Examples:**

**#1:** Input:

```
this is a test string 0123456789

```

output:

```
:regional_indicator_t: :regional_indicator_h: :regional_indicator_i: :regional_indicator_s: :white_large_square: :regional_indicator_i: :regional_indicator_s: :white_large_square: :regional_indicator_a: :white_large_square: :regional_indicator_t: :regional_indicator_e: :regional_indicator_s: :regional_indicator_t: :white_large_square: :regional_indicator_s: :regional_indicator_t: :regional_indicator_r: :regional_indicator_i: :regional_indicator_n: :regional_indicator_g: :white_large_square: :zero: :one: :two: :three: :four: :five: :six: :seven: :eight: :nine:

```

**#2:** input:

```
!?#$YAY 1234

```

output:

```
:regional_indicator_y: :regional_indicator_a: :regional_indicator_y: :white_large_square: :one: :two: :three: :four:

```

**#3:** input:

```
lots         of         spaces

```

output:

```
:regional_indicator_l: :regional_indicator_o: :regional_indicator_t: :regional_indicator_s: :white_large_square: :white_large_square: :white_large_square: :white_large_square: :white_large_square: :white_large_square: :white_large_square: :white_large_square: :white_large_square: :regional_indicator_o: :regional_indicator_f: :white_large_square: :white_large_square: :white_large_square: :white_large_square: :white_large_square: :white_large_square: :white_large_square: :white_large_square: :white_large_square: :regional_indicator_s: :regional_indicator_p: :regional_indicator_a: :regional_indicator_c: :regional_indicator_e: :regional_indicator_s:

```

Examples as shown in discord:

**This is codegolf so the shortest code wins!**

# Answer
# 05AB1E, 75 bytes

```
žK…
©«Ãlvyaiy’‹¬_Âì_ÿ’}ydiy“¡×€µ‚•„í†ìˆÈŒšï¿Ÿ¯¥Š“#è}®yåi’„¸_…Æ_ï©’}…:ÿ:ðJ

```

Try it online!

**Explanation**

```
žK…<space><tab><newline>©«Ã   # remove any character that isn't in [A-Za-z0-9<whitespace>]
lv                            # loop over each character converted to lowercase
yai                           # if it is a letter
   y’‹¬_Âì_ÿ’}                # interpolate into string "regional_indicator_<letter>"
ydi                           # if it is a digit
   y“¡×€µ‚•„í†ìˆÈŒšï¿Ÿ¯¥Š“#è} # extract it from a list of digits as words
®yåi                          # if it is whitespace
    ’„¸_…Æ_ï©’}               # push the string "large_white_square"
…:ÿ:                          # interpolate in string ":<emoji>:"
    ð                         # push a space
     J                        # join stack to one string

```
> 2 votes

# Answer
# Python 2, ~~275~~ ~~268~~ 267 bytes

```
d=['']*256
d[48:58]='zero one two three four five six seven eight nine'.split()
d[9]=d[10]=d[32]='white_large_square'
d[65:90]=d[97:122]=map(lambda c:'regional_indicator_'+chr(c),range(97,122))
print' '.join((':%s:'%d[ord(c)])*(d[ord(c)]!='')for c in input()).strip()

```

It creates a large list of strings, iterates through the input string's characters and gets the string from the list using the character's `ord` value. Works for ascii characters only. Replaces space, tab and newline only; any other whitespace will be discarded.

It did leave whitespaces in front so I had to strip it in the end.

I also tried doing it with regex, turned out to be longer (286 bytes):

```
import re
print re.sub('([ \t\n])|([a-z])|(\d)',lambda m:':'+['white_large_square','regional_indicator_'+m.group(m.lastindex),'zero one two three four five six seven eight nine'.split()[(ord(m.group(m.lastindex))-68)%10]][m.lastindex-1]+': ',re.sub('[^a-z0-9 \t\n]','',input().lower()))

```
> 8 votes

# Answer
## C#, ~~296~~ 273 bytes

---

### Data

* **Input** `String` `i` The string to be converted
* **Output** `String` The input converted

---

### Golfed

```
(string i)=>{var o="";foreach(var c in i){var k=c|32;var t=k>96&&k<123?"regional_indicator_"+(char)k:char.IsWhiteSpace(c)?"white_large_square":c>47&&c<58?new[]{"zero","one","two","three","four","five","six","seven","eight","nine"}[c-48]:"";o+=t!=""?$":{t}: ":t;}return o;};

```

---

### Ungolfed

```
( string i ) => {
   var o = "";

   foreach( var c in i ) {
      var k = c | 32;
      var t = k > 96 && k < 123
         ? "regional_indicator_" + (char) k
         : char.IsWhiteSpace( c )
            ? "white_large_square"
            : c > 47 && c < 58
               ? new[] { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }[ c - 48 ]
               : "";

      o += t != ""
         ? $":{ t }: "
         : t;
   }

   return o;
};

```

---

### Ungolfed readable

```
// Receives a string to be converted
( string i ) => {

   // Initializes a var to store the output
   var o = "";

   // Cycle through each char in the string
   foreach( var c in i ) {
      // Creates a temp int to check for 'a' - 'z'
      var k = c | 32;

      // Creates a temp string that checks if the char is a lowercase letter
      var t = k > 96 && k < 123
         // If so, "builds" a Discord letter
         ? "regional_indicator_" + (char) k

         // Otherwise, checks if the char is a whitespace
         : char.IsWhiteSpace( c )
            // If so, "builds" a Discord white square
            ? "white_large_square"

            // Otherwise, checks if the char is a digit
            : c > 47 && c < 58
               // If so, gets the digit name
               ? new[] { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }[ c - 48 ]

               // Otherwise, builds nothing
               : "";

      // Checks if the temp string is empty or not
      o += t != ""
         // If so, format it properly -- capsulate with ':' and add a space at the end
         ? $":{ t }: "

         // Otherwise, add the temp string, it's empty, so won't do anything
         : t;
   }

   // Return the converted string
   return o;
};

```

---

### Full code

```
using System;
using System.Collections.Generic;

namespace Namespace {
   class Program {
      static void Main( String[] args ) {
         Func<String, String> f = ( string i ) => {
            var o = "";

            foreach( var c in i ) {
               var k = c | 32;
               var t = k > 96 && k < 123
                  ? "regional_indicator_" + (char) k
                  : char.IsWhiteSpace( c )
                     ? "white_large_square"
                     : c > 47 && c < 58
                        ? new[] { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }[ c - 48 ]
                        : "";

               o += t != ""
                  ? $":{ t }: "
                  : t;
            }

            return o;
         };

         List<String>
            testCases = new List<String>() {
               "this is a test string 0123456789",
               "!?#$YAY 1234",
               "lots         of         spaces",
            };

         foreach( String testCase in testCases ) {
            Console.WriteLine( $" Input: {testCase}\nOutput: {f( testCase )}\n" );
         }

         Console.ReadLine();
      }
   }
}

```

---

### Releases

* **v1.1** \- `-23 bytes` \- Implemented pinkfloydx33 suggestions.
* **v1.0** \- `296 bytes` \- Initial solution.

---

### Notes

* None
> 4 votes

# Answer
# Retina, 142 bytes

```
T`w	¶p`_dll%%%_
.
:$&:
[a-z]
regional_indicator_$&
%
white_large_square
0
zero
1
one
2
two
3
three
4
four
5
five
6
six
7
seven
8
eight
9
nine

```

Really wish there was an easier way to replace the digits.

Try it online!

### Explanation

```
T`w ¶p`_dll%%%_

```

(Note the tab before the ) This is a transliteration stage with changes all letters to lowercase, all whitespace to `%`, and deletes every other character.

```
.
:$&:

```

Next, every character gets wrapped in colons and followed by a space.

```
[a-z]
regional_indicator_$&

```

Next, letters are replaced with regional indicators.

```
%
white_large_square

```

And `%`, which were previously whitespace, are replaced with `white_large_square`.

```
0
zero
1
one
.......

```

And finally, the digits are replaced with their respective emojis.
> 2 votes

# Answer
# Ruby, 184 bytes

```
->x{[x.chars.map{|c|[?:,': ']*(c==$;?'white_large_square':c=~/\d/?%w[zero one two three four five six seven eight nine][c.to_i]:c=~/[A-Z]/i?'regional_indicator_%s'%c.downcase: 0)}]*''}

```

Try it online!
> 2 votes

# Answer
# PHP\>=7.0, 202 Bytes

```
for(;a&$c=$argn[$i++];)echo($e=[0,"",ctype_alpha($c)=>regional_indicator_.lcfirst($c),ctype_space($c)=>white_large_square,ctype_digit($c)=>strtolower(substr(IntlChar::charName("$c"),6))][1])?":$e: ":"";

```

It exists no Online Interpreter which contains IntlChar::charName

## PHP, 211 Bytes

is the nearest way to solve this without IntlChar::charName

```
for(;a&$c=$argn[$i++];)echo($e=[0,"",ctype_alpha($c)=>regional_indicator_.lcfirst($c),ctype_space($c)=>white_large_square,ctype_digit($c)=>[zero,one,two,three,four,five,six,seven,eight,nine][$c]][1])?":$e: ":"";

```

Try it online!

# PHP\>=7.0, 220 Bytes

Regex Based

```
<?=preg_replace_callback("#(\pL)|(\d)|(\s)|.#",function($t){$r=!$t[1]?!$t[2]?!$t[3]?"":white_large_square:strtolower(substr(IntlChar::charName("$t[2]"),6)):regional_indicator_.lcfirst($t[1]);return$r?":$r: ":"";},$argn);

```

It exists no Online Interpreter which contains IntlChar::charName

## PHP, 229 Bytes

is the nearest way to solve this without IntlChar::charName

```
<?=preg_replace_callback("#(\pL)|(\d)|(\s)|.#",function($t){$r=!$t[1]?!$t[2]?!$t[3]?"":white_large_square:[zero,one,two,three,four,five,six,seven,eight,nine][$t[2]]:regional_indicator_.lcfirst($t[1]);return$r?":$r: ":"";},$argn);

```

Try it online!
> 1 votes

# Answer
# , 141 bytes

```
Óá/:regional_indicator_&:
Óä/½':'.split('zero one two three four five six seven eight nine')[submatch(0)].':'
Óó/:white_large_square:
Ó::/: :

```

Try it online!
> 1 votes

# Answer
# Python, ~~212~~ 205 bytes

```
lambda s:''.join('/'<c<':'and':'+'zero one two three four five six seven eight nine'.split()[int(c)]+': 'or'`'<c<'{'and':regional_indicator_'+c+': 'or':white_large_square: '*(c in' 	\n')for c in s.lower())

```

Try it online!
> 1 votes

# Answer
# JavaScript (ES6), ~~197~~ 199 bytes

Fixed underscores not being handled properly thanks to @Neil.

```
s=>s.toLowerCase().replace(/_|(\d)|(\w)|(\s)|./g,(c,d,a,w)=>a||d||w?`:${a?"regional_indicator_"+c:d?"zero one two three four five six seven eight nine".split` `[c]:"white_large_square"}: `:"").trim()

```

## Cleaned up

```
s => s.toLowerCase().replace( /_|(\d)|(\w)|(\s)|./g, (c, d, a, w) => {
    if(a || d || w) {
        let out;
        if (a) out = "regional_indicator_" + c;
        else if (d) out = "zero one two three four five six seven eight nine".split(" ")[c];
        else out = "white_large_square";
        return `:${out}: `;
    }
    else {
        return "";
    }
}).trim()

```

## Test Snippet

```
f=
s=>s.toLowerCase().replace(/_|(\d)|(\w)|(\s)|./g,(c,d,a,w)=>a||d||w?`:${a?"regional_indicator_"+c:d?"zero one two three four five six seven eight nine".split` `[c]:"white_large_square"}: `:"").trim()
```

```
<input id="I" type="text" size="50" oninput="O.innerHTML=f(I.value)">
<pre id="O" style="width:90vw;white-space:pre-wrap">
```
> 0 votes

# Answer
# PowerShell, ~~200~~ 197 Bytes

-3 because the `[A-Za-z]` regex isn't needed in the default case-insensitive regex matches.

```
$a=switch -R ([char[]]"$args"){
"[0-9]"{(-split'zero one two three four five six seven eight nine')["$_"]}
"[a-z]"{"regional_indicator_"+"$_"|% *l*r}
"\s"{"white_large_square"}};":$($a-join': :'):"

```

Would like to find:

a way around using `$a` \- wrapping a switch statement in brackets causes it to not work at all for some reason, and any other method is longer than just using a variable.

Try it online! \- input whatever you want and get the result easily.
> 0 votes

---
Tags: code-golf, string
---


title: When's the nearest special common year?

text:
# Question
Title: When's the nearest special common year?
A common year is a year that is not a leap year and where the first and last day of the year are on the same day. A special common year is one that starts on a Monday and so ends on a Monday as well.

Your challenge is to create a program/function that when given a year as input finds the nearest special common year, outputting itself if it is a common year. If the year is as close to the one before it as the one next to it output the larger one.

**Input**

An integer representing the year to test against in the range `1600 <= x <= 2100`.

**Output**

An integer representing the nearest special common year.

**Test cases**

```
2017 -> 2018
2018 -> 2018
1992 -> 1990
1600 -> 1601
2100 -> 2103
1728 -> 1731 (lies between 1725 and 1731)

```

**Notes**

All 54 years in the given range are already shown in the linked Wikipedia article. I will also provide them here for reference:

```
1601, 1607, 1618, 1629, 1635, 1646, 1657, 1663, 1674, 1685, 1691
1703, 1714, 1725, 1731, 1742, 1753, 1759, 1770, 1781, 1787, 1798
1810, 1821, 1827, 1838, 1849, 1855, 1866, 1877, 1883, 1894, 1900
1906, 1917, 1923, 1934, 1945, 1951, 1962, 1973, 1979, 1990
2001, 2007, 2018, 2029, 2035, 2046, 2057, 2063, 2074, 2085, 2091
2103 (Needed for 2097 to 2100)

```

# Answer
# Jelly, 30 bytes

```
“Þıİs|9ṗ[¿¶F’ṃ“©€¿‘⁽£d;+\ạÐṂ⁸Ṁ

```

A monadic link taking and returning an integer year.

**Try it online!** or see a test suite.

### How?

Much like other answers this builds the list of years required for the input domain from the increments, and finds the maximal year of minimal absolute difference from the input.

```
“Þıİs|9ṗ[¿¶F’ṃ“©€¿‘⁽£d;+\ạÐṂ⁸Ṁ - Main link: number y
                   ⁽£d         - augmented base 250 literal = 1601
“Þıİs|9ṗ[¿¶F’                  - base 250 literal = 20129386383114231907032071
              “©€¿‘            - code page index list = [6,12,11]
             ṃ                 - base decompression = [6,11,11,6,11,11,6,11,11,6,12,11,11,6,11,11,6,11,11,6,11,12,11,6,11,11,6,11,11,6,11,6,6,11,6,11,11,6,11,11,6,11,11,6,11,11,6,11,11,6,11,11,6,12]
                      ;        - concatenate = [1601,6,11,11,6,11,11,6,11,11,6,12,11,11,6,11,11,6,11,11,6,11,12,11,6,11,11,6,11,11,6,11,6,6,11,6,11,11,6,11,11,6,11,11,6,11,11,6,11,11,6,11,11,6,12]
                       +\      - reduce with addition = [1601,1607,1618,1629,1635,1646,1657,1663,1674,1685,1691,1703,1714,1725,1731,1742,1753,1759,1770,1781,1787,1798,1810,1821,1827,1838,1849,1855,1866,1877,1883,1894,1900,1906,1917,1923,1934,1945,1951,1962,1973,1979,1990,2001,2007,2018,2029,2035,2046,2057,2063,2074,2085,2091,2103]
                            ⁸  - link's left argument, y
                          ÐṂ   - filter keep if maximal:
                         ạ     -   absolute difference
                             Ṁ - maximum (alternatively tail, Ṫ, since increasing)

```
> 1 votes

# Answer
# PHP, 67 Bytes

```
for(;date(LN,mktime(0,0,0,1,1,$y=$argn+$i))>1;)$i=($i<1)-$i;echo$y;

```

Try it online!

or

```
for(;date(LN,strtotime("1/1/".$y=$argn+$i))>1;)$i=($i<1)-$i;echo$y;

```

Try it online!

Expanded

```
for(;
date(LN,mktime(0,0,0,1,1,$y=$argn+$i)) # N is 1 for Monday and L is 0 for Non leap year
>1;) # loop so long as expression is not 1
  $i=($i<1)-$i; # set $i 0,1,-1,2,-2 ...
echo$y; # Output Year

```

date
> 9 votes

# Answer
# Python 2, ~~129~~ ~~124~~ 118 bytes

```
a=[11,11,6]*13
a[29:29]=a[19:19]=12,
a[10:10]=6,6
n=input()
o=[2401-n]
for i in a*2:o+=o[-1]-i,
print n+min(o,key=abs)

```

Try it online! or Try all test cases
First, the sequence is generated (reversed) on `a`, then `2401 - input_year` is used as starting value to be subtracted over the sequence.
This way the list `o` will contain the differences between all the common years and the input, the nearest year will be the number that is nearest to zero (positive or negative), then will be extracted with `(min, key=abs)` and added back to the input.

## With `datetime`, 119 bytes

```
lambda i:i+min([y-i for y in range(2200,1500,-1)if datetime(y,1,1).weekday()<1and y%400],key=abs)
from datetime import*

```

Try it online!
> 8 votes

# Answer
# 05AB1E, 41 bytes

```
6xD<Š)•HΘ%A°,SΔA)u•3вè.pO0¸ì1601+DI-ÄWQÏ¤

```

Try it online!

**Explanation**

```
6xD<Š)                                     # push the list [11,6,12]
      •HΘ%A°,SΔA)u•                        # push the number 20129386383114231907032071
                   3в                      # convert to a base-3 digit list
                     è                     # use this to index into the first list
                      .p                   # get list of prefixes
                        O                  # sum each sublist
                         0¸ì               # prepend 0
                            1601+          # add 1601 to each
                                 D         # duplicate
                                  I-       # subtract input from each
                                    Ä      # calculate absolute value
                                     WQÏ   # keep only the years that have the
                                           # smallest absolute difference from input
                                        ¤  # get the last one

```
> 7 votes

# Answer
## JavaScript (ES6), 77 bytes

```
f=(y,z=y,d=m=>new Date(y,m,!m||31).getDay()-1)=>d(0)|d(11)?f(z<y?z-1:z+1,y):y
```

```
<input type=number value=2001 oninput=o.textContent=f(+this.value)><pre id=o>2001
```
> 5 votes

# Answer
## Mathematica, 70 bytes

```
Max@Nearest[Select[Range[7!],!LeapYearQ@{#}&&DayName@{#}==Monday&],#]&

```

Generates a list of all special common years up to year 5040 (= 7!) and then finds the nearest one to the input, taking the maximum in case of a tie.
> 4 votes

# Answer
# Java 7, 217 bytes

```
import java.util.*;int c(int y){return d(y,1);}int d(int y,int x){Calendar c=Calendar.getInstance(),d=Calendar.getInstance();c.set(y,0,1);d.set(y,11,31);return c.get(7)==d.get(7)&c.get(7)==2?y:d(y+x,x>0?-++x:-(--x));}

```

**Explanation:**

Try it here.

```
import java.util.*;                   // Required import for Calendar

int c(int y){                         // Method with integer parameter and integer return-type
  return d(y,1);                      //  Call second method with additional parameter
}                                     // End of method (1)

int d(int y,int x){                   // Method (2) with two integer parameters and integer return-type
  Calendar c=Calendar.getInstance(),  //  Create two Calendar instances
           d=Calendar.getInstance();
  c.set(y,0,1);                       //  Set one to 01 January yyyy
  d.set(y,11,31);                     //  and one to 31 December yyyy
  return c.get(7)==d.get(7)           //  If both are the same day of the week
         &c.get(7)==2?                //  and it is a Monday:
          y                           //   Return the input-year
         :                            //  Else:
          d(y+x,                      //   Recursive-call with year + `x`
                x>0?-++x:-(--x));     //   and change `x` to the next to check
                                      //   +1,-2,+3,-4,+5,-6,etc.
}                                     // End of method (2)

```
> 3 votes

# Answer
# MATL, ~~32~~ 31 bytes

```
`G@2&\wEq*-XJtQv24KUhBh9XO77-}J

```

Try it online! Or verify all test cases
> 3 votes

# Answer
# C#, 183 bytes

To get the ball rolling a bit, here's an implementation I've done of my own. I'm pretty sure it can still be golfed down so if anyone wants to feel free to post as a new answer.

```
namespace System.Linq{n=>Enumerable.Range(1,9999).Where(y=>!DateTime.IsLeapYear(y)&(int)new DateTime(y,1,1).DayOfWeek==1).GroupBy(y=>Math.Abs(n-y)).OrderBy(g=>g.Key).First().Last();}

```

Try it online!

Full/Formatted version, this also shows all outputs for the given range when ran.

```
namespace System.Linq
{
    class Program
    {
        static void Main(string[] args)
        {
            Func<int, int> f = n =>
                Enumerable.Range(1, 9999)
                          .Where(y => !DateTime.IsLeapYear(y)
                                    & (int)new DateTime(y, 1, 1).DayOfWeek == 1)
                          .GroupBy(y => Math.Abs(n - y))
                          .OrderBy(g => g.Key)
                          .First()
                          .Last();

            for (int y = 1600; y <= 2100; ++y)
            {
                Console.WriteLine($"{y} -> {f(y)}");
            }

            Console.ReadLine();
        }
    }
}

```
> 1 votes

# Answer
# Ruby, 145 bytes

```
f=->i{i+(1.upto(i).map{|m|Time.new(y=i+m).monday?&&Time.new(y,6).friday?? m:Time.new(y=i-m).monday?&&Time.new(y,6).friday?? -m :nil}.find{|a|a})}

```

Defines a lambda taking the start year as input - `f[2017] => 2018`

Gotta love the Ruby standard library! `wday==1` is the same length as `monday?` and infinitely less cool :). The special common year check is done by the fact that in a common year starting Monday, 1st June is a Friday ("friday" being the equal-shortest day name!)

Unfortunately, it's not so good at searching in both directions.
> 1 votes

---
Tags: code-golf, date
---


title: Find primitive semiperfect numbers

text:
# Question
Title: Find primitive semiperfect numbers
## Semiperfect numbers

A semiperfect/pseudoperfect number is an integer equal to the sum of a part of or all of its divisors (excluding itself). Numbers which are equal to the sum of all of their divisors are perfect.

```
Divisors of 6 : 1,2,3
      6 = 1+2+3 -> semiperfect (perfect)
Divisors of 28 : 1,2,4,7,14
      28 = 14+7+4+2+1 -> semiperfect (perfect)
Divisors of 40 : 1,2,4,5,8,10,20
      40 = 1+4+5+10+20 or 2+8+10+20 -> semiperfect

```

## Primitive

A primitive semiperfect number is a semiperfect number with no semiperfect divisors (except itself :))

```
Divisors of 6 : 1,2,3
      6  = 1+2+3 -> primitive
Divisors of 12 : 1,2,3,4,6
      12 = 2+4+6 -> semiperfect

```

As references, please use the OEIS series A006036 for primitive semiperfect numbers, and A005835 for semiperfects.

## Goal

Write a program or a function in any language. It will take as input a number n as a function parameter or from STDIN/your language's closest alternative, and will output all the primitive semi-perfect numbers from 1 to n (inclusive).

The output must be formated as `6[separator]20[separator]28[separator]88...` where \[separator\] is either as newline, a space or a comma. There must not be a starting \[separator\] nor a ending one.

**Edit : you can leave a trailing newline**

## Examples

input :

```
5

```

output :

input :

```
20

```

output :

```
6
20

```

input :

```
100

```

output :

```
6 20 28 88

```

## Scoring

This is code-golf, so the shortest code in bytes win.

Don't try to fool us with loopholes please :).

I'd be glad you could leave an explanation of your golfed code once you think you're done golfing it!

## As this challenge already have some nice answers, and is slowly getting quiet, I'll put an end to it. The winner of this code-golf will be decided on Monday 29th, 00:00 GMT. Well done to all of you that have answered, and good luck to those who will try to beat them :)

# Answer
# Pyth, ~~28~~ 27 bytes

```
VQI}KhNsMyJf!%KTSNI!@JYeaYK

```

*1 byte thanks to @Jakube*

Demonstration.

```
VQI}KhNsMyJf!%KTSNI!@JYeaYK
                                Implicit:
                                Y = []
                                Q = eval(input())
VQ                              for N in range(Q):
    KhN                         K = N+1
           f    SN              filter T over range(1, N)
            !%KT                the logical not of K%T.
                                This is the list of divisors of K.
          J                     Store the list in J.
         y                      Create all of its subsets.
       sM                       Map each subset to its sum.
  I}K                           If K is in that list: (If K is semiperfect)
                  I!@JY         If the intersection of J (the divisors)
                                and Y (the list of primitive semiperfect numbers)
                                is empty:
                        aYK     Append K to Y
                       e        And print its last element, K.

```
> 8 votes

# Answer
# Julia, ~~161~~ 149 bytes

```
n->(S(m)=!isempty(filter(i->i==unique(i)&&length(i)>1&&all(j->m%j<1,i),partitions(m)));for i=2:n S(i)&&!any(S,filter(k->i%k<1,1:i-1))&&println(i)end)

```

This creates an unnamed function that accepts an integer as input and prints the numbers to STDOUT separated by a newline. To call it, give it a name, e.g. `f=n->...`.

Ungolfed + explanation:

```
# Define a function that determines whether the input is semiperfect
# (In the submission, this is defined as a named inline function within the
# primary function. I've separated it here for clarity.)

function S(m)
    # Get all integer arrays which sum to m
    p = partitions(m)

    # Filter the partitions to subsets of the divisors of m
    d = filter(i -> i == unique(i) && length(i) > 1 && all(j -> m % j == 0, i), p)

    # If d is nonempty, the input is semiperfect
    !isempty(d)
end

# The main function

function f(n)
    # Loop through all integers from 2 to n
    for i = 2:n
        # Determine whether i is semiperfect
        if S(i)
            # If no divisors of i are semiperfect, print i
            !any(S, filter(k -> i % k == 0, 1:i-1) && println(i)
        end
    end
end

```

Examples:

```
julia> f(5)

julia> f(40)
6
20
28

```
> 3 votes

# Answer
# JavaScript (*ES6*) 172

Run the snippet below to test

```
f=
v=>eval("for(n=h=[];n++<v;!t*i&&n>1?h[n]=1:0){for(r=[l=i=t=1];++i<n;)n%i||(h[i]?t=0:l=r.push(i));for(i=0;t&&++i<1<<l;)r.map(v=>i&(m+=m)?t-=v:0,t=n,m=.5)}''+Object.keys(h)")

// Less golfed

ff=v=>
{
   h=[]; // hashtable with numbers found so far

   for (n=1; n <= v; n++)
   {
      r=[1],l=1; // r is the list of divisors, l is the length of this list
      t=1; // used as a flag, will become 0 if a divisor is in h
      for(i=2; i<n; i++)
      {
         if (n%i == 0)
            if (h[i])
               t = 0; // found a divisor in h, n is not primitive
            else
               l = r.push(i); // add divisor to r and adjust l
      }
      if (t != 0) // this 'if' is merged with the for below in golfed code
      {
         // try all the sums, use a bit mask to find combinations
         for(i = 1; t != 0 && i < 1<<l; i++)
         {
            t = n; // start with n and subtract, if ok result will be 0
            m = 0.5; // start with mask 1/2 (nice that in Javascript we can mix int and floats)
            r.forEach( v=> i & (m+=m) ? t -= v : 0);
         }
         if (t == 0 && n > 1) h[n] = 1; // add n to the hashmap (the value can be anything)
      }
   }
   // the hashmap keys list is the result
   return '' + Object.keys(h) // convert to string, adding commas
}

(test=()=> O.textContent=f(+I.value))();
```

```
<input id=I type=number oninput="test()" value=999><pre id=O></pre>
```
> 3 votes

# Answer
# CJam, 54 bytes

This solution feels a bit awkward, but since there have been few answers, and none in CJam, I thought I'd post it anyway:

```
Lli),2>{_N,1>{N\%!},_@&!\_,2,m*\f{.*:+}N#)e&{N+}&}fNS*

```

A good part of the increment over the posted Pyth solution comes from the fact that, as far as I could find, CJam does not have an operator to enumerate all subsets of a set. So it took some work to complete that with available operators. Of course, if there actually is a simple operator I missed, I'll look kind of silly. :)

Explanation:

```
L     Start stack with empty list that will become list of solutions.
li    Get input N and convert to int.
),2>  Build list of candidate solutions [2 .. N].
{     Start for loop over all candidate solutions.
_     Copy list of previous solutions, needed later to check for candidate being primitive.
N,1>  Build list of possible divisors [1 .. N-1].
{N\%!},  Filter list to only contain actual divisors of N.
_     Check if one of divisors is a previous solution. Start by copying divisor list.
@     Pull copy of list with previous solutions to top of stack
&!    Intersect the two lists, and check the result for empty. Will be used later.
\     Swap top two elements, getting divisor list back to top.
_,    Get length of divisor list.
2,    Put [0 1] on top of stack.
m*    Cartesian power. Creates all 0/1 sequences with same length as divisor list.
\     Swap with divisor list.
f{.*:+}  Calculate element by element product of all 0/1 sequences with divisors,
         and sum up the values (i.e. dot products of 0/1 sequences with divisors).
         The result is an array with all possible divisor sums.
N#)  Find N in list of divisor sums, and covert to truth value.
e&   Logical and with earlier result from primitive test.
{N+}&  Add N to list of solutions if result is true.
}fN  Phew! We finally made it to the end of the for loop, and have a list of solutions.
S*   Join the list of solutions with spaces in between.

```

Try it online
> 2 votes

# Answer
# PHP, 263 Bytes

```
function m($a,$n){for($t=1,$b=2**count($a);--$b*$t;$t*=$r!=$n,$r=0)foreach($a as$k=>$v)$r+=($b>>$k&1)*$v;return$t;}for($o=[];$i++<$argn;m($d,$i)?:$o=array_merge($o,range($r[]=$i,3*$argn,$i)))for($d=[],$n=$i;--$n*!in_array($i,$o);)$i%$n?:$d[]=$n;echo join(",",$r);

```

Try it online!

Expanded

```
function m($a,$n){
  for($t=1,$b=2**count($a);--$b*$t;$t*=$r!=$n,$r=0) #loop through bitmasks
    foreach($a as$k=>$v)$r+=($b>>$k&1)*$v; # loop through divisor array
  return$t;} # returns false for semiperfect numbers
for($o=[];$i++<$argn;
m($d,$i)?
  :$o=array_merge($o,range($r[]=$i,3*$argn,$i))) # Make the result array and the array of multiples of the result array
  for($d=[],$n=$i;--$n*!in_array($i,$o);) # check if integer is not in multiples array
    $i%$n?:$d[]=$n; # make divisor array
echo join(",",$r); #Output

```
> 2 votes

# Answer
# Jelly, 22 bytes

```
ÆDṖŒPS€i
ÆDÇ€TL’
RÇÐḟY

```

Try it online!

**Explanation**

```
ÆDṖŒPS€i - helper function to check if input is a semiperfect number
ÆD       - list of divisors of input
  Ṗ      - except for the last one (the input)
   ŒP    - power set = every possible subset of divisors
     S€  - sum of each subset
       i - return truthy iff input is one of these

ÆDÇ€TL’ - helper function to check if input is a primitive semiperfect number
ÆD       - list of divisors of input
  Ç€     - replace each with if they are a semiperfect number, based on
           the above helper function. If input is a primitive semiperfect
           number, we get something like [0,0,0,0,0,94].
    T    - get all truthy values.
     L’  - return falsy iff there is only one truthy value

RÇÐḟY    - main link
R        - Range[input]
 ÇÐḟ     - Filter out those elements which are not primitive semiperfect
           numbers, based on the helper function
    Y    - join by newlines.

```
> 1 votes

---
Tags: code-golf, number, sequence
---


title: Is it true or false?

text:
# Question
Title: Is it true or false?
I cannot believe that this hasn't been done before but I may be wrong. If so, just close as dupe.

This challenge is very similar to Is it truthy or falsy? but, IMO, isn't close enough to be a dupe. That has predefined "falsy" variables that all languages must use, some of which aren't even falsy; this uses your own falsy values.

Your task is to take an input, evaluate it and output whether it is truthy or falsy *in your language*.

The "evaluate" part is just so that the input isn't always a string containing the input. For example an input of `0` would be falsy in almost all languages even if `"0"` is truthy. It simply means, "convert it into its native type"

# Input

Anything. This can be taken from STDIN or as command line arguments.

# Output

Its truthy or falsy value *in your language*. This should be preferably be denoted by `true/false` or `1/0`. If not, please state what is the output for each.

For example, `1`, `"hello"` and `[0,2]` are all truthy in Python but the third isn't in MATL (? Correct me if wrong)

# Rules

* There must be 2 unique identifiers for truthy and falsy. You can't just say `numbers are true and symbols are false`
* Submissions must be **full programs**
* This is a but I have a feeling that a challenge this trivial might become a catalogue so if that happens, I will update the body to contain normal catalogue rules.
* Of course, builtins are allowed but must be part of a full program. For example, `bool` isn't a valid answer in Python.

Good luck!

# Answer
# Japt, ~~3~~ 2 bytes

```
o

```

Needs the `-d` flag.

Try it online!
> 4 votes

# Answer
# Brain-Flak, 14 bytes

```
({()(<()>)}<>)

```

Try it online!

## Explanation

```
(        #Set up a push
 {       #Execute if truthy
  ()     #Create 1 value
  (<()>) #Ensure a 0 to exit the loop
 }
 <>      #Switch stacks
)        #Push the value

```
> 2 votes

# Answer
# Convex, 2 bytes

```
!!

```

Try it online!
> 2 votes

# Answer
# RProgN 2, 2 bytes

```
¬¬

```

Try it online!
> 2 votes

# Answer
# RProgN, 1 char, 3 bytes

Added this because I've never really gotten a use for the `truthy` function, and I wanted to.

Try it online!
> 2 votes

# Answer
# Jelly,  ~~4~~  2 bytes

```
ṆṆ

```

Full program returning 1 for Truthy and 0 for Falsy.

**Try it online!**

### How?

```
ṆṆ - Main link: x
Ṇ  - non-vectorising logical not
 Ṇ - non-vectorising logical not

```
> 2 votes

# Answer
# Python 2, ~~28~~ 27 bytes

```
print(input()and 1>0or 0>1)

```

Less trivial than just `print(bool(input()))`. String input must be given in quotes as per Python 2 requirements.

-1 byte thanks to ovs
> 2 votes

# Answer
# JavaScript (ES6), 6 bytes

```
i=>!!i

```
> 0 votes

---
Tags: code-golf, decision-problem
---