答:
Mathematica, 89 bytes

```<code>Length@FixedPointList[StringLength@StringReplace[IntegerName@#,{" "->"","-"->""}]&,#]-2&
</code>```

Typical Mathematica: built-in functions good, long function names bad. FixedPointList applies its first argument (a function) to the second argument repeatedly until the answer doesn't change, listing all results; the results include the original input and two copies of the repeated output, hence the -2 at the end. Mathematica's built-in IntegerName contains spaces and hyphens, so we need to get rid of those by hand.

Annoyingly, IntegerName's output contains the character "‐" (Unicode #8208) rather than normal hyphens; that's why this submission is 89 bytes rather than 88. (And I couldn't precede the code above with four spaces and have it accept the Unicode character—any help?—so the above code won't work exactly right if cut and pasted.)

Title: Distance to four

Body:
This challenge is based on this video. I recommend that you watch it before trying this challenge.

First we define a function.  This function (OEIS) takes a integer n as input and outputs the number of letters in the English representation of n (without spaces or hyphens).  For example "three" has 5 letters so 3 maps to 5.

As demonstrated in the video starting with any number repeating this process will eventually result in a four, which will map to itself forever.

Here is a crude directed graph showing the orbits of the numbers less than 16:

```<code>  12 11
    \|
15 2 6 1 10 14 13
  \ \|/ /  /  /
   7 3-/  8--/
    \|   /
 9 0 5--/
  \ \|
   \-4
</code>```

Your challenge is to determine the number of steps that a number will take (or the number of times this function must be applied to a number) before reaching four (i.e. the level on the directed graph pictured).

Forming english numbers

Here is a brief explanation of how one should form english words for this challenge:

The numbers one through nineteen are:

one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen

For numbers greater than nineteen the process is as follows:

If the number has a hundreds place begin with the name of digit in the hundreds place and "hundred".

e.g.

```<code>100 -> "onehundred"
</code>```

If the remainder is less than twenty append the remainder's English representation.

e.g.

```<code>714 -> "sevenhundredfourteen"
</code>```

Otherwise if the tens digit is not zero append the proper representation:

```<code>2-> twenty
3-> thirty
4-> forty
5-> fifty
6-> sixty
7-> seventy
8-> eighty
9-> ninety
</code>```

e.g.

```<code>470 -> "fourhundredseventy"
</code>```

Finally if there is a one's digit append its representation

e.g.

```<code>681 -> "sixhundredeightyone"
</code>```

Further Stipulations

For numbers greater than one hundred you should leave out the "and" when counting the number of letters. For instance 577 is "fivehundredseventyseven" which has 23 letters.

Your program must accept all integers greater than 0 and less than 1,000 as input via standard methods.

Your program must output the number of steps required to standard output methods.

This is codegolf so the solution with the fewest bytes wins.

Test cases

```<code>1 -> 3
4 -> 0
7 -> 2
23 -> 5
577 -> 6
600 -> 4
</code>```

Body:
Mathematica, 89 bytes

Length@FixedPointList[StringLength@StringReplace[IntegerName@#,{" "->"","-"->""}]&,#]-2&

Typical Mathematica: built-in functions good, long function names bad. FixedPointList applies its first argument (a function) to the second argument repeatedly until the answer doesn't change, listing all results; the results include the original input and two copies of the repeated output, hence the -2 at the end. Mathematica's built-in IntegerName contains spaces and hyphens, so we need to get rid of those by hand.

Annoyingly, IntegerName's output contains the character "‐" (Unicode #8208) rather than normal hyphens; that's why this submission is 89 bytes rather than 88. (And I couldn't precede the code above with four spaces and have it accept the Unicode character—any help?—so the above code won't work exactly right if cut and pasted.)


问:
Decipher Neurotic Frogs

Decipher Neurotic Frogs

Now that Puzzling.SE has finally cracked my amphibian-obsessed cipher, let's write a program or function to decrypt it!

(If you want to look at the puzzle before having it spoiled for you, click the above link now.)

How the cipher works

In Neurotic Frogs Ought To Relax In Mud Baths ("Neurotic Frogs" for short), every letter is encrypted as one or two words:

The length of a non-italicized word represents a letter.

neurotic => 8 letters => H

frogs => 5 letters => E

perpendicular => 13 letters = M

A word that contains italics modifies the following word, adding 10 if the italicized word was odd in length or 20 if the italicized word was even in length. Any or all of the word may be italicized. An italicized word is always followed by a non-italicized word.

*o*ught to => odd, 2 => 12 => L

lo*u*nging calms => even, 5 => 25 => Y

Every word of plaintext corresponds to a sentence of ciphertext, and every sentence of plaintext corresponds to a paragraph of ciphertext.

Input format

Your program or function shall input a message in Neurotic Frogs, formatted in Markdown. The input will consist only of printable ASCII and newlines.

Words are runs of characters that match the regex [A-Za-z0-9'].

Numbers and letters both count toward the length of a word. QB64 represents D.

NOTE: Apostrophes do not count toward the length of a word. Isn't represents D, not E.

Italicized letters are wrapped in a pair of asterisks (*letters*).

One or more consecutive letters may be italicized, up to an entire word (masseus*es*, *all*); multiple non-consecutive letters in a word may also be italicized (g*e*n*e*rates).

Italics never span multiple words, never include punctuation, and never include apostrophes.

Unpaired asterisks and multiple adjacent asterisks will never occur.

Punctuation is any of the following characters: .,?!:;-()".

Words within a sentence are separated by one or more punctuation characters and/or a single space. Examples: *all* welcomed, toad*s*, newts, Ever*y*one--frogs, cap... bliss, they're (I

Sentences end with one or more punctuation characters and are separated by a double space: Th*e* Montgomery A*m*phibian Salon!  Come luxuriate today!

Paragraphs are separated by a single newline. (The last sentence of a paragraph still has one or more punctuation characters at the end.)

Other characters will not appear in input and do not need to be handled.

Your code may, at your discretion, expect input to have a single trailing newline.

Output format

The result of decrypting the input will be one or more sentences. Letters of plaintext may be any combination of upper- and lowercase. Words within a sentence must be separated by single spaces. Sentences must end with a period (.) and be separated by a single space. You may output a trailing space after the last sentence. Your output will all be on one line, but you may output a trailing newline.

Miscellaneous details

Your code may use any of the standard input and output methods. It must receive input as a multiline string, not a list or other data structure, and it must output a string.

The shortest code in bytes wins!

Test cases

```<code>-->
Neurotic Frogs *O*ught To Rel*a*x In *M*ud Baths!
<--
HELLO.

-->
Business standards all*o*w only *adult* amphibians.
<--
HINT.

-->
Rejoice, *a*ll frogs an*d* toads also!  Montgomery Sal*o*n opens up!  Ha*pp*y throng fill*s* street ecstatically!
<--
GOOD JOB PPL.

-->
I like 3.1415926535897.
IM*O*, it's a *b*la*st*, yeah!
<--
ADAM. MAN.

-->
*I*, happily, *th*anks 2 u *e*ditin*g* specific wor*ding*--clarifying a *bit*--betterment :D!
<--
QUARTATA.

-->
Perpendicular l*ou*nging calms.  *A* frog, a m*u*d cap... bliss!  Wallowing g*e*n*e*rates happiness.  Amphibian sp*a* isn't expensive--seventy d*o*llars--cheap!  That'*s* not *a* large e*x*pens*e* from an*y* discerning fr*o*g's money, unlik*e* Super 8.
Ever*y*one--frogs, toad*s*, newts, *a*nd salamanders!  G*e*t a wonderful shiat*s*u, or recei*v*e an other kind.  Masseus*es* are her*e* today!  Invite a fianc*e*e, supervisor, roommate, niece: *all* welcomed!
Y*o*u simply ne*v*er believed these p*o*ssibilitie*s*; they're (I *swear*) absolute truth!  Th*e* Montgomery A*m*phibian Salon!  Come luxuriate today!
<--
MY NAME IS INIGO MONTOYA. YOU KILLED MY FATHER. PREPARE TO DIE.
</code>```

答:
Perl, 72 bytes

#!perl -n
$x=/\*/?2-y/'//c%2:!print/ /?$':chr$x.0+y/'//c+64for/[\w*']+|  /g,' . '
```

<p>Counting the shebang as one, input is taken from stdin.</p>

<p><strong>Sample Usage</strong></p>

<pre class="lang-perl prettyprint-override"><code>$ more in.dat
Neurotic Frogs *O*ught To Rel*a*x In *M*ud Baths!
Perpendicular l*ou*nging calms.  *A* frog, a m*u*d cap... bliss!  Wallowing g*e*n*e*rates happiness.  Amphibian sp*a* isn't expensive--seventy d*o*llars--cheap!  That'*s* not *a* large e*x*pens*e* from an*y* discerning fr*o*g's money, unlik*e* Super 8.
Ever*y*one--frogs, toad*s*, newts, *a*nd salamanders!  G*e*t a wonderful shiat*s*u, or recei*v*e an other kind.  Masseus*es* are her*e* today!  Invite a fianc*e*e, supervisor, roommate, niece: *all* welcomed!
Y*o*u simply ne*v*er believed these p*o*ssibilitie*s*; they're (I *swear*) absolute truth!  Th*e* Montgomery A*m*phibian Salon!  Come luxuriate today!

$ perl neurotic-frogs.pl < in.dat
HELLO. MY NAME IS INIGO MONTOYA. YOU KILLED MY FATHER. PREPARE TO DIE.
</code>```

ContentLicense: CC BY-SA 3.0

Title: Decipher Neurotic Frogs

Body:
Perl, 72 bytes

#!perl -n
$x=/\*/?2-y/'//c%2:!print/ /?$':chr$x.0+y/'//c+64for/[\w*']+|  /g,' . '

Counting the shebang as one, input is taken from stdin.

Sample Usage

$ more in.dat
Neurotic Frogs *O*ught To Rel*a*x In *M*ud Baths!
Perpendicular l*ou*nging calms.  *A* frog, a m*u*d cap... bliss!  Wallowing g*e*n*e*rates happiness.  Amphibian sp*a* isn't expensive--seventy d*o*llars--cheap!  That'*s* not *a* large e*x*pens*e* from an*y* discerning fr*o*g's money, unlik*e* Super 8.
Ever*y*one--frogs, toad*s*, newts, *a*nd salamanders!  G*e*t a wonderful shiat*s*u, or recei*v*e an other kind.  Masseus*es* are her*e* today!  Invite a fianc*e*e, supervisor, roommate, niece: *all* welcomed!
Y*o*u simply ne*v*er believed these p*o*ssibilitie*s*; they're (I *swear*) absolute truth!  Th*e* Montgomery A*m*phibian Salon!  Come luxuriate today!

$ perl neurotic-frogs.pl < in.dat
HELLO. MY NAME IS INIGO MONTOYA. YOU KILLED MY FATHER. PREPARE TO DIE.


问:
C: replace AES FIPS-197 SubBytes table by constant-time code
In FIPS-197 (the Advanced Encryption Standard, known as AES), it is made heavy use of SubBytes, which could be implemented as

```<code>unsigned char SubBytes(unsigned char x) {
static const unsigned char t[256] = {
  0x63,0x7C,0x77,0x7B,0xF2,0x6B,0x6F,0xC5,0x30,0x01,0x67,0x2B,0xFE,0xD7,0xAB,0x76,
  0xCA,0x82,0xC9,0x7D,0xFA,0x59,0x47,0xF0,0xAD,0xD4,0xA2,0xAF,0x9C,0xA4,0x72,0xC0,
  0xB7,0xFD,0x93,0x26,0x36,0x3F,0xF7,0xCC,0x34,0xA5,0xE5,0xF1,0x71,0xD8,0x31,0x15,
  0x04,0xC7,0x23,0xC3,0x18,0x96,0x05,0x9A,0x07,0x12,0x80,0xE2,0xEB,0x27,0xB2,0x75,
  0x09,0x83,0x2C,0x1A,0x1B,0x6E,0x5A,0xA0,0x52,0x3B,0xD6,0xB3,0x29,0xE3,0x2F,0x84,
  0x53,0xD1,0x00,0xED,0x20,0xFC,0xB1,0x5B,0x6A,0xCB,0xBE,0x39,0x4A,0x4C,0x58,0xCF,
  0xD0,0xEF,0xAA,0xFB,0x43,0x4D,0x33,0x85,0x45,0xF9,0x02,0x7F,0x50,0x3C,0x9F,0xA8,
  0x51,0xA3,0x40,0x8F,0x92,0x9D,0x38,0xF5,0xBC,0xB6,0xDA,0x21,0x10,0xFF,0xF3,0xD2,
  0xCD,0x0C,0x13,0xEC,0x5F,0x97,0x44,0x17,0xC4,0xA7,0x7E,0x3D,0x64,0x5D,0x19,0x73,
  0x60,0x81,0x4F,0xDC,0x22,0x2A,0x90,0x88,0x46,0xEE,0xB8,0x14,0xDE,0x5E,0x0B,0xDB,
  0xE0,0x32,0x3A,0x0A,0x49,0x06,0x24,0x5C,0xC2,0xD3,0xAC,0x62,0x91,0x95,0xE4,0x79,
  0xE7,0xC8,0x37,0x6D,0x8D,0xD5,0x4E,0xA9,0x6C,0x56,0xF4,0xEA,0x65,0x7A,0xAE,0x08,
  0xBA,0x78,0x25,0x2E,0x1C,0xA6,0xB4,0xC6,0xE8,0xDD,0x74,0x1F,0x4B,0xBD,0x8B,0x8A,
  0x70,0x3E,0xB5,0x66,0x48,0x03,0xF6,0x0E,0x61,0x35,0x57,0xB9,0x86,0xC1,0x1D,0x9E,
  0xE1,0xF8,0x98,0x11,0x69,0xD9,0x8E,0x94,0x9B,0x1E,0x87,0xE9,0xCE,0x55,0x28,0xDF,
  0x8C,0xA1,0x89,0x0D,0xBF,0xE6,0x42,0x68,0x41,0x99,0x2D,0x0F,0xB0,0x54,0xBB,0x16};
return t[x];}
</code>```

This function is not arbitrary; it is a reversible mapping, consisting of an inversion in a Galois Field followed by an affine transformation. All the details are in FIPS-197 section 5.1.1 or here section 4.2.1 (under a slightly different name).

One problem with implementation as a table is that it opens to so-called cache-timing attacks.

Thus your mission is to devise an exact replacement for the above SubBytes() function, that exhibits constant-time behavior; we'll assume that's the case when nothing depending on the input x of SubBytes is used  either:

as an array index,

as the control operand of if, while, for, case, or operator ?:;

as any operand of operators &&, ||, !, ==, !=, <, >, <=, >=, *, /, %;

as the right operand of operators >>, <<, *=, /=, %=, <<=, >>=.

The winning entry will be one with the lowest cost, obtained from the number of operators executed in the input-dependent data path, with a weight of 5 for unary operators - and ~ as well as for <<1, >>1, +1, -1; weight of 7 for all other operators, shifts with other counts, or adds/subs of other constants (type casts and promotions are free). By principle, that cost is unchanged by unrolling loops (if any), and independent of the input x. As a tie-breaker, the answer with the shortest code after removing whitespace and comments wins.

I plan to designate an entry as answer as early as I can in year 2013, UTC. I will consider answers in languages that I've some knowledge of, ranking them as a straight translation to C not optimized for size.

Apologies for the initial omission of +1 and -1 in the favored operators, of free casts and promotions, and ranking of size. Note that * is prohibited both when unary, and as multiplication.

Body:
Score: 980=7*5+115*7+7*5+15*7, Boyar and Peralta's minimization

I found A new combinational logic minimization technique with applications to cryptology by Joan Boyar and René Peralta, which (save for the C formalism) does what's required. The technique used to derive their equations is patented by no less than the USA. I just did a straight C translation of their equations, kindly linked here.

unsigned char SubBytes_Boyar_Peralta(unsigned char x7){
  unsigned char
  x6=x7>>1,x5=x6>>1,x4=x5>>1,x3=x4>>1,x2=x3>>1,x1=x2>>1,x0=x1>>1,
  y14=x3^x5,y13=x0^x6,y9=x0^x3,y8=x0^x5,t0=x1^x2,y1=t0^x7,y4=y1^x3,y12=y13^y14,y2=y1^x0,
  y5=y1^x6,y3=y5^y8,t1=x4^y12,y15=t1^x5,y20=t1^x1,y6=y15^x7,y10=y15^t0,y11=y20^y9,y7=x7^y11,
  y17=y10^y11,y19=y10^y8,y16=t0^y11,y21=y13^y16,y18=x0^y16,t2=y12&y15,t3=y3&y6,t4=t3^t2,
  t5=y4&x7,t6=t5^t2,t7=y13&y16,t8=y5&y1,t9=t8^t7,t10=y2&y7,t11=t10^t7,t12=y9&y11,
  t13=y14&y17,t14=t13^t12,t15=y8&y10,t16=t15^t12,t17=t4^t14,t18=t6^t16,t19=t9^t14,
  t20=t11^t16,t21=t17^y20,t22=t18^y19,t23=t19^y21,t24=t20^y18,t25=t21^t22,t26=t21&t23,
  t27=t24^t26,t28=t25&t27,t29=t28^t22,t30=t23^t24,t31=t22^t26,t32=t31&t30,t33=t32^t24,
  t34=t23^t33,t35=t27^t33,t36=t24&t35,t37=t36^t34,t38=t27^t36,t39=t29&t38,t40=t25^t39,
  t41=t40^t37,t42=t29^t33,t43=t29^t40,t44=t33^t37,t45=t42^t41,z0=t44&y15,z1=t37&y6,
  z2=t33&x7,z3=t43&y16,z4=t40&y1,z5=t29&y7,z6=t42&y11,z7=t45&y17,z8=t41&y10,z9=t44&y12,
  z10=t37&y3,z11=t33&y4,z12=t43&y13,z13=t40&y5,z14=t29&y2,z15=t42&y9,z16=t45&y14,z17=t41&y8,
  t46=z15^z16,t47=z10^z11,t48=z5^z13,t49=z9^z10,t50=z2^z12,t51=z2^z5,t52=z7^z8,t53=z0^z3,
  t54=z6^z7,t55=z16^z17,t56=z12^t48,t57=t50^t53,t58=z4^t46,t59=z3^t54,t60=t46^t57,
  t61=z14^t57,t62=t52^t58,t63=t49^t58,t64=z4^t59,t65=t61^t62,t66=z1^t63,s0=t59^t63,
  s6=t56^t62,s7=t48^t60,t67=t64^t65,s3=t53^t66,s4=t51^t66,s5=t47^t65,s1=t64^s3,s2=t55^t67;
  return (((((((s0<<1|s1&1)<<1|s2&1)<<1|s3&1)<<1|s4&1)<<1|s5&1)<<1|s6&1)<<1|s7&1)^0x63;}


问:
Esolang-Comment-Template-Generator
Lots of people on this site use esoteric languages, and since these languages are unusual and hard to understand, they will frequently write an explanation in a certain format. For example, if the code was

```<code>abcdefghijklmnop
</code>```

And this languages uses # for comments, they would write an explanation like this:

```<code>a                #Explanation of what 'a' does
 bc              #Bc
   d             #d
    e            #Explanation of e
     fgh         #foobar
        ij       #hello world
          k      #etc.
           l     #so on
            mn   #and
              op #so forth
</code>```

I frequently do this too, but every time I do this, I feel like creating the layout of text is really obnoxious and time-consuming. So I want you to create a "Esolang-Comment-Template-Generator" for me. For example, if we ignore the comments, the previous code has this template:

```<code>a                #
 bc              #
   d             #
    e            #
     fgh         #
        ij       #
          k      #
           l     #
            mn   #
              op #
</code>```

The Challenge:

You must write a program or function that takes two strings as input, and outputs this "Esolang-Comment-Template". The first input will be the code, but with bars (|) inserted where the newlines go. The second input is what we will use for comments. So our last example would have this for input:

```<code>"a|bc|d|e|fgh|ij|k|l|mn|op", "#"
</code>```

Unfortunately this excludes bars from being part of the code input, but that's OK. You can assume that the comment input will be a single character. For simplicity's sake, the comment char will not be a bar. The code input will only contain printable ASCII, and it will not contain any newlines.

Hopefully you can infer what to do from the testcases, but I'll try to clarify some things.

You must split the code input up into "code-sections" on every bar. Then, each section of code is output on its own line and left-padded with the length of all the previous code (not including the bars). Then, each line is right-padded with enough spaces so that the last two characters on every line are "One additional space" + "The comment character".

One trailing newline is allowed.

Here is another example. For the input

```<code>"Hello|World", "/"
</code>```

The first section of code is "Hello" and the second is "World". So it should give the output:

```<code>Hello      /
     World /
</code>```

Here are some more samples:

```<code>Input:
"a|b|c|d|e|f|g", ","

Output:
a       ,
 b      ,
  c     ,
   d    ,
    e   ,
     f  ,
      g ,

Input:
"abcdefg", ":"

Output:
abcdefg :

Input:
"4|8|15|16|23|42", "%"

Output:
4          %
 8         %
  15       %
    16     %
      23   %
        42 %

Input:
"E|ac|h s|ecti|on is| one c|haracte|r longer| than the| last!", "!"

Output:
E                                                   !
 ac                                                 !
   h s                                              !
      ecti                                          !
          on is                                     !
                one c                               !
                     haracte                        !
                            r longer                !
                                     than the       !
                                              last! !

Input:
"This|Code|has||empty||sections", "@"

Output:
This                     @
    Code                 @
        has              @
                         @
           empty         @
                         @
                sections @
</code>```

Rules:

You may take these inputs and outputs in any reasonable format. For example, reading/writing a file, STDIN/STOUT, function arguments/return value, etc. As usual, this is code-golf, so try to make your code as short as possible and you win if you can get the shortest solution in your language! I will also select the shortest solution as the overall winner. Standard loopholes are banned.

答:
Jelly, 41 bytes

This looks like it has far to many increments, and probably too many links...

```<code>ṫø⁹‘‘µFL‘⁶ẋ
‘ị
ḣFL⁶ẋ$;ç@;1ŀ
J’ç@€
ṣ”|Ç;€Y
</code>```

Test it at TryItOnline

How?

```<code>ṫø⁹‘‘µFL‘⁶ẋ  - link 1: get the spaces for after the code, dyadic(split string, index)
 ø           - next chain as a nilad
  ⁹‘‘        - right argument incremented twice (the index we actually want)
ṫ            - tail (get the rest of the split string)
     µ       - next chain as a monad
      FL‘    - flatten, get its length and increment
         ⁶   - a space character " "
          ẋ  - repeat the space character that many times

‘ị           - Link 2: get the code for a line dyadic(index, split string)
‘            - increment the index
 ị           - retrieve the string at that index

ḣFL⁶ẋ$;ç@;1ŀ - Link 3: get the code and join with spaces, dyadic (index, split string)
ḣ            - head: split string[index:]
 FL          - flatten and get its length
     $       - previous two atoms as a monad
   ⁶         - a space character, " "
    ẋ        - repeat the space that many times
      ;      - concatenate with
       ç@    - the result of the previous link (the code) - reverse inputs
         ;   - concatenate with
          1ŀ - the result of Link 1 (the spaces after the code)

J’ç@€        - Link 3: a for loop, monadic(split string)
J’           - [0,...,Len(split string)-1]
  ç@€        - the result of the previous link, with revered inputs, for each

ṣ”|Ç;€Y      - Main Link: dyadic(code string, comment character)
ṣ”|          - split on "|"
   Ç         - the result of the previous link
    ;€       - concatenate each with the comment character
      Y      - join with line feeds
             - implicit print
</code>```

ContentLicense: CC BY-SA 4.0

Title: Esolang-Comment-Template-Generator

Body:
Jelly, 41 bytes

This looks like it has far to many increments, and probably too many links...

ṫø⁹‘‘µFL‘⁶ẋ
‘ị
ḣFL⁶ẋ$;ç@;1ŀ
J’ç@€
ṣ”|Ç;€Y

Test it at TryItOnline

How?

ṫø⁹‘‘µFL‘⁶ẋ  - link 1: get the spaces for after the code, dyadic(split string, index)
 ø           - next chain as a nilad
  ⁹‘‘        - right argument incremented twice (the index we actually want)
ṫ            - tail (get the rest of the split string)
     µ       - next chain as a monad
      FL‘    - flatten, get its length and increment
         ⁶   - a space character " "
          ẋ  - repeat the space character that many times

‘ị           - Link 2: get the code for a line dyadic(index, split string)
‘            - increment the index
 ị           - retrieve the string at that index

ḣFL⁶ẋ$;ç@;1ŀ - Link 3: get the code and join with spaces, dyadic (index, split string)
ḣ            - head: split string[index:]
 FL          - flatten and get its length
     $       - previous two atoms as a monad
   ⁶         - a space character, " "
    ẋ        - repeat the space that many times
      ;      - concatenate with
       ç@    - the result of the previous link (the code) - reverse inputs
         ;   - concatenate with
          1ŀ - the result of Link 1 (the spaces after the code)

J’ç@€        - Link 3: a for loop, monadic(split string)
J’           - [0,...,Len(split string)-1]
  ç@€        - the result of the previous link, with revered inputs, for each

ṣ”|Ç;€Y      - Main Link: dyadic(code string, comment character)
ṣ”|          - split on "|"
   Ç         - the result of the previous link
    ;€       - concatenate each with the comment character
      Y      - join with line feeds
             - implicit print


问:
Converting integers to English words
The goal of this code golf is to convert integers to English words.

The program prompts for input. If this input isn't an integer, print NaN. If it is an integer, convert it to English words and print these words. Minimum input: 0 (zero). Maximum input: 9000 (nine thousand).

So, 5 returns five (case doesn't matter), and 500 returns five hundred or five-hundred (dashes don't matter).

Some other rules:

A one before hundred or thousand is optional: one hundred is correct, but hundred too (if the input is 100 of course).

The word and in for example one hundred and forty five is optional too.

Whitespace matters. So, for 500, five-hundred or five hundred is correct, but fivehundred is not.

Good luck!

答:
PHP, <s>327</s> <s>310</s> 308 bytes

```<code><?$a=['',one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thir,0,fif,0,0,eigh];echo($n=$argv[1])>999?$a[$n/1000].' thousand ':'',$n%1000>99?$a[$n/100%10].' hundred ':'',$n?($k=$n%100)<20?($a[$k]?:$a[$k%10]).[teen][$k<13]:[2=>twen,thir,'for',fif,six,seven,eigh,nine][$k/10].'ty '.$a[$k%10]:zero;
</code>```

takes the number as parameter, works for 0<=n<=12999

breakdown

```<code>// define names
$a=['',one,two,three,four,five,six,seven,eight,nine,
    ten,eleven,twelve,thir,0,fif,0,0,eigh];
// print ...
echo
    ($n=$argv[1])>999?$a[$n/1000].' thousand ':'',                  // thousands
    $n%1000>99?$a[$n/100%10].' hundred ':'',                        // hundreds
    $n?
        // if remains <20:
        ($k=$n%100)<20?
            ($a[$k]?:$a[$k%10]) // no value at index (0,14,16,17,19)? value from index%10
            .[teen][$k<13]      // append "teen" for $k>12
        // else:
        :[2=>twen,thir,'for',fif,six,seven,eigh,nine][$k/10].'ty '  // tens
        .$a[$k%10]                                                  // ones
    // "zero" for $n==0
    :zero
;
</code>```

Title: Converting integers to English words

Body:
PHP, <s>327</s> <s>310</s> 308 bytes

<?$a=['',one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thir,0,fif,0,0,eigh];echo($n=$argv[1])>999?$a[$n/1000].' thousand ':'',$n%1000>99?$a[$n/100%10].' hundred ':'',$n?($k=$n%100)<20?($a[$k]?:$a[$k%10]).[teen][$k<13]:[2=>twen,thir,'for',fif,six,seven,eigh,nine][$k/10].'ty '.$a[$k%10]:zero;

takes the number as parameter, works for 0<=n<=12999

breakdown

// define names
$a=['',one,two,three,four,five,six,seven,eight,nine,
    ten,eleven,twelve,thir,0,fif,0,0,eigh];
// print ...
echo
    ($n=$argv[1])>999?$a[$n/1000].' thousand ':'',                  // thousands
    $n%1000>99?$a[$n/100%10].' hundred ':'',                        // hundreds
    $n?
        // if remains <20:
        ($k=$n%100)<20?
            ($a[$k]?:$a[$k%10]) // no value at index (0,14,16,17,19)? value from index%10
            .[teen][$k<13]      // append "teen" for $k>12
        // else:
        :[2=>twen,thir,'for',fif,six,seven,eigh,nine][$k/10].'ty '  // tens
        .$a[$k%10]                                                  // ones
    // "zero" for $n==0
    :zero
;


问:
Sort band names

Challenge description

You have a music library with many tracks recorded by many bands, each of which has a name, like Queen, Aerosmith, Sunny Day Real Estate, The Strokes . When an audio player displays your library alphabetically by band name, it usually skips the The part, as many band names start with The, making it easier to navigate through your media collection. In this challenge, given a list (array) of strings, you need to sort it that way (that is, omitting the The word at the beginning of the name). You can either write a method or a full working program.

Sample inputs / outputs

```<code>[Queen, Aerosmith, Sunny Day Real Estate, The Strokes] -> [Aerosmith, Queen, The Strokes, Sunny Day Real Estate]
[The Ramones, The Cure, The Pixies, The Roots, The Animals, Enrique Iglesias] -> [The Animals, The Cure, Enrique Iglesias, The Pixies, The Ramones, The Roots]
[The The, The They, Thermodynamics] -> [The The, Thermodynamics, The They]
</code>```

Notes / Edge cases

Sorting lexicographically is case insensitive, so The Police, The police and the police are all equivalent,

Your algorithm should only omit the first the word, so bands named The The or The The Band are sorted normally by the second the,

A band named The (a three letter word) is sorted normally (no skipping),

Order of two bands having the same name, one of which starts with the (like The Police and Police) is undefined,

You can assume that if a band's name consists of more than one word, they are separated by a single space character. You don't need to handle leading or trailing whitespaces,

All input strings match [A-Za-z0-9 ]*, that is they will consist only of lower- and uppercase letters of English alphabet, digits and space characters,

Remember that this is a code-golf challenge, so make your code as short as possible!

答:
Bash + coreutils, 44 bytes

sed '/^the /I!s,^,@ ,'|sort -dk2|sed s,@\ ,,
```

<p><strong>Explanation:</strong> the input and output format is one band per line</p>

<pre class="lang-sh prettyprint-override"><code>sed '/^the /I!s,^,@ ,'   # prepend '@ ' to each line not starting with 'the ', case
                         #insensitive. This adds a temporary field needed by sort.
sort -dk2                # sort in ascending dictionary order by 2nd field onward
sed s,@\ ,,              # remove the temporary field
</code>```

Test run (using a here-document with EOF as the end marker):

./sort_bands.sh << EOF
> Queen
> Aerosmith
> Sunny Day Real Estate
> The Strokes
> EOF
```

<p><strong>Output:</strong></p>

<pre class="lang-sh prettyprint-override"><code>Aerosmith
Queen
The Strokes
Sunny Day Real Estate
</code>```

Title: Sort band names

Body:
Bash + coreutils, 44 bytes

sed '/^the /I!s,^,@ ,'|sort -dk2|sed s,@\ ,,

Explanation: the input and output format is one band per line

sed '/^the /I!s,^,@ ,'   # prepend '@ ' to each line not starting with 'the ', case
                         #insensitive. This adds a temporary field needed by sort.
sort -dk2                # sort in ascending dictionary order by 2nd field onward
sed s,@\ ,,              # remove the temporary field

Test run (using a here-document with EOF as the end marker):

./sort_bands.sh << EOF
> Queen
> Aerosmith
> Sunny Day Real Estate
> The Strokes
> EOF

Output:

Aerosmith
Queen
The Strokes
Sunny Day Real Estate


问:
Evaluate the primorial of a number
The primorial of a number is the product of all the primes until that number, itself included.

Take a number from STDIN as the input and evaluate its primorial, also known as the prime factorial.

Don't use libraries. Shortest code wins.

Test cases:

```<code>1 1
2 2
3 6
4 6
5 30
6 30
7 210
8 210
9 210
10 210
11 2310
12 2310
13 30030
14 30030
15 30030
16 30030
17 510510
18 510510
19 9699690
</code>```

答:
Python 2, 49 bytes

P=k=1
exec"P*=P**k%k<1or k;k+=1;"*input()
print P
```

Counts up k from 1 to the input, updating the primorial P by multiplying P by k whenever it's prime. Since P contains all lower prime factors, a sufficiently high power of P will contain k as a factor if and only if k is non-prime. The power P**k suffices, and we check whether P**k%k<1, multipling P by 1 if so (doing nothing) and by k otherwise.

Title: Evaluate the primorial of a number

Body:
Python 2, 49 bytes

P=k=1
exec"P*=P**k%k<1or k;k+=1;"*input()
print P

Counts up k from 1 to the input, updating the primorial P by multiplying P by k whenever it's prime. Since P contains all lower prime factors, a sufficiently high power of P will contain k as a factor if and only if k is non-prime. The power P**k suffices, and we check whether P**k%k<1, multipling P by 1 if so (doing nothing) and by k otherwise.


问:
Produce the word 'codegolf' without using any of its characters in code
You need to produce the word codegolf

Rules:

None of the characters of the word codegolf (i.e. 'c', 'o', 'd', 'e', 'g', 'o', 'l' and 'f') in either case can exist anywhere in the code.

Case of the word must be one of three:

All Upcase (CODEGOLF)

All Downcase (codegolf)

Capitalized (Codegolf)

You only need to produce it somehow so there can be other characters in the output as well. For example, 21§HCodegolf092 is an acceptable result.

The shortest code (counting in bytes) to do so in any language wins.

I guess it will be less trickier in some languages than others (Brainfuck, Javascript, etc.)

答:
Jelly, 7 bytes

```<code>“£ṙɲI⁵»
</code>```

Try it online!

Body:
Jelly, 7 bytes

“£ṙɲI⁵»

Try it online!


问:
Change the Timezone

Challenge

Given a time and a timezone as input, output the time in that timezone.

Time

The time will be given in 24 hour format like so:

```<code>hh:mm
</code>```

Where hh is the two digit hour and mm is the two digit minute. Note that the hour and the minute will always be padded with zeroes like so:

```<code>06:09
</code>```

All the times given are at UTC+00:00.

The hours in your output do not have to be padded wih zeroes but your time it must be in 24 hour format

Timezone

The timezone will be given in the following format:

```<code>UTC±hh:mm
</code>```

Where ± is either going to be a + or a - and hh, is the two digit hour and mm is the two digit minute (again, these will be padded with zeroes).

To find the time in that timezone, you either add (if the symbol is +) or subtract (if the symbol is -) the time after the UTC± from the inputted time.

For example, if the input was 24:56 and UTC-02:50, you would subtract 2 hours and 50 minutes from 24:56:

```<code>24:56
02:50 -
-----
22:06
</code>```

The output would be 22:06.

Examples

Chicago

```<code>Input:  08:50 and UTC-06:00
Output: 02:50
</code>```

Kathmandu

```<code>Input:  09:42 and UTC+05:45
Output: 15:27
</code>```

Samoa

```<code>Input:  06:42 and UTC+13:00
Output: 19:42
</code>```

Hawaii

```<code>Input:  02:40 and UTC-10:00
Output: 16:40
</code>```

Note that this has gone to the previous day.

Tokyo

```<code>Input:  17:25 and UTC+09:00
Output: 02:25
</code>```

Note that this has gone to the following day.

Rules

You must not use any built in date functions or libraries.

Assume all input will be valid times and time offsets.

The timezone will be in the range UTC-24:00 to UTC+24:00 inclusive.

In the case of half past midnight, the correct representation should be 00:30, not 24:30.

Winning

The shortest code in bytes wins.

Title: Change the Timezone

Body:
C, 109 bytes

a,b,c;f(char*t,char*z){for(c=0;z[3];t=z+=3)sscanf(t,"%d:%d",&a,&b),c+=b+a*60;printf("%d:%02d",c/60%24,c%60);}

Invoke as follows:

int main() { f("17:25", "UTC+09:00"); }


Title: Change the Timezone

Body:
Challenge

Given a time and a timezone as input, output the time in that timezone.

Time

The time will be given in 24 hour format like so:

```<code>hh:mm
</code>```

Where hh is the two digit hour and mm is the two digit minute. Note that the hour and the minute will always be padded with zeroes like so:

```<code>06:09
</code>```

All the times given are at UTC+00:00.

The hours in your output do not have to be padded wih zeroes but your time it must be in 24 hour format

Timezone

The timezone will be given in the following format:

```<code>UTC±hh:mm
</code>```

Where ± is either going to be a + or a - and hh, is the two digit hour and mm is the two digit minute (again, these will be padded with zeroes).

To find the time in that timezone, you either add (if the symbol is +) or subtract (if the symbol is -) the time after the UTC± from the inputted time.

For example, if the input was 24:56 and UTC-02:50, you would subtract 2 hours and 50 minutes from 24:56:

```<code>24:56
02:50 -
-----
22:06
</code>```

The output would be 22:06.

Examples

Chicago

```<code>Input:  08:50 and UTC-06:00
Output: 02:50
</code>```

Kathmandu

```<code>Input:  09:42 and UTC+05:45
Output: 15:27
</code>```

Samoa

```<code>Input:  06:42 and UTC+13:00
Output: 19:42
</code>```

Hawaii

```<code>Input:  02:40 and UTC-10:00
Output: 16:40
</code>```

Note that this has gone to the previous day.

Tokyo

```<code>Input:  17:25 and UTC+09:00
Output: 02:25
</code>```

Note that this has gone to the following day.

Rules

You must not use any built in date functions or libraries.

Assume all input will be valid times and time offsets.

The timezone will be in the range UTC-24:00 to UTC+24:00 inclusive.

In the case of half past midnight, the correct representation should be 00:30, not 24:30.

Winning

The shortest code in bytes wins.

Body:
JavaScript (ES6), 101 bytes

(t,z,g=s=>+(s[3]+s[7]+s[8])+s.slice(3,6)*60,m=g('UTC+'+t)+g(z)+1440)=>(m/60%24|0)+':'+(m/10%6|0)+m%10

Would be 121 bytes if I padded the hours.


Title: Change the Timezone

Body:
Python 2, 129 bytes

def T(t,a):f=[int.__add__,int.__sub__]["-"in a];m=f(int(t[3:5]),int(a[7:9]));print`f(int(t[0:2])+m/60,int(a[4:6]))%24`+":"+`m%60`

Call as T("02:45", "UTC-05:33")


答:
Python 2, <s>238</s> <s>221</s> <s>218</s> <s>214</s> <s>207</s> 205 bytes

from re import*
def f(x):
 d='';m=0
 for w in split(r"[^\w\d*'~\n]+",sub('  ','~',x))[:-1]:l=len(sub("[*'~\n]",'',w));q='*'in w;d+='. '[w[0]>'}':]*(w[0]in'~\n')+chr(64+l+m)[q:];m=(2-l%2)*10*q
 print d+'.'
```

Uses lots of regex to do the processing. We transform the double-space into ~ and use that to process it. ~ and \n are handled specially.

The biggest character gain comes from the preprocessing of the input in the for line; this can definitely be golfed further.

Ideone it! (all test cases)

Saved 7 bytes thanks to DLosc!

Title: Decipher Neurotic Frogs

Body:
Decipher Neurotic Frogs

Now that Puzzling.SE has finally cracked my amphibian-obsessed cipher, let's write a program or function to decrypt it!

(If you want to look at the puzzle before having it spoiled for you, click the above link now.)

How the cipher works

In Neurotic Frogs Ought To Relax In Mud Baths ("Neurotic Frogs" for short), every letter is encrypted as one or two words:

The length of a non-italicized word represents a letter.

neurotic => 8 letters => H

frogs => 5 letters => E

perpendicular => 13 letters = M

A word that contains italics modifies the following word, adding 10 if the italicized word was odd in length or 20 if the italicized word was even in length. Any or all of the word may be italicized. An italicized word is always followed by a non-italicized word.

*o*ught to => odd, 2 => 12 => L

lo*u*nging calms => even, 5 => 25 => Y

Every word of plaintext corresponds to a sentence of ciphertext, and every sentence of plaintext corresponds to a paragraph of ciphertext.

Input format

Your program or function shall input a message in Neurotic Frogs, formatted in Markdown. The input will consist only of printable ASCII and newlines.

Words are runs of characters that match the regex [A-Za-z0-9'].

Numbers and letters both count toward the length of a word. QB64 represents D.

NOTE: Apostrophes do not count toward the length of a word. Isn't represents D, not E.

Italicized letters are wrapped in a pair of asterisks (*letters*).

One or more consecutive letters may be italicized, up to an entire word (masseus*es*, *all*); multiple non-consecutive letters in a word may also be italicized (g*e*n*e*rates).

Italics never span multiple words, never include punctuation, and never include apostrophes.

Unpaired asterisks and multiple adjacent asterisks will never occur.

Punctuation is any of the following characters: .,?!:;-()".

Words within a sentence are separated by one or more punctuation characters and/or a single space. Examples: *all* welcomed, toad*s*, newts, Ever*y*one--frogs, cap... bliss, they're (I

Sentences end with one or more punctuation characters and are separated by a double space: Th*e* Montgomery A*m*phibian Salon!  Come luxuriate today!

Paragraphs are separated by a single newline. (The last sentence of a paragraph still has one or more punctuation characters at the end.)

Other characters will not appear in input and do not need to be handled.

Your code may, at your discretion, expect input to have a single trailing newline.

Output format

The result of decrypting the input will be one or more sentences. Letters of plaintext may be any combination of upper- and lowercase. Words within a sentence must be separated by single spaces. Sentences must end with a period (.) and be separated by a single space. You may output a trailing space after the last sentence. Your output will all be on one line, but you may output a trailing newline.

Miscellaneous details

Your code may use any of the standard input and output methods. It must receive input as a multiline string, not a list or other data structure, and it must output a string.

The shortest code in bytes wins!

Test cases

```<code>-->
Neurotic Frogs *O*ught To Rel*a*x In *M*ud Baths!
<--
HELLO.

-->
Business standards all*o*w only *adult* amphibians.
<--
HINT.

-->
Rejoice, *a*ll frogs an*d* toads also!  Montgomery Sal*o*n opens up!  Ha*pp*y throng fill*s* street ecstatically!
<--
GOOD JOB PPL.

-->
I like 3.1415926535897.
IM*O*, it's a *b*la*st*, yeah!
<--
ADAM. MAN.

-->
*I*, happily, *th*anks 2 u *e*ditin*g* specific wor*ding*--clarifying a *bit*--betterment :D!
<--
QUARTATA.

-->
Perpendicular l*ou*nging calms.  *A* frog, a m*u*d cap... bliss!  Wallowing g*e*n*e*rates happiness.  Amphibian sp*a* isn't expensive--seventy d*o*llars--cheap!  That'*s* not *a* large e*x*pens*e* from an*y* discerning fr*o*g's money, unlik*e* Super 8.
Ever*y*one--frogs, toad*s*, newts, *a*nd salamanders!  G*e*t a wonderful shiat*s*u, or recei*v*e an other kind.  Masseus*es* are her*e* today!  Invite a fianc*e*e, supervisor, roommate, niece: *all* welcomed!
Y*o*u simply ne*v*er believed these p*o*ssibilitie*s*; they're (I *swear*) absolute truth!  Th*e* Montgomery A*m*phibian Salon!  Come luxuriate today!
<--
MY NAME IS INIGO MONTOYA. YOU KILLED MY FATHER. PREPARE TO DIE.
</code>```

Body:
Python 2, <s>238</s> <s>221</s> <s>218</s> <s>214</s> <s>207</s> 205 bytes

from re import*
def f(x):
 d='';m=0
 for w in split(r"[^\w\d*'~\n]+",sub('  ','~',x))[:-1]:l=len(sub("[*'~\n]",'',w));q='*'in w;d+='. '[w[0]>'}':]*(w[0]in'~\n')+chr(64+l+m)[q:];m=(2-l%2)*10*q
 print d+'.'

Uses lots of regex to do the processing. We transform the double-space into ~ and use that to process it. ~ and \n are handled specially.

The biggest character gain comes from the preprocessing of the input in the for line; this can definitely be golfed further.

Ideone it! (all test cases)

Saved 7 bytes thanks to DLosc!


问:
Goldenness of an integer
A positive integer n can be represented as a rectangle with integer sides a, b such that n = a * b. That is, the area represents the number. In general, a and b are not unique for a given n.

As is well known, a rectangle is specially pleasing to the eye (or is it the brain?) when its sides are in the golden ratio, φ = (sqrt(5)+1)/2 ≈ 1.6180339887...

Combining these two facts, the purpose of this challenge is to decompose an integer n into the product of two integers a, b whose ratio is as close as possible to φ (with the usual metric on ℝ). The fact that φ is irrational implies that there is a unique solution pair (a, b).

The challenge

Given a positive integer n, output positive integers a, b such that  a * b = n and the absolute difference between a/b and φ is minimized.

As an example, consider n = 12. The pairs (a, b) that satisfy a * b = n are: (1, 12), (2,6), (3,4), (4,3), (6,2), (12,1). The pair whose ratio is closest to φ is (4,3), which gives 4/3 = 1.333.

Rules

Functions or programs are acceptable.

The numerator (a) should appear first in the output, and the denominator (b) second. Other than that, input and output formats are flexible as usual. For example, the two numbers can be output as strings with any reasonable separator, or as an array.

The code should work in theory for arbitrarily large numbers. In practice, it may be limited by memory or data-type restrictions.

It's sufficient to consider an approximate version of φ, as long as it is accurate up to the third decimal or better. That is, the absolute difference between the true φ and the approximate value should not exceed 0.0005. For example, 1.618 is acceptable.

When using an approximate, rational version of φ there's a small chance that the solution is not unique. In that case you can output any pair a, b that satisfies the minimization criterion.

Shortest code wins.

Test cases

```<code>1        ->  1    1
2        ->  2    1
4        ->  2    2
12       ->  4    3
42       ->  7    6
576      ->  32   18
1234     ->  2    617
10000    ->  125  80
199999   ->  1    199999
9699690  ->  3990 2431
</code>```

答:
Mathematica, 51 bytes

```<code>#&@@SortBy[{x=Divisors@#,#/x},Abs[#/#2-1.618]&]&
</code>```

The  is Mathematica's postfix operator for transposition (displayed as a superscript T in Mathematica).

Mathematica has a built-in GoldenRatio, but 1.618 is a lot shorter, especially because the former also requires N@.

Title: Goldenness of an integer

Body:
Mathematica, 51 bytes

#&@@SortBy[{x=Divisors@#,#/x},Abs[#/#2-1.618]&]&

The  is Mathematica's postfix operator for transposition (displayed as a superscript T in Mathematica).

Mathematica has a built-in GoldenRatio, but 1.618 is a lot shorter, especially because the former also requires N@.


Title: Change the Timezone

Body:
C# 214 205 183 Bytes

string f(char[]t,char[]u){int s=~(u[3]-45),z=48,m=(t[3]-z)*10+t[4]-z+((u[7]-z)*10+u[8]-z)*s,h=(t[0]-z)*10+t[1]-z+((u[4]-z)*10+u[5]-z)*s+m/60+(m>>8)+24;return$"{h%24}:{(m+60)%60:D2}";}

205 byte version

string f(string t,string u){Func<string,int>P=int.Parse;var T=t.Split(':');int s=u[3]<45?1:-1,m=P(T[1])+P(u.Substring(7))*s,h=P(T[0])+P($"{u[4]}"+u[5])*s+m/60+(m<0?-1:0)+24;return$"{h%24}:{(m+60)%60:D2}";}

Ungolfed

string f(char[] t, char[] u)
{
    int s = ~(u[3]-45),
        z = 48,
        m = (t[3] - z) * 10 + t[4] - z + ((u[7] - z) * 10 + u[8] - z) * s,
        h = (t[0] - z) * 10 + t[1] - z + ((u[4] - z) * 10 + u[5] - z) * s + m / 60 + (m>>8) + 24;
    return $"{h % 24}:{(m + 60) % 60:D2}";
}

Original 214:

string f(string t,string u){Func<string,int>P=int.Parse;var T=t.Split(':');int h=P(T[0]),m=P(T[1]),s=u[3]<45?1:-1;m+=P(u.Substring(7))*s;h+=P($"{u[4]}"+u[5])*s+m/60+(m<0?-1:0)+24;return$"{h%24:D2}:{(m+60)%60:D2}";}


问:
Shortest program that throws StackOverflow Error
Write a program that throws a StackOverflow Error or the equivalent in the language used. For example, in java, the program should throw java.lang.StackOverflowError.

You are not allowed to define a function that calls itself or a new class(except the one containing main in java). It should use the classes of the selected programming language.

And it should not throw the error explicitly.

答:
Neoscript, 22 bytes

```<code>try 1/0;catch e retry;
</code>```

The division by 0 crash and execute the catch block, which call the try..catch block again, the division by 0 crash and excute the catch block again, etc...

Body:
Neoscript, 22 bytes

try 1/0;catch e retry;

The division by 0 crash and execute the catch block, which call the try..catch block again, the division by 0 crash and excute the catch block again, etc...


问:
Can the number reach 1 by repeatedly subtracting the largest prime less than it?

Challenge:

Given a number, take the largest prime strictly less than it, subtract it from this number, do this again to this new number with the biggest prime less than it, and continue doing this until it's less than 3. If it reaches 1, your program should output a truthy value, else, the program should output a falsey value.

Examples:

All of these should give a truthy value:

```<code>3
4
6
8
10
11
12
14
16
17
18
20
22
23
24
26
27
29
30
32
34
35
37
38
40
41
42
44
46
47
48
50
</code>```

All of these should give falsey values:

```<code>5
7
9
13
15
19
21
25
28
31
33
36
39
43
45
49
</code>```

Rules:

You can either write a program or function.

You can assume that the input is bigger than 2.

Standard loopholes apply

This is code-golf so the shortest answer wins!

答:
Vitsy, <s>28</s> 26 bytes

This can definitely be shortened.

```<code><]xN0)l1)-1[)/3D-];(pD-1[D
</code>```

```<code><                    Traverse the code in this direction, rotating on the line.
                     For the sake of reading the code easier, I'm reversing the
                     code on this line. This will be the order executed.

 D[1-Dp(;]-D3/)[1-)1l)0Nx]
 D                         Duplicate the top member of the stack.
  [      ]                 Do the stuff in brackets until break is called.
   1-                      Subtract 1 from the top item of the stack.
     D                     Duplicate the top member of the stack.
      p(                   If the top member is a prime...
        ;                  break;
          -                Pop a, b, push a - b.
           D3/)[         ] If this value is less than 3, do the bracketed code.
                1-         Subtract the top item of the stack by 1.
                  )        If the top item is zero...
                   1       Push 1.
                    l)     If the length of the stack is zero...
                      0    Push 0.
                       N   Output the top member of the stack.
                        x  System.exit(0);
</code>```

Try it online!

Body:
Vitsy, <s>28</s> 26 bytes

This can definitely be shortened.

<]xN0)l1)-1[)/3D-];(pD-1[D

<                    Traverse the code in this direction, rotating on the line.
                     For the sake of reading the code easier, I'm reversing the
                     code on this line. This will be the order executed.

 D[1-Dp(;]-D3/)[1-)1l)0Nx]
 D                         Duplicate the top member of the stack.
  [      ]                 Do the stuff in brackets until break is called.
   1-                      Subtract 1 from the top item of the stack.
     D                     Duplicate the top member of the stack.
      p(                   If the top member is a prime...
        ;                  break;
          -                Pop a, b, push a - b.
           D3/)[         ] If this value is less than 3, do the bracketed code.
                1-         Subtract the top item of the stack by 1.
                  )        If the top item is zero...
                   1       Push 1.
                    l)     If the length of the stack is zero...
                      0    Push 0.
                       N   Output the top member of the stack.
                        x  System.exit(0);

Try it online!


答:
Python 2.7, <s>390</s> <s>342</s> <s>341</s> <s>339</s> 335 bytes:

```<code>from re import*
def F(i):
 W=X="";S,s=split,sub;D='[^\w\s*]';Q=lambda c,t:len(s(D,X,c.group()).split()[t])
 for m in S('\W\n',s(D+"*\w*\*\w+\*.*?(?=\s) \w+",lambda v:"a"*([20,10][Q(v,0)%2]+Q(v,1)),s("'",X,s("--"," ",i)))):
  for g in S('\W  ',m):
   for q in S('\W',g):
    W+=chr(64+len(q))
   W+=" "
  W=W[:-1]+". "
 print s("@",X,W)
</code>```

Takes input in the format:

F('''Multi or Single-lined String''')

Can be golfed down a lot more, which I will do whenever I get the chance.

Repl.it with All Test Cases!

Explanation:

Uses the immense power of Python's regular expression built-ins to decipher the input. This is the fundamental process the function goes through for each input:

Firstly, all -- are replaced with a single space, and every apostrophe is removed. Then, all words containing italicized components and the word proceeding it are both matched in one string and replaced with 10 + len(second word) number of consecutive as if the length of the first word is odd, and 20 + len(second word) consecutive as otherwise. This makes use of the following regular expression:

[^\w\s*]*\w*\*\w+\*.*?(?=\s) \w+

For example, if we have the sentence Perpendicular l*ou*nging calms., l*ou*nging calms will be replaced with aaaaaaaaaaaaaaaaaaaaaaaaa, or 25 as, since l*ou*nging has an even number of characters and calms has 5. 20+5=25.

Now, the newly modified input is split at each punctuation mark followed by a newline (\n) to get the paragraphs, then each paragraph is split at each punctuation followed by 2 spaces to get the sentences, and finally, each sentence is split into words along any punctuation including a space. Then, for each word (including the runs of consecutive as), we add on to a string W the letter corresponding to the unicode code point 64 (the unicode code point of the character before A, which is @) plus len(word). We then add a single space to W once all the words of a sentence have been exhausted, and when all the sentences in a paragraph are exhausted, we add a . followed by a single space.

Finally, after the entire input has been gone through, W is output to stdout as the deciphered message.

Title: Decipher Neurotic Frogs

Body:
Python 2.7, <s>390</s> <s>342</s> <s>341</s> <s>339</s> 335 bytes:

from re import*
def F(i):
 W=X="";S,s=split,sub;D='[^\w\s*]';Q=lambda c,t:len(s(D,X,c.group()).split()[t])
 for m in S('\W\n',s(D+"*\w*\*\w+\*.*?(?=\s) \w+",lambda v:"a"*([20,10][Q(v,0)%2]+Q(v,1)),s("'",X,s("--"," ",i)))):
  for g in S('\W  ',m):
   for q in S('\W',g):
    W+=chr(64+len(q))
   W+=" "
  W=W[:-1]+". "
 print s("@",X,W)

Takes input in the format:

F('''Multi or Single-lined String''')

Can be golfed down a lot more, which I will do whenever I get the chance.

Repl.it with All Test Cases!

Explanation:

Uses the immense power of Python's regular expression built-ins to decipher the input. This is the fundamental process the function goes through for each input:

Firstly, all -- are replaced with a single space, and every apostrophe is removed. Then, all words containing italicized components and the word proceeding it are both matched in one string and replaced with 10 + len(second word) number of consecutive as if the length of the first word is odd, and 20 + len(second word) consecutive as otherwise. This makes use of the following regular expression:

[^\w\s*]*\w*\*\w+\*.*?(?=\s) \w+

For example, if we have the sentence Perpendicular l*ou*nging calms., l*ou*nging calms will be replaced with aaaaaaaaaaaaaaaaaaaaaaaaa, or 25 as, since l*ou*nging has an even number of characters and calms has 5. 20+5=25.

Now, the newly modified input is split at each punctuation mark followed by a newline (\n) to get the paragraphs, then each paragraph is split at each punctuation followed by 2 spaces to get the sentences, and finally, each sentence is split into words along any punctuation including a space. Then, for each word (including the runs of consecutive as), we add on to a string W the letter corresponding to the unicode code point 64 (the unicode code point of the character before A, which is @) plus len(word). We then add a single space to W once all the words of a sentence have been exhausted, and when all the sentences in a paragraph are exhausted, we add a . followed by a single space.

Finally, after the entire input has been gone through, W is output to stdout as the deciphered message.


答:
Retina, 31 bytes

```<code>.+
$*
+`1(?!(11+)\1+$)11+
1
^1$
</code>```

Prints 0 (falsy) or 1 (truthy).

Try it online! (The first line enables a linefeed-separated test suite.)

Explanation

```<code>.+
$*
</code>```

Convert input to unary by turning input N into N copies of 1.

```<code>+`1(?!(11+)\1+$)11+
1
</code>```

Repeatedly remove the largest prime less than the input. This is based on the standard primality test with regex.

```<code>^1$
</code>```

Check whether the result is a single 1.

Title: Can the number reach 1 by repeatedly subtracting the largest prime less than it?

Body:
Challenge:

Given a number, take the largest prime strictly less than it, subtract it from this number, do this again to this new number with the biggest prime less than it, and continue doing this until it's less than 3. If it reaches 1, your program should output a truthy value, else, the program should output a falsey value.

Examples:

All of these should give a truthy value:

```<code>3
4
6
8
10
11
12
14
16
17
18
20
22
23
24
26
27
29
30
32
34
35
37
38
40
41
42
44
46
47
48
50
</code>```

All of these should give falsey values:

```<code>5
7
9
13
15
19
21
25
28
31
33
36
39
43
45
49
</code>```

Rules:

You can either write a program or function.

You can assume that the input is bigger than 2.

Standard loopholes apply

This is code-golf so the shortest answer wins!

Body:
Retina, 31 bytes

.+
$*
+`1(?!(11+)\1+$)11+
1
^1$

Prints 0 (falsy) or 1 (truthy).

Try it online! (The first line enables a linefeed-separated test suite.)

Explanation

.+
$*

Convert input to unary by turning input N into N copies of 1.

+`1(?!(11+)\1+$)11+
1

Repeatedly remove the largest prime less than the input. This is based on the standard primality test with regex.

^1$

Check whether the result is a single 1.


问:
Simulate the Wireworld cellular automaton
Wireworld is a cellular automaton that was designed to be resemble electrons flowing through wires. Its simple mechanics allow the construction of digital circuits.  It has even permitted the construction of an entire computer.

Your mission is to create the shortest Wireworld implementation in your language of choice.

Each cell in the grid has one out of four states.  The four states are "blank," "copper," "electron head," or "electron tail."

A blank cell will always remain a blank cell

An electron head will always become an electron tail

An electron tail will always become copper

A copper cell will become an electron head iff exactly one or two out of its eight neighbors are electron heads, otherwise it will remain copper

This competition will have a similar style to the Shortest Game of Life competition, but with a few changes.

The grid must be at least 40 by 40 cells

The edges of the grid must NOT wrap around (not a torus). Treat cells outside of the field as being constantly "blank."

It must be possible for the users to enter their own starting configuration.

Staring at blank screens is not fun.  The program must visually display the simulation as it is running.

This is code golf,  fewest bytes wins.

答:
Python (<s>243</s> 214)

Tried to make a cross between usability and characters. The grid is 40x40. Input is given on stdin. An electron head is h, electron tail is t, copper is c, anything else is blank.

```<code>import os
f=raw_input()
while 1:f=''.join('h'if(i=='c')&(0<sum(1 for i in[-1,1,-39,-40,-41,39,40,41]if f[e+i:e+i+1]=='h')<3)else't'if i=='h'else'c'if i=='t'else f[e]for e,i in enumerate(f));os.system('cls');print f
</code>```

The while loop (line 3) uncompressed (will not work if placed in code):

```<code>while 1:
 for e,i in enumerate(f):
  if(i=='c')&(0<sum(1 for i in[-1,1,-39,-40,-41,39,40,41]if f[e+i:e+i+1]=='h')<3):f[e]='h'
  elif i=='h':f[e]='t'
  elif i=='t':f[e]='c'
  else:f[e]=f[e]  #redundant, but Python needs this to run
 os.system('cls') #cls is shorter than clear, so I used that
 print f
</code>```

Body:
Python (<s>243</s> 214)

Tried to make a cross between usability and characters. The grid is 40x40. Input is given on stdin. An electron head is h, electron tail is t, copper is c, anything else is blank.

import os
f=raw_input()
while 1:f=''.join('h'if(i=='c')&(0<sum(1 for i in[-1,1,-39,-40,-41,39,40,41]if f[e+i:e+i+1]=='h')<3)else't'if i=='h'else'c'if i=='t'else f[e]for e,i in enumerate(f));os.system('cls');print f

The while loop (line 3) uncompressed (will not work if placed in code):

while 1:
 for e,i in enumerate(f):
  if(i=='c')&(0<sum(1 for i in[-1,1,-39,-40,-41,39,40,41]if f[e+i:e+i+1]=='h')<3):f[e]='h'
  elif i=='h':f[e]='t'
  elif i=='t':f[e]='c'
  else:f[e]=f[e]  #redundant, but Python needs this to run
 os.system('cls') #cls is shorter than clear, so I used that
 print f


答:
Pyth, <s>18</s> <s>15</s> 14 bytes

Thanks to @Maltysen for -1 byte

```<code>#=-QefP_TUQ)q1
</code>```

A program that takes input on STDIN and prints True or False as appropriate.

Try it online

How it works

```<code>#=-QefP_TUQ)q1  Program. Input: Q
#          )    Loop until error statement (which occurs when Q<3):
         UQ      Yield [0, 1, 2, 3, ..., Q-1]
     fP_T        Filter that by primality
    e            Yield the last element of that
 =-Q             Q = Q - that
            q1  Q is 1 (implicit variable fill)
                Implicitly print
</code>```

Old version with reduce, 18 bytes

```<code>qu-G*<HGH_fP_TSQQ1
</code>```

Try it online

How it works

```<code>qu-G*<HGH_fP_TSQQ1  Program. Input: Q
              SQ    Yield [1, 2, 3, ..., Q]
          fP_T      Filter that by primality
         _          Reverse it
 u                  Reduce it:
                Q    with base case Q and
                     function G, H ->
     <HG              H<G
    *   H             *H (yields H if H<G, else 0)
  -G                  Subtract that from G
q                1  The result of that is 1
                    Implicitly print
</code>```

Body:
Pyth, <s>18</s> <s>15</s> 14 bytes

Thanks to @Maltysen for -1 byte

#=-QefP_TUQ)q1

A program that takes input on STDIN and prints True or False as appropriate.

Try it online

How it works

#=-QefP_TUQ)q1  Program. Input: Q
#          )    Loop until error statement (which occurs when Q<3):
         UQ      Yield [0, 1, 2, 3, ..., Q-1]
     fP_T        Filter that by primality
    e            Yield the last element of that
 =-Q             Q = Q - that
            q1  Q is 1 (implicit variable fill)
                Implicitly print

Old version with reduce, 18 bytes

qu-G*<HGH_fP_TSQQ1

Try it online

How it works

qu-G*<HGH_fP_TSQQ1  Program. Input: Q
              SQ    Yield [1, 2, 3, ..., Q]
          fP_T      Filter that by primality
         _          Reverse it
 u                  Reduce it:
                Q    with base case Q and
                     function G, H ->
     <HG              H<G
    *   H             *H (yields H if H<G, else 0)
  -G                  Subtract that from G
q                1  The result of that is 1
                    Implicitly print


Title: Produce the word 'codegolf' without using any of its characters in code

Body:
You need to produce the word codegolf

Rules:

None of the characters of the word codegolf (i.e. 'c', 'o', 'd', 'e', 'g', 'o', 'l' and 'f') in either case can exist anywhere in the code.

Case of the word must be one of three:

All Upcase (CODEGOLF)

All Downcase (codegolf)

Capitalized (Codegolf)

You only need to produce it somehow so there can be other characters in the output as well. For example, 21§HCodegolf092 is an acceptable result.

The shortest code (counting in bytes) to do so in any language wins.

I guess it will be less trickier in some languages than others (Brainfuck, Javascript, etc.)

Body:
Lua, 33 bytes

CODEGOLF (33 bytes)

print("\67\79\68\69\71\79\76\70")

Codegolf (40 bytes)

print("\67\111\100\101\103\111\108\102")

codegolf (40 bytes)

print("\99\111\100\101\103\111\108\102")


答:
Mathematica, 32 bytes

```<code>2>(#//.x_/;x>2:>x+NextPrime@-x)&
</code>```

This is an unnamed function which takes an integer and returns a boolean.

Explanation

There's a lot of syntax and funny reading order here, so...

```<code>   #                               This is simply the argument of the function.
    //.                            This is the 'ReplaceRepeated' operator, which applies
                                   a substitution until the its left-hand argument stops
                                   changing.
       x_/;x>2                     The substitution pattern. Matches any expression x as
                                   long as that expression is greater than 2.
              :>                   Replace that with...
                  NextPrime@-x     Mathematica has a NextPrime built-in but no
                                   PreviousPrime built-in. Conveniently, NextPrime
                                   works with negative inputs and then gives you the
                                   next "negative prime" which is basically a
                                   PreviousPrime function (just with an added minus sign).
                x+                 This gets added to x, which subtracts the previous
                                   prime from it.
2>(                           )    Finally, we check whether the result is less than 2.
</code>```

Body:
Mathematica, 32 bytes

2>(#//.x_/;x>2:>x+NextPrime@-x)&

This is an unnamed function which takes an integer and returns a boolean.

Explanation

There's a lot of syntax and funny reading order here, so...

   #                               This is simply the argument of the function.
    //.                            This is the 'ReplaceRepeated' operator, which applies
                                   a substitution until the its left-hand argument stops
                                   changing.
       x_/;x>2                     The substitution pattern. Matches any expression x as
                                   long as that expression is greater than 2.
              :>                   Replace that with...
                  NextPrime@-x     Mathematica has a NextPrime built-in but no
                                   PreviousPrime built-in. Conveniently, NextPrime
                                   works with negative inputs and then gives you the
                                   next "negative prime" which is basically a
                                   PreviousPrime function (just with an added minus sign).
                x+                 This gets added to x, which subtracts the previous
                                   prime from it.
2>(                           )    Finally, we check whether the result is less than 2.


答:
CJam, <s>21</s> 16 bytes

Thanks to Dennis for saving 4 bytes.

```<code>ri{_1|{mp},W=-}h
</code>```

Try it online!

Explanation

```<code>ri       e# Read input and convert to integer N.
{        e# Run this block as long as N is positive (or until the program aborts
         e# with an error)...
  _1|    e#   Duplicate and OR 1. This rounds up to an odd number. For N > 2, this
         e#   will never affect the greatest prime less than N.
  {mp},  e#   Get all primes from 0 to (N|1)-1.
         e#   For N > 2, this will contain all primes less than N.
         e#   For N = 2, this will contain only 2.
         e#   For N = 1, this will be empty.
  W=     e#   Select the last element (largest prime up to (N|1)-1).
         e#   For N = 1, this will result in an error and terminate the program, which
         e#   still prints the stack contents though (which are 1, the desired output).
  -      e#   Subtract from N. Note that this gives us 0 for N = 2, which terminates the
         e#   loop.
}h
</code>```

Body:
CJam, <s>21</s> 16 bytes

Thanks to Dennis for saving 4 bytes.

ri{_1|{mp},W=-}h

Try it online!

Explanation

ri       e# Read input and convert to integer N.
{        e# Run this block as long as N is positive (or until the program aborts
         e# with an error)...
  _1|    e#   Duplicate and OR 1. This rounds up to an odd number. For N > 2, this
         e#   will never affect the greatest prime less than N.
  {mp},  e#   Get all primes from 0 to (N|1)-1.
         e#   For N > 2, this will contain all primes less than N.
         e#   For N = 2, this will contain only 2.
         e#   For N = 1, this will be empty.
  W=     e#   Select the last element (largest prime up to (N|1)-1).
         e#   For N = 1, this will result in an error and terminate the program, which
         e#   still prints the stack contents though (which are 1, the desired output).
  -      e#   Subtract from N. Note that this gives us 0 for N = 2, which terminates the
         e#   loop.
}h


答:
Vitsy, 6 bytes

```<code><ZR^72
</code>```

This has a 1 in 36028797018963968 chance of printing the right order of characters per character output with ~10000 characters output a second. This means that, by 3.17 million years from now, you'll almost certainly have seen it.

:)

Using a method found here.

Try it online!

Body:
Vitsy, 6 bytes

<ZR^72

This has a 1 in 36028797018963968 chance of printing the right order of characters per character output with ~10000 characters output a second. This means that, by 3.17 million years from now, you'll almost certainly have seen it.

:)

Using a method found here.

Try it online!


答:
JavaScript (ES6), 83 bytes

f=
n=>{p=r=>Math.abs(r/n-n/r-1);for(r=i=n;--i;)r=n%i||p(i*i)>p(r*r)?r:i;return[r,n/r]}
;```
<pre class="snippet-code-html lang-html prettyprint-override"><code><input type=number min=1 oninput=[a.value,b.value]=f(+this.value)><input readonly id=a><input readonly id=b></code>```

Actually returns the (a, b) pair which minimises the absolute value of a/b-b/a-1, but this works for all the test cases at least, although I guess I could save 4 bytes by using the 1.618 test instead.

Title: Goldenness of an integer

Body:
A positive integer n can be represented as a rectangle with integer sides a, b such that n = a * b. That is, the area represents the number. In general, a and b are not unique for a given n.

As is well known, a rectangle is specially pleasing to the eye (or is it the brain?) when its sides are in the golden ratio, φ = (sqrt(5)+1)/2 ≈ 1.6180339887...

Combining these two facts, the purpose of this challenge is to decompose an integer n into the product of two integers a, b whose ratio is as close as possible to φ (with the usual metric on ℝ). The fact that φ is irrational implies that there is a unique solution pair (a, b).

The challenge

Given a positive integer n, output positive integers a, b such that  a * b = n and the absolute difference between a/b and φ is minimized.

As an example, consider n = 12. The pairs (a, b) that satisfy a * b = n are: (1, 12), (2,6), (3,4), (4,3), (6,2), (12,1). The pair whose ratio is closest to φ is (4,3), which gives 4/3 = 1.333.

Rules

Functions or programs are acceptable.

The numerator (a) should appear first in the output, and the denominator (b) second. Other than that, input and output formats are flexible as usual. For example, the two numbers can be output as strings with any reasonable separator, or as an array.

The code should work in theory for arbitrarily large numbers. In practice, it may be limited by memory or data-type restrictions.

It's sufficient to consider an approximate version of φ, as long as it is accurate up to the third decimal or better. That is, the absolute difference between the true φ and the approximate value should not exceed 0.0005. For example, 1.618 is acceptable.

When using an approximate, rational version of φ there's a small chance that the solution is not unique. In that case you can output any pair a, b that satisfies the minimization criterion.

Shortest code wins.

Test cases

```<code>1        ->  1    1
2        ->  2    1
4        ->  2    2
12       ->  4    3
42       ->  7    6
576      ->  32   18
1234     ->  2    617
10000    ->  125  80
199999   ->  1    199999
9699690  ->  3990 2431
</code>```

Body:
JavaScript (ES6), 83 bytes

f=
n=>{p=r=>Math.abs(r/n-n/r-1);for(r=i=n;--i;)r=n%i||p(i*i)>p(r*r)?r:i;return[r,n/r]}
;

<input type=number min=1 oninput=[a.value,b.value]=f(+this.value)><input readonly id=a><input readonly id=b>

Actually returns the (a, b) pair which minimises the absolute value of a/b-b/a-1, but this works for all the test cases at least, although I guess I could save 4 bytes by using the 1.618 test instead.


答:
Pyke, <s>15</s> 11 bytes

```<code>WDU#_P)e-Dt
</code>```

Try it here!

```<code>            - stack = input
W           - while continue:
  U#_P)     -     filter(is_prime, range(stack))
       e    -    ^[-1]
 D      -   -   stack-^
         Dt -  continue = ^ != 1
</code>```

Returns 1 if true and raises an exception if false

Body:
Pyke, <s>15</s> 11 bytes

WDU#_P)e-Dt

Try it here!

            - stack = input
W           - while continue:
  U#_P)     -     filter(is_prime, range(stack))
       e    -    ^[-1]
 D      -   -   stack-^
         Dt -  continue = ^ != 1

Returns 1 if true and raises an exception if false


答:
Julia (0.4), 32 bytes

(Update (as of 1.4): This is rather out-of-date, now - primes is no longer in Base, and ?: needs spaces around the ? and the :)

While it's not going to be the shortest solution among the languages, this might be the shortest of the human-readable ones...

```<code>!n=n>2?!(n-primes(n-1)[end]):n<2
</code>```

Try it online!

Or, to put it in slightly clearer terms

```<code>function !(n)
  if n>2
    m=primes(n-1)[end]   # Gets largest prime less than n
    return !(n-m)        # Recurses
  else
    return n<2           # Gives true if n is 1 and false if n is 2
  end
end
</code>```

Called with, for example, !37.

Body:
Julia (0.4), 32 bytes

(Update (as of 1.4): This is rather out-of-date, now - primes is no longer in Base, and ?: needs spaces around the ? and the :)

While it's not going to be the shortest solution among the languages, this might be the shortest of the human-readable ones...

!n=n>2?!(n-primes(n-1)[end]):n<2

Try it online!

Or, to put it in slightly clearer terms

function !(n)
  if n>2
    m=primes(n-1)[end]   # Gets largest prime less than n
    return !(n-m)        # Recurses
  else
    return n<2           # Gives true if n is 1 and false if n is 2
  end
end

Called with, for example, !37.


答:
Python3, 102 92 90 89 88 bytes

```<code>f=lambda n:n<2if n<3else f(n-[x for x in range(2,n)if all(x%y for y in range(2,x))][-1])
</code>```

Golfing suggestions welcome! I see that gmpy contains a function next_prime, but I can't test it yet :(

-2 bytes, thanks to @JonathanAllan!

-1 byte, thanks to @Aaron!

Testcases

```<code>f=lambda n:n<2if n<3else f(n-[x for x in range(2,n)if all(x%y for y in range(2,x))][-1])

s="3 4 6 8 10 11 12 14 16 17 18 20 22"
h="5 7 9 13 15 19 21 25 28 31 33 36 39"

for j in s.split(" "):print(f(int(j)))
for j in h.split(" "):print(f(int(j)))
</code>```

Output is 13 truthy values and 13 falsey values.
s contains the truthy cases and h the falseys.

Body:
Python3, 102 92 90 89 88 bytes

f=lambda n:n<2if n<3else f(n-[x for x in range(2,n)if all(x%y for y in range(2,x))][-1])

Golfing suggestions welcome! I see that gmpy contains a function next_prime, but I can't test it yet :(

-2 bytes, thanks to @JonathanAllan!

-1 byte, thanks to @Aaron!

Testcases

f=lambda n:n<2if n<3else f(n-[x for x in range(2,n)if all(x%y for y in range(2,x))][-1])

s="3 4 6 8 10 11 12 14 16 17 18 20 22"
h="5 7 9 13 15 19 21 25 28 31 33 36 39"

for j in s.split(" "):print(f(int(j)))
for j in h.split(" "):print(f(int(j)))

Output is 13 truthy values and 13 falsey values.
s contains the truthy cases and h the falseys.


Body:
Floroid, 45 30 29 bytes

f=Bb:b<2Fb<3Gf(b-en(b-1)[-1])


答:
Pyke, 5 bytes

```<code>~aHpr
</code>```

Try it here!

Body:
Pyke, 5 bytes

~aHpr

Try it here!


答:
05AB1E, 5 bytes

```<code>’ƒËŠˆ
</code>```

Uses the CP-1252 encoding. Try it online!

Body:
05AB1E, 5 bytes

’ƒËŠˆ

Uses the CP-1252 encoding. Try it online!


答:
05AB1E, 21 bytes

Code:

```<code>ÑÂø©vy`/})5t>;-ÄWQ®sÏ
</code>```

Uses the CP-1252 encoding. Try it online!

Title: Goldenness of an integer

Body:
05AB1E, 21 bytes

Code:

ÑÂø©vy`/})5t>;-ÄWQ®sÏ

Uses the CP-1252 encoding. Try it online!


答:
JavaScript (ES6), <s>64</s> 63 bytes

Saved 1 byte thanks to @Neil

```<code>g=(x,n=x-1)=>n<2?x:x%n?g(x,n-1):g(x-1)
f=x=>x<3?x%2:f(x-g(x-1))
</code>```

I wrote this in 2 minutes... and it worked perfectly the first time. First user to find the inevitable bug wins....

Try it out

g=(x,n=x-1)=>n<2?x:x%n?g(x,n-1):g(x-1)
f=x=>x<3?x%2:f(x-g(x-1))```
<pre class="snippet-code-html lang-html prettyprint-override"><code><input type="number" value=3 min=3 onchange="A.innerHTML=f(this.value)"><br>
<p id=A>1</p></code>```

How it works

First we define g(x) as the function that finds the first prime number p <= x. This is done using the following process:

Start with n = x-1.

If n < 2, x is prime; return x.

If x is divisible  by n, decrement x and go to step 1.

Otherwise, decrement n and go to step 2.

The solution to this challenge, f(x), is now fairly straightforward:

If x < 3, return x = 1.

Otherwise, subtract g(x-1) and try again.

Body:
Challenge:

Given a number, take the largest prime strictly less than it, subtract it from this number, do this again to this new number with the biggest prime less than it, and continue doing this until it's less than 3. If it reaches 1, your program should output a truthy value, else, the program should output a falsey value.

Examples:

All of these should give a truthy value:

```<code>3
4
6
8
10
11
12
14
16
17
18
20
22
23
24
26
27
29
30
32
34
35
37
38
40
41
42
44
46
47
48
50
</code>```

All of these should give falsey values:

```<code>5
7
9
13
15
19
21
25
28
31
33
36
39
43
45
49
</code>```

Rules:

You can either write a program or function.

You can assume that the input is bigger than 2.

Standard loopholes apply

This is code-golf so the shortest answer wins!

Body:
JavaScript (ES6), <s>64</s> 63 bytes

Saved 1 byte thanks to @Neil

g=(x,n=x-1)=>n<2?x:x%n?g(x,n-1):g(x-1)
f=x=>x<3?x%2:f(x-g(x-1))

I wrote this in 2 minutes... and it worked perfectly the first time. First user to find the inevitable bug wins....

Try it out

g=(x,n=x-1)=>n<2?x:x%n?g(x,n-1):g(x-1)
f=x=>x<3?x%2:f(x-g(x-1))

<input type="number" value=3 min=3 onchange="A.innerHTML=f(this.value)"><br>
<p id=A>1</p>

How it works

First we define g(x) as the function that finds the first prime number p <= x. This is done using the following process:

Start with n = x-1.

If n < 2, x is prime; return x.

If x is divisible  by n, decrement x and go to step 1.

Otherwise, decrement n and go to step 2.

The solution to this challenge, f(x), is now fairly straightforward:

If x < 3, return x = 1.

Otherwise, subtract g(x-1) and try again.


答:
MATL, 13 bytes

```<code>`tqZq0)-t2>}o
</code>```

Try it online! Or verify all test cases at once.

Explanation

```<code>`        % Do...while
  t      %   Duplicate. Takes input implicitly in the first iteration
  qZq    %   All primes less than that
  0)     %   Get last one
  -      %   Subtract (this result will be used in the next iteration, if any)
  t      %   Duplicate
  2>     %   Does it exceed 2? If so: next iteration. Else: execute the "finally"
         %   block and exit do...while loop
}        % Finally
  o      %   Parity. Transforms 2 into 0 and 1 into 1
         % End do...while implicitly
         % Display implicitly
</code>```

Body:
MATL, 13 bytes

`tqZq0)-t2>}o

Try it online! Or verify all test cases at once.

Explanation

`        % Do...while
  t      %   Duplicate. Takes input implicitly in the first iteration
  qZq    %   All primes less than that
  0)     %   Get last one
  -      %   Subtract (this result will be used in the next iteration, if any)
  t      %   Duplicate
  2>     %   Does it exceed 2? If so: next iteration. Else: execute the "finally"
         %   block and exit do...while loop
}        % Finally
  o      %   Parity. Transforms 2 into 0 and 1 into 1
         % End do...while implicitly
         % Display implicitly


答:
Jelly, <s>9</s> 8 bytes

```<code>’ÆRṪạµ¡Ḃ
</code>```

Try it online! or verify all test cases.

How it works

```<code>’ÆRṪạµ¡Ḃ  Main link. Argument: n

     µ    Combine all atoms to the left into a chain.
’           Decrement; yield n - 1.
 ÆR         Prime range; yield all primes in [2, ..., n -1].
   Ṫ        Tail; yield p, the last prime in the range.
            If the range is empty, this yields p = 0.
    ạ       Compute the absolute difference of p and n.
      ¡   Call the chain to the left n times.
          This suffices since each iteration decreases n, until one of the fixed
          points (1 or 2) is reached.
       Ḃ  Bit; return the parity of the fixed point.
</code>```

Body:
Jelly, <s>9</s> 8 bytes

’ÆRṪạµ¡Ḃ

Try it online! or verify all test cases.

How it works

’ÆRṪạµ¡Ḃ  Main link. Argument: n

     µ    Combine all atoms to the left into a chain.
’           Decrement; yield n - 1.
 ÆR         Prime range; yield all primes in [2, ..., n -1].
   Ṫ        Tail; yield p, the last prime in the range.
            If the range is empty, this yields p = 0.
    ạ       Compute the absolute difference of p and n.
      ¡   Call the chain to the left n times.
          This suffices since each iteration decreases n, until one of the fixed
          points (1 or 2) is reached.
       Ḃ  Bit; return the parity of the fixed point.


答:
Perl 6, <s> 54 53 52 </s> 51 bytes

{($_,{$_-($_-1...2).first: *.is-prime}...3>*)[*-1]==1}
{($_,{$_-($_-1...2).first: *.is-prime}...3>*).any==1}
{any($_,{$_-($_-1...2).first: *.is-prime}...3>*)==1}
```

<pre class="lang-perl6 prettyprint-override"><code>{any($_,{$_-(^$_).grep(*.is-prime)[*-1]}...3>*)==1}
</code>```

Explanation:

# bare block lambda with implicit parameter ｢$_｣
# used to generate all of the rest of the elements of the sequence
{
  # create an any Junction of the following list
  any(
    $_, # initialize sequence with the inner block's argument

    # bare block lambda with implicit parameter ｢$_｣
    {
      # take this inner block's argument and subtract
      $_ -

      ( ^$_ )            # Range up-to and excluding ｢$_｣
      .grep(*.is-prime)\ # find the primes
      [ * - 1 ]          # return the last value
    }

    ...   # keep doing that until

    3 > * # the result is less than 3

  # test that Junction against ｢1｣
  # ( returns an ｢any｣ Junction like ｢any(False, False, True)｣ )
  ) == 1
}
```

<h2>Example:</h2>

<pre class="lang-perl6 prettyprint-override"><code># show what is returned and if it is truthy
sub show ($_) {
  # ｢.&{…}｣ uses the block as a method and implicitly against ｢$_｣
  my $value = .&{any($_,{$_-(^$_).grep(*.is-prime)[*-1]}...3>*)==1}
  say join "\t", $_, ?$value, $value.gist;
}

show 3;  # 3    True    any(False, True)
show 4;  # 4    True    any(False, True)
show 5;  # 5    False   any(False, False)
show 10; # 10   True    any(False, False, True)
show 28; # 28   False   any(False, False, False)
show 49; # 49   False   any(False, False)
show 50; # 50   True    any(False, False, True)
</code>```

Body:
Perl 6, <s> 54 53 52 </s> 51 bytes

{($_,{$_-($_-1...2).first: *.is-prime}...3>*)[*-1]==1}
{($_,{$_-($_-1...2).first: *.is-prime}...3>*).any==1}
{any($_,{$_-($_-1...2).first: *.is-prime}...3>*)==1}

{any($_,{$_-(^$_).grep(*.is-prime)[*-1]}...3>*)==1}

Explanation:

# bare block lambda with implicit parameter ｢$_｣
# used to generate all of the rest of the elements of the sequence
{
  # create an any Junction of the following list
  any(
    $_, # initialize sequence with the inner block's argument

    # bare block lambda with implicit parameter ｢$_｣
    {
      # take this inner block's argument and subtract
      $_ -

      ( ^$_ )            # Range up-to and excluding ｢$_｣
      .grep(*.is-prime)\ # find the primes
      [ * - 1 ]          # return the last value
    }

    ...   # keep doing that until

    3 > * # the result is less than 3

  # test that Junction against ｢1｣
  # ( returns an ｢any｣ Junction like ｢any(False, False, True)｣ )
  ) == 1
}

Example:

# show what is returned and if it is truthy
sub show ($_) {
  # ｢.&{…}｣ uses the block as a method and implicitly against ｢$_｣
  my $value = .&{any($_,{$_-(^$_).grep(*.is-prime)[*-1]}...3>*)==1}
  say join "\t", $_, ?$value, $value.gist;
}

show 3;  # 3    True    any(False, True)
show 4;  # 4    True    any(False, True)
show 5;  # 5    False   any(False, False)
show 10; # 10   True    any(False, False, True)
show 28; # 28   False   any(False, False, False)
show 49; # 49   False   any(False, False)
show 50; # 50   True    any(False, False, True)


答:
Python 2, 84 bytes

def f(t,z):i=int;r=60*(i(t[:2])+i(z[3:6]))+i(t[3:])+i(z[3]+z[7:]);print r/60%24,r%60
```

All test cases are at ideone

Output format is space separated, with no leading zeros.

Title: Change the Timezone

Body:
Challenge

Given a time and a timezone as input, output the time in that timezone.

Time

The time will be given in 24 hour format like so:

```<code>hh:mm
</code>```

Where hh is the two digit hour and mm is the two digit minute. Note that the hour and the minute will always be padded with zeroes like so:

```<code>06:09
</code>```

All the times given are at UTC+00:00.

The hours in your output do not have to be padded wih zeroes but your time it must be in 24 hour format

Timezone

The timezone will be given in the following format:

```<code>UTC±hh:mm
</code>```

Where ± is either going to be a + or a - and hh, is the two digit hour and mm is the two digit minute (again, these will be padded with zeroes).

To find the time in that timezone, you either add (if the symbol is +) or subtract (if the symbol is -) the time after the UTC± from the inputted time.

For example, if the input was 24:56 and UTC-02:50, you would subtract 2 hours and 50 minutes from 24:56:

```<code>24:56
02:50 -
-----
22:06
</code>```

The output would be 22:06.

Examples

Chicago

```<code>Input:  08:50 and UTC-06:00
Output: 02:50
</code>```

Kathmandu

```<code>Input:  09:42 and UTC+05:45
Output: 15:27
</code>```

Samoa

```<code>Input:  06:42 and UTC+13:00
Output: 19:42
</code>```

Hawaii

```<code>Input:  02:40 and UTC-10:00
Output: 16:40
</code>```

Note that this has gone to the previous day.

Tokyo

```<code>Input:  17:25 and UTC+09:00
Output: 02:25
</code>```

Note that this has gone to the following day.

Rules

You must not use any built in date functions or libraries.

Assume all input will be valid times and time offsets.

The timezone will be in the range UTC-24:00 to UTC+24:00 inclusive.

In the case of half past midnight, the correct representation should be 00:30, not 24:30.

Winning

The shortest code in bytes wins.

Body:
Python 2, 84 bytes

def f(t,z):i=int;r=60*(i(t[:2])+i(z[3:6]))+i(t[3:])+i(z[3]+z[7:]);print r/60%24,r%60

All test cases are at ideone

Output format is space separated, with no leading zeros.


问:
Implementing bool() without any conditionals
Title says it all. Given some input, turn it into a boolean value (0 or 1), without using conditional statements (e.x. == > < <= >= != ~=), or any function which uses conditional statements within its implementation, such as if, while and for. Your program must work with floating points, although you get more if it works with other items.

A general rule for determining whether bool(item) is False is if the item is empty ('' is an empty string, [] is an empty list.), or if the function used to turn an item of one type into another is given no input (in Python, str() returns '', list() returns [].)

Here are (some of) the different valid types. Your program is considered to work with one type if it works with one item in the following lists:

Integers, floating points, doubles, longs

Strings

Lists, tuples, arrays (bytearrays)

Dictionaries

Functions

Objects/Classes

Program score will be calculated like this: [# of characters]-(50*[# of types]). The program with the smallest score wins the challenge.

答:
Python - 122 chars - 50*13 types = -528

```<code>def b(x=False):
 try:return[False][x]
 except IndexError:return True
 except:
  try:return b(len(x))
  except:return True
</code>```

Works for the following built-in types (as listed in §3.2 The standard type hierarchy)

NotImplemented

Ellipsis

int

long

bool

string

unicode

tuple

list

bytearray

set

frozenset

dict

Body:
Python - 122 chars - 50*13 types = -528

def b(x=False):
 try:return[False][x]
 except IndexError:return True
 except:
  try:return b(len(x))
  except:return True

Works for the following built-in types (as listed in §3.2 The standard type hierarchy)

NotImplemented

Ellipsis

int

long

bool

string

unicode

tuple

list

bytearray

set

frozenset

dict


Title: Change the Timezone

Body:
Ruby, 95 bytes

g=->s{"60*"+s.scan(/\d+/).map(&:to_i)*?+}
f=->t,z{r=eval(g[t]+z[3]+g[z]);print r/60%24,?:,r%60}

Usage

f[gets,gets]

Inputs(example)

08:50
UTC-06:00


问:
Make me a bad fade animation... please
Your task is to, as the title discreetly suggests, make a bad fade animation of one word turning into a second word for yours truly.

What exactly is this "fade animation" you may ask?

To make a spectacular(ly bad) fade animation, you take two strings which will contain only printable ASCII characters. You start by printing your starting string (the first of the two). Then, you randomly pick a character in the original word and change it to the corresponding character in the word you want to animate to. When the words are of unequal length, you must pad them with spaces.

You keep on doing this until all of the characters have been changed, but you will not change the character at a certain index more than once. Here is an example i/o:

```<code>Hey -> Peeps
Hey    # original string
Hey s  # replace char at index 4
Hey s  # replace char at index 1
Pey s  # replace char at index 0
Pee s  # replace char at index 2
Peeps  # replace char at index 3
</code>```

You must write a function or full program that changes a letter and then prints the new string at increments of one second. The input format is loose, but the output format is strict.

This is code-golf, so shortest code in bytes wins.

Some test cases (Form: init -> final):

```<code>Stringy -> Blingy
Banana -> Republic
United -> States
Make America -> Tissue box
I like walls -> I have small hands
Hello, -> world!
</code>```

Reference implementation in Python 2:

```<code>import random
import time
def F(c,f):
    print c                                      # before we do stuff
    if len(c)>len(f):f+=" "*(len(c)-len(f))      # add padding part 1
    if len(f)>len(c):c+=" "*(len(f)-len(c))      # add padding part 2
    c, f = list(c), list(f)
    ai = [i for i in range(len(c))]              # a list for keeping track
    while len(ai) > 0:                           #  of available indices
        time.sleep(1)                            # 1 second pause...
        i = ai.pop(random.randint(0,len(ai)-1))  # get a random index and remove
        c[i] = f[i]                              #   it from the list
        print ''.join(c)                         # print the new string
</code>```

答:
Python 3, 214 bytes

import time,random
o,f=list(input()),list(input())
F=len(f);O=len(o);o+=[" "]*(F-O);f+=[" "]*(O-F);p=-1;l=[p]
while o!=f:
 while p in l:p=random.randrange(max(F,O))
 l+=[p];o[p]=f[p];print(''.join(o));time.sleep(1)
```

Ideone it!

Title: Make me a bad fade animation... please

Body:
Python 3, 214 bytes

import time,random
o,f=list(input()),list(input())
F=len(f);O=len(o);o+=[" "]*(F-O);f+=[" "]*(O-F);p=-1;l=[p]
while o!=f:
 while p in l:p=random.randrange(max(F,O))
 l+=[p];o[p]=f[p];print(''.join(o));time.sleep(1)

Ideone it!


答:
Pyth - <s>25</s> 24 bytes

Will refactor.

```<code>AC.tQdV.SU
G
=XGN@HN.d_1
</code>```

Try it online here.

Title: Make me a bad fade animation... please

Body:
Your task is to, as the title discreetly suggests, make a bad fade animation of one word turning into a second word for yours truly.

What exactly is this "fade animation" you may ask?

To make a spectacular(ly bad) fade animation, you take two strings which will contain only printable ASCII characters. You start by printing your starting string (the first of the two). Then, you randomly pick a character in the original word and change it to the corresponding character in the word you want to animate to. When the words are of unequal length, you must pad them with spaces.

You keep on doing this until all of the characters have been changed, but you will not change the character at a certain index more than once. Here is an example i/o:

```<code>Hey -> Peeps
Hey    # original string
Hey s  # replace char at index 4
Hey s  # replace char at index 1
Pey s  # replace char at index 0
Pee s  # replace char at index 2
Peeps  # replace char at index 3
</code>```

You must write a function or full program that changes a letter and then prints the new string at increments of one second. The input format is loose, but the output format is strict.

This is code-golf, so shortest code in bytes wins.

Some test cases (Form: init -> final):

```<code>Stringy -> Blingy
Banana -> Republic
United -> States
Make America -> Tissue box
I like walls -> I have small hands
Hello, -> world!
</code>```

Reference implementation in Python 2:

```<code>import random
import time
def F(c,f):
    print c                                      # before we do stuff
    if len(c)>len(f):f+=" "*(len(c)-len(f))      # add padding part 1
    if len(f)>len(c):c+=" "*(len(f)-len(c))      # add padding part 2
    c, f = list(c), list(f)
    ai = [i for i in range(len(c))]              # a list for keeping track
    while len(ai) > 0:                           #  of available indices
        time.sleep(1)                            # 1 second pause...
        i = ai.pop(random.randint(0,len(ai)-1))  # get a random index and remove
        c[i] = f[i]                              #   it from the list
        print ''.join(c)                         # print the new string
</code>```

Body:
Pyth - <s>25</s> 24 bytes

Will refactor.

AC.tQdV.SU
G
=XGN@HN.d_1

Try it online here.


答:
Java 201 bytes

```<code>String T(String t,String z){return(24+Integer.valueOf(t.substring(0,2))+Integer.valueOf((String)z.subSequence(3,6)))%24+":"+(60+Integer.valueOf(t.substring(3,5))+Integer.valueOf(z.substring(7,9)))%60;}
</code>```

Called as
    T("12:00", "UTC+02:40")

Unglolfed for the logic,

```<code>String T(String t, String z) {
    int i = (24 + Integer.valueOf(t.substring(0, 2)) + Integer.valueOf((String) z.subSequence(3, 6))) % 24;
    int j = (60 + Integer.valueOf(t.substring(3, 5)) + Integer.valueOf(z.substring(7, 9))) % 60;
    return i + ":" + j;
}
</code>```

Any help to get it under 200 would be appreciated!

Title: Change the Timezone

Body:
Java 201 bytes

String T(String t,String z){return(24+Integer.valueOf(t.substring(0,2))+Integer.valueOf((String)z.subSequence(3,6)))%24+":"+(60+Integer.valueOf(t.substring(3,5))+Integer.valueOf(z.substring(7,9)))%60;}

Called as
    T("12:00", "UTC+02:40")

Unglolfed for the logic,

String T(String t, String z) {
    int i = (24 + Integer.valueOf(t.substring(0, 2)) + Integer.valueOf((String) z.subSequence(3, 6))) % 24;
    int j = (60 + Integer.valueOf(t.substring(3, 5)) + Integer.valueOf(z.substring(7, 9))) % 60;
    return i + ":" + j;
}

Any help to get it under 200 would be appreciated!


答:
Pyth - <s>24</s> 23 bytes

There has to be a better way to find the divisors...

```<code>ho.a-.n3cFNfsIeTm,dcQdS
</code>```

Test Suite.

Title: Goldenness of an integer

Body:
A positive integer n can be represented as a rectangle with integer sides a, b such that n = a * b. That is, the area represents the number. In general, a and b are not unique for a given n.

As is well known, a rectangle is specially pleasing to the eye (or is it the brain?) when its sides are in the golden ratio, φ = (sqrt(5)+1)/2 ≈ 1.6180339887...

Combining these two facts, the purpose of this challenge is to decompose an integer n into the product of two integers a, b whose ratio is as close as possible to φ (with the usual metric on ℝ). The fact that φ is irrational implies that there is a unique solution pair (a, b).

The challenge

Given a positive integer n, output positive integers a, b such that  a * b = n and the absolute difference between a/b and φ is minimized.

As an example, consider n = 12. The pairs (a, b) that satisfy a * b = n are: (1, 12), (2,6), (3,4), (4,3), (6,2), (12,1). The pair whose ratio is closest to φ is (4,3), which gives 4/3 = 1.333.

Rules

Functions or programs are acceptable.

The numerator (a) should appear first in the output, and the denominator (b) second. Other than that, input and output formats are flexible as usual. For example, the two numbers can be output as strings with any reasonable separator, or as an array.

The code should work in theory for arbitrarily large numbers. In practice, it may be limited by memory or data-type restrictions.

It's sufficient to consider an approximate version of φ, as long as it is accurate up to the third decimal or better. That is, the absolute difference between the true φ and the approximate value should not exceed 0.0005. For example, 1.618 is acceptable.

When using an approximate, rational version of φ there's a small chance that the solution is not unique. In that case you can output any pair a, b that satisfies the minimization criterion.

Shortest code wins.

Test cases

```<code>1        ->  1    1
2        ->  2    1
4        ->  2    2
12       ->  4    3
42       ->  7    6
576      ->  32   18
1234     ->  2    617
10000    ->  125  80
199999   ->  1    199999
9699690  ->  3990 2431
</code>```

Body:
Pyth - <s>24</s> 23 bytes

There has to be a better way to find the divisors...

ho.a-.n3cFNfsIeTm,dcQdS

Test Suite.


Title: Change the Timezone

Body:
Javascript (ES6), <s>93</s> 92 bytes

t=>((t=eval(t.replace(/.*?(.)?(..):(..)/g,'$1($2*60+$3)+720')))/60%24|0)+':'+(t/10%6|0)+t%10

Test cases

let f =
t=>((t=eval(t.replace(/.*?(.)?(..):(..)/g,'$1($2*60+$3)+720')))/60%24|0)+':'+(t/10%6|0)+t%10

console.log(f("08:50 UTC-06:00")); //  2:50
console.log(f("09:42 UTC+05:45")); // 15:27
console.log(f("06:42 UTC+13:00")); // 19:42
console.log(f("02:40 UTC-10:00")); // 16:40
console.log(f("17:25 UTC+09:00")); //  2:25