答:
Logicode, 43 bytes

```<code>circ l(a)->1+l(a)
cond binp->out l(a)/out 0
</code>```

Logicode can't output while in an infinite circuit loop, so this program will output ALL of the 1's after the infinite loop (when the program encounters a 1).

If a truth machine that goes into an infinite loop when 1 is entered and has no output is acceptable, the code can be shorter by 2 bytes:

```<code>circ l(a)->1+l(a)
cond binp->out l(a)/out 0
</code>```

Title: Implement a Truth-Machine

Body:
Logicode, 43 bytes

circ l(a)->1+l(a)
cond binp->out l(a)/out 0

Logicode can't output while in an infinite circuit loop, so this program will output ALL of the 1's after the infinite loop (when the program encounters a 1).

If a truth machine that goes into an infinite loop when 1 is entered and has no output is acceptable, the code can be shorter by 2 bytes:

circ l(a)->1+l(a)
cond binp->out l(a)/out 0


问:
Close-Knit Words

Introduction

According to Rand Al'Thor's post in the Puzzling SE, a close-knit word is any word that contains three alphabetically consecutive letters (in any order).

Words like education, foghorn and cabaret are all considered close-knit words whereas words like learning, klaxon and perform are not close-knit words.

Challenge

The challenge is to code-golf a program capable of taking a single word as input (assumed lower case, for all intents and purposes) and to return output that (if available) lists all consecutive letter sets (also in lower case) if it is a close-knit word, and empty output if it is not a close-knit word.

Examples

```<code>Input: education
Output: cde

Input: foghorn
Output: fgh

Input: cabaret
Output: abc

Input: hijacking
Output: ghi, hij, ijk

Input: pneumonia
Output: mno, nop

Input: klaxon
Output: <<no output>>

Input: perform
Output: <<no output>>

Input: learning
Output: <<no output>>
</code>```

Rules

Whereas input is to be assumed to be a single lower-case word and output must be lower-case, the nature of the output will vary according to the choice of your coding language. Please select a form of output that will best suit the nature of the challenge, whether it be STDOUT, file output, array, etc.

Because this is code-golf, it will be a case of lowest number of bytes being the clear winner.

No silly loopholes.

I will not accept answers that have the consecutive letters in non-alphabetical order... So cab will not be deemed a suitable output for cabaret, for example.

Special note, while the "triplets" don't necessarily have to be in alphabetical order, but the characters within the triplets must be... so in the case of the word "performance", for example, the output mno,nop will be accepted, as will nop,mno. In the case of the word "hijacking", there are six ways that the triplets of ghi, hij and ijk could be arranged in a list, and all six permutations are acceptable as output.

Other than that, on your marks, get set, golf!

答:
Java 7, 230 bytes

```<code>String c(char[]q){java.util.Arrays.sort(q);char a[]=new String(q).replaceAll("(.)\\1","$1").toCharArray(),c=97,i=2;String r="",z="",s;for(;c<'z';z+=c++);while(i<a.length)if(z.contains(s=""+a[i-2]+a[i-1]+a[i++]))r+=s+" ";return r;}
</code>```

This can most likely be golfed, but the challenge was a lot tougher than I originally thought in Java..

Ungolfed & test cases:

Try it here.

```<code>class M{
  static String c(char[] q){
    java.util.Arrays.sort(q);
    char a[] = new String(q).replaceAll("(.)\\1", "$1").toCharArray(),
         c = 97,
         i = 2;
    String r = "",
           z = "",
           s;
    for(; c < 'z'; z += c++);
    while(i < a.length){
      if(z.contains(s = "" + a[i-2] + a[i-1] + a[i++])){
        r += s+" ";
      }
    }
    return r;
  }

  public static void main(String[] a){
    System.out.println(c("education".toCharArray()));
    System.out.println(c("foghorn".toCharArray()));
    System.out.println(c("cabaret".toCharArray()));
    System.out.println(c("hijacking".toCharArray()));
    System.out.println(c("pneumonia".toCharArray()));
    System.out.println(c("klaxon".toCharArray()));
    System.out.println(c("perform".toCharArray()));
    System.out.println(c("learning".toCharArray()));
    System.out.println(c("dblacghmeifjk".toCharArray()));
  }
}
</code>```

Output:

```<code>cde
fgh
abc
ghi hij ijk
mno nop

abc bcd cde def efg fgh ghi hij ijk jkl klm
</code>```

ContentLicense: CC BY-SA 3.0

Title: Close-Knit Words

Body:
Java 7, 230 bytes

String c(char[]q){java.util.Arrays.sort(q);char a[]=new String(q).replaceAll("(.)\\1","$1").toCharArray(),c=97,i=2;String r="",z="",s;for(;c<'z';z+=c++);while(i<a.length)if(z.contains(s=""+a[i-2]+a[i-1]+a[i++]))r+=s+" ";return r;}

This can most likely be golfed, but the challenge was a lot tougher than I originally thought in Java..

Ungolfed & test cases:

Try it here.

class M{
  static String c(char[] q){
    java.util.Arrays.sort(q);
    char a[] = new String(q).replaceAll("(.)\\1", "$1").toCharArray(),
         c = 97,
         i = 2;
    String r = "",
           z = "",
           s;
    for(; c < 'z'; z += c++);
    while(i < a.length){
      if(z.contains(s = "" + a[i-2] + a[i-1] + a[i++])){
        r += s+" ";
      }
    }
    return r;
  }

  public static void main(String[] a){
    System.out.println(c("education".toCharArray()));
    System.out.println(c("foghorn".toCharArray()));
    System.out.println(c("cabaret".toCharArray()));
    System.out.println(c("hijacking".toCharArray()));
    System.out.println(c("pneumonia".toCharArray()));
    System.out.println(c("klaxon".toCharArray()));
    System.out.println(c("perform".toCharArray()));
    System.out.println(c("learning".toCharArray()));
    System.out.println(c("dblacghmeifjk".toCharArray()));
  }
}

Output:

cde
fgh
abc
ghi hij ijk
mno nop

abc bcd cde def efg fgh ghi hij ijk jkl klm


问:
Pointers, pointers, pointers!

Introduction

In the error outputs of some languages such as Java, a pointer is shown to give the programmer an idea of exactly where the error went wrong.

Take this example on Ideone:

```<code>Main.java:12: error: ';' expected
    Invalid Java!
                ^
</code>```

Notice the caret shows where the invalid code is?

Challenge

Your challenge is: given number N and string S, place a pointer on the Nth character in S.

Examples

Input: 2, "Lorem ipsum, dollar sit amet."

Output:

```<code>Lorem ipsum, dollar sit amet.
 ^
</code>```

Rules

Input is received via STDIN or function parameters

Output is printed out to the console or returned

Trailing new lines, spaces etc are allowed in the output

The pointer character must be a ^ caret and must be on a new line.

This is code golf, so the shortest answer wins. Good luck!

答:
Straw, 13 bytes

```<code><#<>
> ,}*>^>
</code>```

Try it online!

^ is the only non-alphanumeric character (with \) to not be assigned to a command, so no need for a string literal to push it.

Title: Pointers, pointers, pointers!

Body:
Straw, 13 bytes

<#<>
> ,}*>^>

Try it online!

^ is the only non-alphanumeric character (with \) to not be assigned to a command, so no need for a string literal to push it.


问:
Calculate the sum of ILD

Input:

An integer

Output:

Sum of the input itself + the length of the input + each individual digit of the input.

```<code>nr + nr-length + {sum of digits} = output
</code>```

Examples:

Input: 99

Output: 99 (nr) + 2 (nr-length) + (9 + 9) (digits) → 119

Input: 123

Output: 123 + 3 + (1 + 2 + 3) → 132

Challenge rules:

The input can also contain negative input, which are resolved special. The -/minus-sign is also +1 for the length, and is part of the first digit.

For example:

Input: -123

Output: -123 + 4 + (-1 + 2 + 3) → -115

You can assume that the input nor output will ever be outside the range of an (32-bit) integer.

General rules:

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

Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.

Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.

Default Loopholes are forbidden.

If possible, please add a link with a test for your code.

Also, please add an explanation if necessary.

Test cases:

```<code>87901 → 87931
123 → 132
99 → 119
5 → 11
1 → 3
0 → 1
-3 → -4
-123 → -115
-900 → -905
-87901 → -87886
</code>```

Semi-related: Count Sum of all Digits

答:
Bash + coreutils, 36 bytes

bc<<<$1+${#1}+$(sed s:\\B:+:g<<<0$1)
```

<p><strong>Explanation:</strong></p>

<pre class="lang-sh prettyprint-override"><code>     $1+                      # the input number (+)
     ${#1}+                   # the length of the number, the '-' sign included (+)
     $(sed s:\\B:+:g<<<0$1)   # insert '+' between two consecutive word characters
                              #A word character is any letter, digit or underscore.
bc<<<                         # calculate the sum
</code>```

In sed, \B also matches between two consecutive non-word characters, so for a negative number it matches between '^' and '-'. Note the 0$1 trick needed for \B to give 0-1+2+3, for example.

Run example: 'input.txt' contains all the test cases in the question's statement

while read N;do echo "$N -> "$(./ILD_sum.sh "$N");done < input.txt
```

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

<pre class="lang-sh prettyprint-override"><code>87901 -> 87931
123 -> 132
99 -> 119
5 -> 11
1 -> 3
0 -> 1
-3 -> -4
-99 -> -96
-123 -> -115
-900 -> -905
-87901 -> -87886
</code>```

Title: Calculate the sum of ILD

Body:
Bash + coreutils, 36 bytes

bc<<<$1+${#1}+$(sed s:\\B:+:g<<<0$1)

Explanation:

     $1+                      # the input number (+)
     ${#1}+                   # the length of the number, the '-' sign included (+)
     $(sed s:\\B:+:g<<<0$1)   # insert '+' between two consecutive word characters
                              #A word character is any letter, digit or underscore.
bc<<<                         # calculate the sum

In sed, \B also matches between two consecutive non-word characters, so for a negative number it matches between '^' and '-'. Note the 0$1 trick needed for \B to give 0-1+2+3, for example.

Run example: 'input.txt' contains all the test cases in the question's statement

while read N;do echo "$N -> "$(./ILD_sum.sh "$N");done < input.txt

Output:

87901 -> 87931
123 -> 132
99 -> 119
5 -> 11
1 -> 3
0 -> 1
-3 -> -4
-99 -> -96
-123 -> -115
-900 -> -905
-87901 -> -87886


答:
Perl, 36 bytes

Includes +1 for -n

Give input on STDIN:

```<code>perl -nE 'join("",a..z)=~/[$_]{3}(?{say$&})^/' <<< "hijacking"
</code>```

Just the code:

```<code>join("",a..z)=~/[$_]{3}(?{say$&})^/
</code>```

Title: Close-Knit Words

Body:
Introduction

According to Rand Al'Thor's post in the Puzzling SE, a close-knit word is any word that contains three alphabetically consecutive letters (in any order).

Words like education, foghorn and cabaret are all considered close-knit words whereas words like learning, klaxon and perform are not close-knit words.

Challenge

The challenge is to code-golf a program capable of taking a single word as input (assumed lower case, for all intents and purposes) and to return output that (if available) lists all consecutive letter sets (also in lower case) if it is a close-knit word, and empty output if it is not a close-knit word.

Examples

```<code>Input: education
Output: cde

Input: foghorn
Output: fgh

Input: cabaret
Output: abc

Input: hijacking
Output: ghi, hij, ijk

Input: pneumonia
Output: mno, nop

Input: klaxon
Output: <<no output>>

Input: perform
Output: <<no output>>

Input: learning
Output: <<no output>>
</code>```

Rules

Whereas input is to be assumed to be a single lower-case word and output must be lower-case, the nature of the output will vary according to the choice of your coding language. Please select a form of output that will best suit the nature of the challenge, whether it be STDOUT, file output, array, etc.

Because this is code-golf, it will be a case of lowest number of bytes being the clear winner.

No silly loopholes.

I will not accept answers that have the consecutive letters in non-alphabetical order... So cab will not be deemed a suitable output for cabaret, for example.

Special note, while the "triplets" don't necessarily have to be in alphabetical order, but the characters within the triplets must be... so in the case of the word "performance", for example, the output mno,nop will be accepted, as will nop,mno. In the case of the word "hijacking", there are six ways that the triplets of ghi, hij and ijk could be arranged in a list, and all six permutations are acceptable as output.

Other than that, on your marks, get set, golf!

Body:
Perl, 36 bytes

Includes +1 for -n

Give input on STDIN:

perl -nE 'join("",a..z)=~/[$_]{3}(?{say$&})^/' <<< "hijacking"

Just the code:

join("",a..z)=~/[$_]{3}(?{say$&})^/


问:
Prime factors buddies
Given an integer N > 1, output all other numbers which prime decompositions have the same digits as the prime decomposition of N.

For example, if N = 117, then the output must be [279, 939, 993, 3313, 3331], because

```<code>117 = 3 × 3 × 13
</code>```

therefore, the available digits are 1, 3, 3 and 3 and we have

```<code>279  = 3 × 3 × 31
939  = 3 × 313
993  = 3 × 331
3313 = 3313
3331 = 3331
</code>```

Those are the only other possible numbers, because other combination of these digits yield non-prime integers, which can't be the result of prime factorization.

If N is any of 117, 279, 939, 993, 3313 or 3331, then the output will contain the five other numbers: they are prime factors buddies.

You cannot use leading zeroes to get primes, e.g. for N = 107, its only buddy is 701 (017 is not considered).

Input and Outputs

The input and output buddies must be taken and returned in the decimal base.

N will always be strictly greater than 1.

The output can be formatted rather freely, as long as it only contains the buddies and separators/list syntactic elements.

The ordering of the output is unimportant.

You may take the input through STDIN, as a function argument or anything similar.

You may print the output to STDOUT, return it from a function, or anything similar.

Test cases

Your program should solve any of the test cases below in less than a minute.

```<code>N        Buddies
2        []
4        []
8        []
15       [53]
16       []
23       [6]
42       [74, 146, 161]
126      [222, 438, 483, 674, 746, 851, 1466, 1631, 1679]
204      [364,548,692,762,782,852,868,1268,1626,2474,2654,2921,2951,3266,3446,3791,4274,4742,5426,5462,6233,6434,6542,7037,8561,14426,14642,15491,15833,22547]
</code>```

Scoring

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

答:
JavaScript (ES6), <s>163</s> 158 bytes

Edit: It has been clarified that a prime such as 23 should return [6] rather an empty result set. Saved 5 bytes by removing a now useless rule that was -- on purpose -- preventing that from happening.

The last test case is commented so that this snippet runs fast enough, although it should complete in less than one minute just as well.

let f =

n=>[...Array(+(l=(p=n=>{for(i=2,m=n,s='';i<=m;n%i?i++:(s+=i,n/=i));return s.split``.sort().reverse().join``})(n))+1)].map((_,i)=>i).filter(i=>i&&i-n&&p(i)==l)

console.log(JSON.stringify(f(2)));
console.log(JSON.stringify(f(4)));
console.log(JSON.stringify(f(8)));
console.log(JSON.stringify(f(15)));
console.log(JSON.stringify(f(16)));
console.log(JSON.stringify(f(23)));
console.log(JSON.stringify(f(42)));
console.log(JSON.stringify(f(126)));
//console.log(JSON.stringify(f(204)));```

Title: Prime factors buddies


问:
Words -> City Skyline

The challenge

Your program or function will accept a single string input from STDIN or a function parameter. You can assume the input will contain only alphabetic characters (a-zA-Z), spaces, and full stops. Input is case insensitive, so you should treat 'a' exactly the same as you would treat 'A'.

For each character in the string, you will output a representation of a building as per the following specification.

Each building must have a roof, designated by an underscore on the top line then a slash, space, backslash on the second line.

```<code> _
/ \
</code>```

You will then have a number of floors, matching the letter number (a=1, b=2, c=3 etc.) which are represented by a wall (|) on each side and a space in the middle. The bottom floor (and only the bottom floor) should have a foundation, which is an underscore between the walls. Like this...

```<code>|_|
</code>```

So for example, 'b' would look like this

```<code> _
/ \
| |
|_|
</code>```

Now, we know that very tall, narrow buildings cannot stand and must get wider at the base, so no building can stand more than three storeys high without some additional support. So every three levels (no less) you should add a 'widening layer'. The widening layer consists of a slash and backslash directly above the walls of the section below it, and the section below should be two spaces wider than the section above. The extra layer does not count towards the height of the building.

Buildings should not overlap but should not have any unnecessary spaces between them, and the ground is always flat so all buildings should have their base on the same level.

For example, 'abcdefga' will look like this.

```<code>                           _
                          / \
                     _    | |
                _   / \   | |
           _   / \  | |   | |
          / \  | |  | |  /   \
       _  | |  | |  | |  |   |
    _ / \ | |  | | /   \ |   |
 _ / \| | | | /   \|   | |   |  _
/ \| || |/   \|   ||   |/     \/ \
|_||_||_||___||___||___||_____||_|
</code>```

Spaces in the string input should be represented by a double space.

Full stops in the string input should be represented by rubble like this.

```<code>/\/\
</code>```

Further examples

Input = Hello world.

Output =

```<code>                                                   _
                                                  / \
                                                  | |
                                                  | |
                                                  | |
                                                 /   \
                                                 |   |
                                                 |   |                       _
                                                 |   |                      / \
                                                /     \                     | |
                                                |     |                     | |
                                   _            |     |          _          | |
                                  / \           |     |         / \        /   \
                                  | |          /       \        | |        |   |
                                  | |          |       |        | |        |   |
                _        _        | |          |       |        | |        |   |        _
               / \      / \      /   \         |       |       /   \      /     \      / \
               | |      | |      |   |        /         \      |   |      |     |      | |
               | |      | |      |   |        |         |      |   |      |     |      | |
               | |      | |      |   |        |         |      |   |      |     |      | |
   _          /   \    /   \    /     \       |         |     /     \    /       \    /   \
  / \         |   |    |   |    |     |      /           \    |     |    |       |    |   |
  | |         |   |    |   |    |     |      |           |    |     |    |       |    |   |
  | |         |   |    |   |    |     |      |           |    |     |    |       |    |   |
  | |    _   /     \  /     \  /       \     |           |   /       \  /         \  /     \
 /   \  / \  |     |  |     |  |       |    /             \  |       |  |         |  |     |   _
 |   |  | |  |     |  |     |  |       |    |             |  |       |  |         |  |     |  / \
 |   |  | |  |     |  |     |  |       |    |             |  |       |  |         |  |     |  | |
 |   |  | | /       \/       \/         \   |             | /         \/           \/       \ | |
/     \/   \|       ||       ||         |  /               \|         ||           ||       | | |
|     ||   ||       ||       ||         |  |               ||         ||           ||       |/   \
|_____||___||_______||_______||_________|  |_______________||_________||___________||_______||___|/\/\
</code>```

Input = lorem ipsum

```<code>                                                                                _
                                                                                / \
                                                                              _             | |
                                                                             / \            | |
                          _                                                  | |            | |
                         / \                                                 | |           /   \
                         | |                                    _            | |           |   |
                         | |                                   / \          /   \          |   |
              _          | |                                   | |          |   |          |   |
             / \        /   \                                  | |          |   |         /     \
             | |        |   |              _                   | |          |   |         |     |         _
             | |        |   |             / \                 /   \        /     \        |     |        / \
    _        | |        |   |             | |                 |   |        |     |        |     |        | |
   / \      /   \      /     \            | |                 |   |        |     |       /       \       | |
   | |      |   |      |     |            | |                 |   |        |     |       |       |       | |
   | |      |   |      |     |           /   \               /     \      /       \      |       |      /   \
   | |      |   |      |     |           |   |        _      |     |      |       |      |       |      |   |
  /   \    /     \    /       \          |   |       / \     |     |      |       |     /         \     |   |
  |   |    |     |    |       |          |   |       | |     |     |      |       |     |         |     |   |
  |   |    |     |    |       |         /     \      | |    /       \    /         \    |         |    /     \
  |   |    |     |    |       |         |     |      | |    |       |    |         |    |         |    |     |
 /     \  /       \  /         \   _    |     |     /   \   |       |    |         |   /           \   |     |
 |     |  |       |  |         |  / \   |     |     |   |   |       |    |         |   |           |   |     |
 |     |  |       |  |         |  | |  /       \    |   |  /         \  /           \  |           |  /       \
 |     |  |       |  |         |  | |  |       |    |   |  |         |  |           |  |           |  |       |
/       \/         \/           \ | |  |       |   /     \ |         |  |           | /             \ |       |
|       ||         ||           |/   \ |       |   |     | |         |  |           | |             | |       |
|       ||         ||           ||   |/         \  |     |/           \/             \|             |/         \
|_______||_________||___________||___||_________|  |_____||___________||_____________||_____________||_________|
</code>```

Input = a.a.a.x.x.x.a.a.a

```<code>                             _                    _                    _
                            / \                  / \                  / \
                            | |                  | |                  | |
                            | |                  | |                  | |
                            | |                  | |                  | |
                           /   \                /   \                /   \
                           |   |                |   |                |   |
                           |   |                |   |                |   |
                           |   |                |   |                |   |
                          /     \              /     \              /     \
                          |     |              |     |              |     |
                          |     |              |     |              |     |
                          |     |              |     |              |     |
                         /       \            /       \            /       \
                         |       |            |       |            |       |
                         |       |            |       |            |       |
                         |       |            |       |            |       |
                        /         \          /         \          /         \
                        |         |          |         |          |         |
                        |         |          |         |          |         |
                        |         |          |         |          |         |
                       /           \        /           \        /           \
                       |           |        |           |        |           |
                       |           |        |           |        |           |
                       |           |        |           |        |           |
                      /             \      /             \      /             \
                      |             |      |             |      |             |
                      |             |      |             |      |             |
                      |             |      |             |      |             |
                     /               \    /               \    /               \
 _      _      _     |               |    |               |    |               |     _      _      _
/ \    / \    / \    |               |    |               |    |               |    / \    / \    / \
|_|/\/\|_|/\/\|_|/\/\|_______________|/\/\|_______________|/\/\|_______________|/\/\|_|/\/\|_|/\/\|_|
</code>```

Rules

Of course this is code golf, lowest score in bytes wins

Standard loophole rules apply

Any number of additional blank lines before or after the output are allowed

You can choose to output the entire result in one string or offer the output as an array where each element represents one line of output, or send to STDOUT

Note

This is my first post to PPCG, so please go easy on me. It's been through the sandbox. Any negative points or possible improvements please post as a comment and I'll do what I can

答:
Pyth, <s>93</s> 79 bytes

```<code>K"/\\"j_.tsm?hJxGdC_m.[hyNk\ +\_mj*hy/k4?nkJ\ \_?%k4"||"Kh=+J=Nh/J3[F*2|@d;Krz0
</code>```

Try it online. Test suite.

Explanation

I hid this away by default since it's way too long.

Initialize K to "/\".

Lowercase (r…0) the input (z).

For each (m) character d in the lowercase input:

Find the index (x) of the character (d) in the alphabet (G). This results in a number 0-25 for the letters and -1 for anything else. Save the index to J.

Add one (h). This results in a positive number for the letters and 0 for anything else.

If the result was nonzero (?):

Int-divide (/) J by 3 and increment (h) and save (=) the result to N.

Increment (=+) J by that amount.

Add one (h). This yields the height of the house excluding the roof.

For each (m) number k from 0 to result-1:

Take " " (\ ) if (?) the number (k) is not equal to (n) J, otherwise take "_" (\_).

Int-divide (/) the number (k) by 4, double (y) and add one (h).

Multiply the string by the number (*).

Take "||" if (?) the number (k) is not divisible by 4 (%…4), otherwise take the string in K.

Join (j) that string by the previous one. This puts the previous string in the middle.

Prepend (+) a "_" (\_) to the resulting list to add the roof.

For each line k in the list:

Take N, double (y) and add one (h).

Pad (.[) the line (k) to that length with spaces (\ ).

We now have the rows for this one house. Reverse (_) and transpose (C) the result to get the reversed columns.

If the result was zero (all the way up there):

Take the intersection (@) of the character (d) and " " (;). This yields an empty string for periods and a space for itself.

Logical OR (|) that with the string in K. This yields that string for periods and a space for itself.

Repeat that string (*) 2 times and cast to array ([F). This yields the (reversed) columns for spaces and periods.

Concatenate (s) the resulting lists. This yields the total reversed columns for the output.

Transpose, padding with spaces (.t), reverse (_) and join by newline (j). Implicitly print the output.

```

Title: Words -> City Skyline

Body:
Pyth, <s>93</s> 79 bytes

K"/\\"j_.tsm?hJxGdC_m.[hyNk\ +\_mj*hy/k4?nkJ\ \_?%k4"||"Kh=+J=Nh/J3[F*2|@d;Krz0

Try it online. Test suite.

Explanation

I hid this away by default since it's way too long.

<ul type="disc"><li>Initialize <code>K</code> to <code>"/\"</code>.</li><li>Lowercase (<code>r</code>&hellip;<code>0</code>) the input (<code>z</code>).</li><li>For each (<code>m</code>) character <code>d</code> in the lowercase input:</li><ul type="disc"><li>Find the index (<code>x</code>) of the character (<code>d</code>) in the alphabet (<code>G</code>). This results in a number 0-25 for the letters and -1 for anything else. Save the index to <code>J</code>.</li><li>Add one (<code>h</code>). This results in a positive number for the letters and 0 for anything else.</li><li>If the result was nonzero (<code>?</code>):</li><ul type="disc"><li>Int-divide (<code>/</code>) <code>J</code> by <code>3</code> and increment (<code>h</code>) and save (<code>=</code>) the result to <code>N</code>.</li><li>Increment (<code>=+</code>) <code>J</code> by that amount.</li><li>Add one (<code>h</code>). This yields the height of the house excluding the roof.</li><li>For each (<code>m</code>) number <code>k</code> from 0 to result-1:</li><ul type="disc"><li>Take <code>" "</code> (<code>\ </code>) if (<code>?</code>) the number (<code>k</code>) is not equal to (<code>n</code>) <code>J</code>, otherwise take <code>"_"</code> (<code>\_</code>).</li><li>Int-divide (<code>/</code>) the number (<code>k</code>) by <code>4</code>, double (<code>y</code>) and add one (<code>h</code>).</li><li>Multiply the string by the number (<code>*</code>).</li><li>Take <code>"||"</code> if (<code>?</code>) the number (<code>k</code>) is not divisible by 4 (<code>%</code>&hellip;<code>4</code>), otherwise take the string in <code>K</code>.</li><li>Join (<code>j</code>) that string by the previous one. This puts the previous string in the middle.</li></ul><li>Prepend (<code>+</code>) a <code>"_"</code> (<code>\_</code>) to the resulting list to add the roof.</li><li>For each line <code>k</code> in the list:</li><ul type="disc"><li>Take <code>N</code>, double (<code>y</code>) and add one (<code>h</code>).</li><li>Pad (<code>.[</code>) the line (<code>k</code>) to that length with spaces (<code>\ </code>).</li></ul><li>We now have the rows for this one house. Reverse (<code>_</code>) and transpose (<code>C</code>) the result to get the reversed columns.</li></ul><li>If the result was zero (all the way up there):</li><ul type="disc"><li>Take the intersection (<code>@</code>) of the character (<code>d</code>) and <code>" "</code> (<code>;</code>). This yields an empty string for periods and a space for itself.</li><li>Logical OR (<code>|</code>) that with the string in <code>K</code>. This yields that string for periods and a space for itself.</li><li>Repeat that string (<code>*</code>) <code>2</code> times and cast to array (<code>[F</code>). This yields the (reversed) columns for spaces and periods.</li></ul></ul><li>Concatenate (<code>s</code>) the resulting lists. This yields the total reversed columns for the output.</li><li>Transpose, padding with spaces (<code>.t</code>), reverse (<code>_</code>) and join by newline (<code>j</code>). Implicitly print the output.</li></ul>


问:
Create a sudoku solution CHECKER

Create a Sudoku solution CHECKER

There are oodles of Sudoku SOLVERS here, but I want you to create a solution CHECKER as small as humanly possible (code-golf).

A valid entry will be able to either take a 9x9 array as an argument (passed by reference, serialized on the command line, or however you want to take it) or accept an input file that is nine lines of nine numbers for the final grid.  See examples of input below.

Valid input should be base-10 numbers (1-9)

Missing, empty, extra, non-numeric positions, or positions with numbers outside of 1-9 should be rejected as invalid input by returning a non-zero result, printing an error, or both.

Your program needs to test whether each number appears once per column, once per line, and once per 3x3 sub-grid.  If it passes, return "0" and if not, return a non-zero result.

Use of external resources (websites, etc.) is to be avoided.

If your solution is a stand-alone program, exiting with a exit status of, or printing, "0" or non-zero for "Pass" or "Fail", respectively, is ok.

Let the smallest answer win!

Input Examples:

c array:

```<code>int input[9][9]={{1,2,3,4,5,6,7,8,9},
                 {4,5,6,7,8,9,1,2,3},
                 {7,8,9,1,2,3,4,5,6},
                 {2,3,1,5,6,4,8,9,7},
                 {5,6,4,8,9,7,2,3,1},
                 {8,9,7,2,3,1,5,6,4},
                 {3,1,2,6,4,5,9,7,8},
                 {6,4,5,9,7,8,3,1,2},
                 {9,7,8,3,1,2,6,4,5}
                };
</code>```

file:

```<code>123456789
456789123
789123456
231564897
564897231
897231564
312645978
645978312
978312645
</code>```

The 9 sub-grids:

```<code>+---+---+---+
|123|456|789|
|456|789|123|
|789|123|456|
+---+---+---+
|231|564|897|
|564|897|231|
|897|231|564|
+---+---+---+
|312|645|978|
|645|978|312|
|978|312|645|
+---+---+---+
</code>```

答:
R, <s>63</s> 50 bytes

Assumes the input m is a 9x9 matrix of numbers.

```<code>all(apply(m,1,match,x=1:9),apply(m,2,match,x=1:9))
</code>```

I was right that further golfing was possible.

Explanation:

```<code>    apply(m,1,match,x=1:9),
</code>```

Take m, and for each row, apply the match function. We specify a further argument x=1:9 to be passed to match. x is the default first position argument, and therefore each row is placed in the second argument position, which is table. The function match looks for instances of x in
table. In this case, then, it's looking for 1:9 (the numbers 1 through 9) in each row. For each of 1:9, it will return TRUE (or FALSE) if that number is found (or not).

So, this yields a series of 81 boolean values.

```<code>                           apply(m,2,match,x=1:9)
</code>```

Repeat the above for each column of the input.

```<code>all(                                             )
</code>```

Finally, all checks if every element of the list of booleans is TRUE. This will be the case if and only if the solution is correct (i.e. each number 1:9 is present only once in each column and each row).

<s>Old approach:

```<code>for(i in 1:2)F=F+apply(m,i,function(x)sort(x)==1:9);sum(F)==162
</code>```

It takes each row, sorts it, and then compares it to [1, 2, ... 9]. A correct row should match exactly. Then it does the same for each column. In total, we should have 162 exact matches, which is what the final portion checks for. There is likely some scope for further golfing here...</s>

Title: Create a sudoku solution CHECKER

Body:
R, <s>63</s> 50 bytes

Assumes the input m is a 9x9 matrix of numbers.

all(apply(m,1,match,x=1:9),apply(m,2,match,x=1:9))

I was right that further golfing was possible.

Explanation:

    apply(m,1,match,x=1:9),

Take m, and for each row, apply the match function. We specify a further argument x=1:9 to be passed to match. x is the default first position argument, and therefore each row is placed in the second argument position, which is table. The function match looks for instances of x in
table. In this case, then, it's looking for 1:9 (the numbers 1 through 9) in each row. For each of 1:9, it will return TRUE (or FALSE) if that number is found (or not).

So, this yields a series of 81 boolean values.

                           apply(m,2,match,x=1:9)

Repeat the above for each column of the input.

all(                                             )

Finally, all checks if every element of the list of booleans is TRUE. This will be the case if and only if the solution is correct (i.e. each number 1:9 is present only once in each column and each row).

<s>Old approach:

for(i in 1:2)F=F+apply(m,i,function(x)sort(x)==1:9);sum(F)==162

It takes each row, sorts it, and then compares it to [1, 2, ... 9]. A correct row should match exactly. Then it does the same for each column. In total, we should have 162 exact matches, which is what the final portion checks for. There is likely some scope for further golfing here...</s>


问:
Make me a mooncake!
The mid-autumn festival has begun!

Unfortunately, all my mooncakes were stolen -- they're getting too expensive for small folk such as myself, and I fear I won't be able to eat any this year!

So I turn to you for help. Would you be able to make me some?

For those unaware, let me educate you on what a mooncake looks like.

Mooncakes come in many different sizes!

So I'm gonna give you my input, n, when I want one.

Here are some examples of the output I want:

Mooncake of size n = 3:

```<code>    (@@@@@)
    (@MAF@)
    (@@@@@)
</code>```

Mooncake of size n = 6:

```<code>    (@@@@@@@@@@@)
    (@         @)
    (@    M    @)
    (@    F    @)
    (@         @)
    (@@@@@@@@@@@)
</code>```

That is to say, a mooncake of size n is:

n lines high

2n - 1 @s long

2n + 1 characters long (@s and brackets)

And you better not throw me your too-tiny practice mooncakes!

Assume input will always be n >= 3.

Mooncakes also contain one of the following decorations:

MF

MAF

HMF

JCJ

TTT

ZJ

LF

RF

CF

Which one, it doesn't matter - as long as it is vertically and horizontally centered.

It can be written vertically or horizontally too!

I want variety!

If you're really going to make me two of the same mooncake, the decoration better be different!

That is, multiple executions of your program with the exact same input must not always yield the same decoration.

I can't wait to eat your moon cakes, so the sooner I can receive them (the shorter your code) the better!

Good Luck!

For those wondering about the decorations:

They are the initials of all alternative names for the Mid-Autumn Festival.

A list can be found in the Wikipedia page linked at the top of this post.

Clarifications:

There are no rules regarding leading and trailing whitespace.

Have as much or as little as you like!

The decorations must be in the very center of your mooncake!

On horizontal decorations, this means it must be on the middle line of your cake, and the number of characters to the left and right of the decoration string must be equal.

On vertical decorations, this means it must reside in the middle column of your cake, and the number of characters above and below the decoration must be equal.

Not all decorations must be used!

The only requirement is that there must be more than one possibility for any given input n. The possibilities also do not need to be even.

Functions are acceptable.

答:
C# 448 bytes

Golfed:

```<code>var v=n%2==0;int l=n+n-3,h=n-2,e=v?0:1,c=e+2;var c2=v?"MFZJLFRFCF":"MAFHMFJCJTTT";var r=new Random().Next(3+e);var f=new String(c2.Skip(c*r).Take(c).ToArray());var mc="";for (var i=0;i < h;i++) {var x="";if (!v && i==((h / 2))) { x=f;} else if (v && ((i==h / 2) || (i==(h/2)-1))) { x +=f[i%2==1?0:1];} var es=x.PadLeft((l/2)+1+e,' ').PadRight(l,' ');mc +="(@"+es+"@)\n";}var b="("+"".PadLeft(l+2, '@')+")";mc=b+"\n"+mc+ b; Console.WriteLine(mc);
</code>```

Test it here

Ungolfed:

```<code>        var v = n % 2 == 0;
        int l = n + n - 3, h = n - 2, e = v ? 0 : 1, c = e + 2;
        var c2 = v ? "MFZJLFRFCF" : "MAFHMFJCJTTT";
        var r = new Random().Next(3 + e);
        var f = new String(c2.Skip(c * r).Take(c).ToArray());
        var mc = "";
        for (var i = 0; i < h; i++)
        {
            var x = "";
            if (!v && i == ((h / 2)))
            {
                x = f;
            }
            else if (v && ((i == h / 2) || (i == (h / 2) - 1)))
            {
                x += f[i % 2 == 1 ? 0 : 1];
            }
            var emptySpace = x.PadLeft((l / 2) + 1 + e, ' ').PadRight(l, ' ');
            mc += "(@" + emptySpace + "@)\n";
        }
        var b = "(" + "".PadLeft(l + 2, '@') + ")";
        mc = b + "\n" + mc + b;
        Console.WriteLine(mc);
</code>```

Title: Make me a mooncake!

Body:
C# 448 bytes

Golfed:

var v=n%2==0;int l=n+n-3,h=n-2,e=v?0:1,c=e+2;var c2=v?"MFZJLFRFCF":"MAFHMFJCJTTT";var r=new Random().Next(3+e);var f=new String(c2.Skip(c*r).Take(c).ToArray());var mc="";for (var i=0;i < h;i++) {var x="";if (!v && i==((h / 2))) { x=f;} else if (v && ((i==h / 2) || (i==(h/2)-1))) { x +=f[i%2==1?0:1];} var es=x.PadLeft((l/2)+1+e,' ').PadRight(l,' ');mc +="(@"+es+"@)\n";}var b="("+"".PadLeft(l+2, '@')+")";mc=b+"\n"+mc+ b; Console.WriteLine(mc);

Test it here

Ungolfed:

        var v = n % 2 == 0;
        int l = n + n - 3, h = n - 2, e = v ? 0 : 1, c = e + 2;
        var c2 = v ? "MFZJLFRFCF" : "MAFHMFJCJTTT";
        var r = new Random().Next(3 + e);
        var f = new String(c2.Skip(c * r).Take(c).ToArray());
        var mc = "";
        for (var i = 0; i < h; i++)
        {
            var x = "";
            if (!v && i == ((h / 2)))
            {
                x = f;
            }
            else if (v && ((i == h / 2) || (i == (h / 2) - 1)))
            {
                x += f[i % 2 == 1 ? 0 : 1];
            }
            var emptySpace = x.PadLeft((l / 2) + 1 + e, ' ').PadRight(l, ' ');
            mc += "(@" + emptySpace + "@)\n";
        }
        var b = "(" + "".PadLeft(l + 2, '@') + ")";
        mc = b + "\n" + mc + b;
        Console.WriteLine(mc);


答:
C# 77 bytes

Check it here

Golfed:

```<code>int r(int n){return n+(n+"").Length+(n+"").Select(c=>int.Parse(c+"")).Sum();}
</code>```

Ungolfed:

```<code> public int r(int n)
 {
     var t = n + (n+"").Length;
     t += (n + "").Select(c => int.(c + "")).Sum();
     return t;
 }
</code>```

Title: Calculate the sum of ILD

Body:
Input:

An integer

Output:

Sum of the input itself + the length of the input + each individual digit of the input.

```<code>nr + nr-length + {sum of digits} = output
</code>```

Examples:

Input: 99

Output: 99 (nr) + 2 (nr-length) + (9 + 9) (digits) → 119

Input: 123

Output: 123 + 3 + (1 + 2 + 3) → 132

Challenge rules:

The input can also contain negative input, which are resolved special. The -/minus-sign is also +1 for the length, and is part of the first digit.

For example:

Input: -123

Output: -123 + 4 + (-1 + 2 + 3) → -115

You can assume that the input nor output will ever be outside the range of an (32-bit) integer.

General rules:

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

Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.

Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.

Default Loopholes are forbidden.

If possible, please add a link with a test for your code.

Also, please add an explanation if necessary.

Test cases:

```<code>87901 → 87931
123 → 132
99 → 119
5 → 11
1 → 3
0 → 1
-3 → -4
-123 → -115
-900 → -905
-87901 → -87886
</code>```

Semi-related: Count Sum of all Digits

Body:
C# 77 bytes

Check it here

Golfed:

int r(int n){return n+(n+"").Length+(n+"").Select(c=>int.Parse(c+"")).Sum();}

Ungolfed:

 public int r(int n)
 {
     var t = n + (n+"").Length;
     t += (n + "").Select(c => int.(c + "")).Sum();
     return t;
 }


答:
JavaScript (Firefox 48), 93 bytes

```<code>x=>[for(c of a=[...new Set(x,i=0)].sort())if(parseInt(d=c+a[++i]+a[i+1],36)%1333==38&!d[3])d]
</code>```

This lends itself to a 96-byte ES6 version:

```<code>x=>[...new Set(x)].sort().map((c,i,a)=>c+a[i+1]+a[i+2]).filter(x=>!x[3]&parseInt(x,36)%1333==38)
</code>```

How it works

The first major chunk of the function is this:

```<code>[...new Set(x)].sort()
</code>```

new Set(string) creates a Set object that contains one of each unique character in the string. For example, new Set("foghorn") will return Set ["f", "o", "g", "h", "r", "n"]. We can convert this into an array with [... ], then sort it with the built-in .sort(). This turns "foghorn" into ["f", "g", "h", "n", "o", "r"].

The next step is this:

```<code>.map((c,i,a)=>c+a[i+1]+a[i+2])
</code>```

This maps each character in the array to the character concatenated with the two items after it. For example, ["f", "g", "h", "n", "o", "r"] => ["fgh", "ghn", "hno", "nor", "orundefined", "rundefinedundefined"]. (The undefineds pop up when you try to access a non-existent member of the array.

The final step is filtering:

```<code>.filter(x=>!c[3]&parseInt(x,36)%1333==38)
</code>```

First, the !c[3]& is to rule out any strings that contain undefined. This is necessary because a bug causes the following algorithm to count e.g. gmundefined as a consecutive triplet.

All three-consecutive-char strings, when interpreted as base-36 numbers, are 38 modulo 1333. I figured this out by the following calculation:

012 (base 36) =   38

123 (base 36) = 1371

1371 - 38 = 1333

1371 mod 1333 ≡ 38 mod 1333 ≡ 38

Therefore, if a three-char string is 38 mod 1333 in base-36, the three characters are consecutive in the alphabet.

Test snippet

function test(x){O.innerHTML=/[^a-z]/.test(x)?"Invalid input":f(x);}
f=x=>[...new Set(x)].sort().map((c,i,a)=>c+a[i+1]+a[i+2]).filter(x=>!x[3]&parseInt(x,36)%1333==38)```
<pre class="snippet-code-html lang-html prettyprint-override"><code><input id=I value="hijacked">
<button onclick="test(I.value)">Run</button>
<pre id=O>cde,hij,ijk``````

Title: Close-Knit Words

Body:
JavaScript (Firefox 48), 93 bytes

x=>[for(c of a=[...new Set(x,i=0)].sort())if(parseInt(d=c+a[++i]+a[i+1],36)%1333==38&!d[3])d]

This lends itself to a 96-byte ES6 version:

x=>[...new Set(x)].sort().map((c,i,a)=>c+a[i+1]+a[i+2]).filter(x=>!x[3]&parseInt(x,36)%1333==38)

How it works

The first major chunk of the function is this:

[...new Set(x)].sort()

new Set(string) creates a Set object that contains one of each unique character in the string. For example, new Set("foghorn") will return Set ["f", "o", "g", "h", "r", "n"]. We can convert this into an array with [... ], then sort it with the built-in .sort(). This turns "foghorn" into ["f", "g", "h", "n", "o", "r"].

The next step is this:

.map((c,i,a)=>c+a[i+1]+a[i+2])

This maps each character in the array to the character concatenated with the two items after it. For example, ["f", "g", "h", "n", "o", "r"] => ["fgh", "ghn", "hno", "nor", "orundefined", "rundefinedundefined"]. (The undefineds pop up when you try to access a non-existent member of the array.

The final step is filtering:

.filter(x=>!c[3]&parseInt(x,36)%1333==38)

First, the !c[3]& is to rule out any strings that contain undefined. This is necessary because a bug causes the following algorithm to count e.g. gmundefined as a consecutive triplet.

All three-consecutive-char strings, when interpreted as base-36 numbers, are 38 modulo 1333. I figured this out by the following calculation:

012 (base 36) =   38

123 (base 36) = 1371

1371 - 38 = 1333

1371 mod 1333 ≡ 38 mod 1333 ≡ 38

Therefore, if a three-char string is 38 mod 1333 in base-36, the three characters are consecutive in the alphabet.

Test snippet

function test(x){O.innerHTML=/[^a-z]/.test(x)?"Invalid input":f(x);}
f=x=>[...new Set(x)].sort().map((c,i,a)=>c+a[i+1]+a[i+2]).filter(x=>!x[3]&parseInt(x,36)%1333==38)

<input id=I value="hijacked">
<button onclick="test(I.value)">Run</button>
<pre id=O>cde,hij,ijk</pre>


答:
PowerShell v2+, 93 bytes

```<code>param($n)97..120|%{-join[char[]]($_,++$_,++$_)}|?{(-join([char[]]$n|sort|select -u))-match$_}
</code>```

Feels much longer than required, but I can't seem to golf it any further.

Takes input $n. Loops from 97 to 120, constructing contiguous three-letter strings -- that is, up to the |?, we'll have abc, bcd, cde, etc. on the pipeline. Then that's fed through a Where-Object (the |?) to pull out only those items where the clause is true. Here, the clause is 1) the input string $n, cast as a char-array, sorted and select -unique'd, then -joined back into a string, 2) -matched against the three-letter strings (i.e., regex matching). If it's a match, then the three-letter string is in the word, and so it filters through the |?. The results are left on the pipeline and output is implicit.

Examples

(Note that here the output is space-separated, since we're stringifying the output by concatenation.)

```<code>PS C:\Tools\Scripts\golfing> 'education','foghorn','cabaret','hijacking','pneumonia','klaxon','perform','learning'|%{"$_ -> "+(.\close-knit-words.ps1 $_)}
education -> cde
foghorn -> fgh
cabaret -> abc
hijacking -> ghi hij ijk
pneumonia -> mno nop
klaxon ->
perform ->
learning ->
</code>```

Title: Close-Knit Words

Body:
PowerShell v2+, 93 bytes

param($n)97..120|%{-join[char[]]($_,++$_,++$_)}|?{(-join([char[]]$n|sort|select -u))-match$_}

Feels much longer than required, but I can't seem to golf it any further.

Takes input $n. Loops from 97 to 120, constructing contiguous three-letter strings -- that is, up to the |?, we'll have abc, bcd, cde, etc. on the pipeline. Then that's fed through a Where-Object (the |?) to pull out only those items where the clause is true. Here, the clause is 1) the input string $n, cast as a char-array, sorted and select -unique'd, then -joined back into a string, 2) -matched against the three-letter strings (i.e., regex matching). If it's a match, then the three-letter string is in the word, and so it filters through the |?. The results are left on the pipeline and output is implicit.

Examples

(Note that here the output is space-separated, since we're stringifying the output by concatenation.)

PS C:\Tools\Scripts\golfing> 'education','foghorn','cabaret','hijacking','pneumonia','klaxon','perform','learning'|%{"$_ -> "+(.\close-knit-words.ps1 $_)}
education -> cde
foghorn -> fgh
cabaret -> abc
hijacking -> ghi hij ijk
pneumonia -> mno nop
klaxon ->
perform ->
learning ->


问:
Connect the pixels
Given a text like this:

```<code># #### ## #
## #  ##  #
   ####  ##
</code>```

Output the same text but by connecting the pixels with the characters ─│┌┐└┘├┤┬┴┼. If a pixel doesn't have any neighbours, don't change it.

So the output of the last text is:

```<code>│ ─┬── ┌─ │
└─ │  ┌┘  │
   └──┘  ─┘
</code>```

You can take input as a boolean array.

The input will always contain at least 1 pixel.

You can count box-drawing chars as 1 byte.

You can assume the input is padded with spaces.

Test cases

```<code>## #
=>
── #
</code>```

```<code>###
 #
=>
─┬─
 │
</code>```

```<code>##### ##
 # #  #
########
=>
─┬─┬─ ┌─
 │ │  │
─┴─┴──┴─
</code>```

```<code> # #
#####
 # #
=>
 │ │
─┼─┼─
 │ │
</code>```

```<code># # # # #
 # # # #
# # # # #
 # # # #
# # # # #
=>
# # # # #
 # # # #
# # # # #
 # # # #
# # # # #
</code>```

```<code>#####
#####
#####
#####
#####
=>
┌┬┬┬┐
├┼┼┼┤
├┼┼┼┤
├┼┼┼┤
└┴┴┴┘
</code>```

Since this is code-golf, the shortest code wins.

答:
Python 3, 149 bytes

```<code>def f(s):S=' ';w=s.find('\n')+1;t=lambda i:(s+w*S)[i]>S;return[[c,'#│─┘─└─┴││┐┤┌├┬┼'[t(p-w)+2*t(p-1)+4*t(p+1)+8*t(p+w)]][c>S]for p,c in enumerate(s)]
</code>```

Takes input like ##\n #\n and returns output like ['─', '┐', '\n', ' ', '│', '\n'].

Title: Connect the pixels

Body:
Python 3, 149 bytes

def f(s):S=' ';w=s.find('\n')+1;t=lambda i:(s+w*S)[i]>S;return[[c,'#│─┘─└─┴││┐┤┌├┬┼'[t(p-w)+2*t(p-1)+4*t(p+1)+8*t(p+w)]][c>S]for p,c in enumerate(s)]

Takes input like ##\n #\n and returns output like ['─', '┐', '\n', ' ', '│', '\n'].


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

```<code>Ṅ⁶ṁ”^⁹¦
</code>```

Try it online!

That <s>dollar</s>dolor makes me laugh!!

Thanks to @Dennis for -1.

Title: Pointers, pointers, pointers!

Body:
Introduction

In the error outputs of some languages such as Java, a pointer is shown to give the programmer an idea of exactly where the error went wrong.

Take this example on Ideone:

```<code>Main.java:12: error: ';' expected
    Invalid Java!
                ^
</code>```

Notice the caret shows where the invalid code is?

Challenge

Your challenge is: given number N and string S, place a pointer on the Nth character in S.

Examples

Input: 2, "Lorem ipsum, dollar sit amet."

Output:

```<code>Lorem ipsum, dollar sit amet.
 ^
</code>```

Rules

Input is received via STDIN or function parameters

Output is printed out to the console or returned

Trailing new lines, spaces etc are allowed in the output

The pointer character must be a ^ caret and must be on a new line.

This is code golf, so the shortest answer wins. Good luck!

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

Ṅ⁶ṁ”^⁹¦

Try it online!

That <s>dollar</s>dolor makes me laugh!!

Thanks to @Dennis for -1.

ContentLicense: CC BY-SA 4.0


答:
Common Lisp, 40 35

```<code>(format t"~A
~VT^"(read)(1-(read)))
</code>```

-5 bytes thanks to PrzemysławP.

Title: Pointers, pointers, pointers!

Body:
Common Lisp, 40 35

(format t"~A
~VT^"(read)(1-(read)))

-5 bytes thanks to PrzemysławP.


问:
Print a 10 by 10 grid of asterisks

Background

This is a standard textbook example to demonstrate for loops.

This is one of the first programs I learnt when I started learning programming ~10 years ago.

Task

You are to print this exact text:

```<code>**********
**********
**********
**********
**********
**********
**********
**********
**********
**********
</code>```

Specs

You may have extra trailing newlines.

You may have extra trailing spaces (U+0020) at the end of each line, including the extra trailing newlines.

Scoring

This is code-golf. Shortest answer in bytes wins.

答:
Prolog (SWIPl), 64 / 69 bytes (depending on how to count)

```<code>-1*_.
A*0:-writeln(*),C is A-1,C*9.
A*B:-write(*),C is B-1, A*C.
</code>```

Query with

```<code>9*9.
</code>```

Online Example

Try it online, but take note that since writeln/1 has a bug in Swish, causing it to print a new line before as well as after. I've replaced it with write/1,nl/0 which should be (according to documentation) its equivalent. This raised the byte count of the example.

On the Byte Count

I'm not sure how to count the query, but if it is to be counted towards the total byte count, it's 5 bytes (including an Enter).

Title: Print a 10 by 10 grid of asterisks

Body:
Prolog (SWIPl), 64 / 69 bytes (depending on how to count)

-1*_.
A*0:-writeln(*),C is A-1,C*9.
A*B:-write(*),C is B-1, A*C.

Query with

9*9.

Online Example

Try it online, but take note that since writeln/1 has a bug in Swish, causing it to print a new line before as well as after. I've replaced it with write/1,nl/0 which should be (according to documentation) its equivalent. This raised the byte count of the example.

On the Byte Count

I'm not sure how to count the query, but if it is to be counted towards the total byte count, it's 5 bytes (including an Enter).


问:
Showcase of Languages

Notes

This thread is open and unlocked only because the community decided to make an exception. Please do not use this question as evidence that you can ask similar questions here. Please do not create additional showcase questions.

This is no longer a popularity-contest, nor are snippet lengths limited by the vote tally. If you know this thread from before, please make sure you familiarize yourself with the changes.

This thread is dedicated to showing off interesting, useful, obscure, and/or unique features your favorite programming languages have to offer. This is neither a challenge nor a competition, but a collaboration effort to showcase as many programming languages as possible as well as possible.

How this works

All answers should include the name of the programming language at the top of the post, prefixed by a #.

Answers may contain one (and only one) factoid, i.e., a couple of sentences without code that describe the language.

Aside from the factoid, answers should consist of snippets of code, which can (but don't have to be) programs or functions.

The snippets do not need to be related. In fact, snippets that are too related may be redundant.

Since this is not a contest, all programming languages are welcome, whenever they were created.

Answers that contain more than a handful of code snippets should use a Stack Snippet to collapse everything except the factoid and one of the snippets.

Whenever possible, there should be only one answer per programming language. This is a community wiki, so feel free to add snippets to any answer, even if you haven't created it yourself. There is a Stack Snippet for compressing posts, which should mitigate the effect of the 30,000 character limit.

Answers that predate these guidelines should be edited. Please help updating them as needed.

Current answers, sorted alphabetically by language name

$.ajax({type:"GET",url:"https://api.stackexchange.com/2.2/questions/44680/answers?site=codegolf&filter=withbody",success:function(data){for(var i=0;i<data.items.length;i++){var temp=document.createElement('p');temp.innerHTML = data.items[i].body.split("\n")[0];$('#list').append('
' + temp.innerText || temp.textContent + '');}}})```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><base href="http://codegolf.stackexchange.com"><ul id="list"></ul></code>```

答:
MiniStringFuck

MSF- is a way to compress the unique characters of any 0-255 ASCII string to just two characters; and it does pretty well! Although code might just be long.

Length 1 snippet

```<code>.
</code>```

Outputs 0x00.

Length 2 snippet

```<code>+.
</code>```

Outputs 0x01. This does not only demonstrate the . (output), but also the + (accumulator). + essentially changes the accumulator's value (acc) to (acc + 1) % 256.

Length 3 snippet

```<code>,+.
</code>```

It does not really output the next character; it's the same as above, because non-+. characters are ignored.

Length 4 snippet

```<code>+.+.
</code>```

Yay multiple chars!! This outputs \1\2 (escaped chars).

Length 5 snippet

```<code>+.+..
</code>```

This prints \1\2\2. Yes, we need too much upvotes yet to get to a reasonable program.

Length 6 snippet

```<code>+.+.+.
</code>```

Prints \1\2\3. Finally something that looks a little bit more interesting than just some random sequence of unprintables.

Title: Showcase of Languages

Body:
MiniStringFuck

MSF- is a way to compress the unique characters of any 0-255 ASCII string to just two characters; and it does pretty well! Although code might just be long.

Length 1 snippet

.

Outputs 0x00.

Length 2 snippet

+.

Outputs 0x01. This does not only demonstrate the . (output), but also the + (accumulator). + essentially changes the accumulator's value (acc) to (acc + 1) % 256.

Length 3 snippet

,+.

It does not really output the next character; it's the same as above, because non-+. characters are ignored.

Length 4 snippet

+.+.

Yay multiple chars!! This outputs \1\2 (escaped chars).

Length 5 snippet

+.+..

This prints \1\2\2. Yes, we need too much upvotes yet to get to a reasonable program.

Length 6 snippet

+.+.+.

Prints \1\2\3. Finally something that looks a little bit more interesting than just some random sequence of unprintables.


Title: Print this Multiplication Table

Body:
Write shortest code to print the following Multiplication Table:</p>

```<code>1×1=1
1×2=2  2×2=4
1×3=3  2×3=6  3×3=9
1×4=4  2×4=8  3×4=12 4×4=16
1×5=5  2×5=10 3×5=15 4×5=20 5×5=25
1×6=6  2×6=12 3×6=18 4×6=24 5×6=30 6×6=36
1×7=7  2×7=14 3×7=21 4×7=28 5×7=35 6×7=42 7×7=49
1×8=8  2×8=16 3×8=24 4×8=32 5×8=40 6×8=48 7×8=56 8×8=64
1×9=9  2×9=18 3×9=27 4×9=36 5×9=45 6×9=54 7×9=63 8×9=72 9×9=81
</code>```

Body:
C 79 bytes

i=1,j=1;f(){printf("%dx%d=%d ",j,i,i*j);++i>j?++j,i=1,j<=9?puts(""),f():0:f();}

the main

main(){f();}

the table

1x1=1
2x1=2 2x2=4
3x1=3 3x2=6 3x3=9
4x1=4 4x2=8 4x3=12 4x4=16
5x1=5 5x2=10 5x3=15 5x4=20 5x5=25
6x1=6 6x2=12 6x3=18 6x4=24 6x5=30 6x6=36
7x1=7 7x2=14 7x3=21 7x4=28 7x5=35 7x6=42 7x7=49
8x1=8 8x2=16 8x3=24 8x4=32 8x5=40 8x6=48 8x7=56 8x8=64
9x1=9 9x2=18 9x3=27 9x4=36 9x5=45 9x6=54 9x7=63 9x8=72 9x9=81


Title: Words -> City Skyline

Body:
The challenge

Your program or function will accept a single string input from STDIN or a function parameter. You can assume the input will contain only alphabetic characters (a-zA-Z), spaces, and full stops. Input is case insensitive, so you should treat 'a' exactly the same as you would treat 'A'.

For each character in the string, you will output a representation of a building as per the following specification.

Each building must have a roof, designated by an underscore on the top line then a slash, space, backslash on the second line.

```<code> _
/ \
</code>```

You will then have a number of floors, matching the letter number (a=1, b=2, c=3 etc.) which are represented by a wall (|) on each side and a space in the middle. The bottom floor (and only the bottom floor) should have a foundation, which is an underscore between the walls. Like this...

```<code>|_|
</code>```

So for example, 'b' would look like this

```<code> _
/ \
| |
|_|
</code>```

Now, we know that very tall, narrow buildings cannot stand and must get wider at the base, so no building can stand more than three storeys high without some additional support. So every three levels (no less) you should add a 'widening layer'. The widening layer consists of a slash and backslash directly above the walls of the section below it, and the section below should be two spaces wider than the section above. The extra layer does not count towards the height of the building.

Buildings should not overlap but should not have any unnecessary spaces between them, and the ground is always flat so all buildings should have their base on the same level.

For example, 'abcdefga' will look like this.

```<code>                           _
                          / \
                     _    | |
                _   / \   | |
           _   / \  | |   | |
          / \  | |  | |  /   \
       _  | |  | |  | |  |   |
    _ / \ | |  | | /   \ |   |
 _ / \| | | | /   \|   | |   |  _
/ \| || |/   \|   ||   |/     \/ \
|_||_||_||___||___||___||_____||_|
</code>```

Spaces in the string input should be represented by a double space.

Full stops in the string input should be represented by rubble like this.

```<code>/\/\
</code>```

Further examples

Input = Hello world.

Output =

```<code>                                                   _
                                                  / \
                                                  | |
                                                  | |
                                                  | |
                                                 /   \
                                                 |   |
                                                 |   |                       _
                                                 |   |                      / \
                                                /     \                     | |
                                                |     |                     | |
                                   _            |     |          _          | |
                                  / \           |     |         / \        /   \
                                  | |          /       \        | |        |   |
                                  | |          |       |        | |        |   |
                _        _        | |          |       |        | |        |   |        _
               / \      / \      /   \         |       |       /   \      /     \      / \
               | |      | |      |   |        /         \      |   |      |     |      | |
               | |      | |      |   |        |         |      |   |      |     |      | |
               | |      | |      |   |        |         |      |   |      |     |      | |
   _          /   \    /   \    /     \       |         |     /     \    /       \    /   \
  / \         |   |    |   |    |     |      /           \    |     |    |       |    |   |
  | |         |   |    |   |    |     |      |           |    |     |    |       |    |   |
  | |         |   |    |   |    |     |      |           |    |     |    |       |    |   |
  | |    _   /     \  /     \  /       \     |           |   /       \  /         \  /     \
 /   \  / \  |     |  |     |  |       |    /             \  |       |  |         |  |     |   _
 |   |  | |  |     |  |     |  |       |    |             |  |       |  |         |  |     |  / \
 |   |  | |  |     |  |     |  |       |    |             |  |       |  |         |  |     |  | |
 |   |  | | /       \/       \/         \   |             | /         \/           \/       \ | |
/     \/   \|       ||       ||         |  /               \|         ||           ||       | | |
|     ||   ||       ||       ||         |  |               ||         ||           ||       |/   \
|_____||___||_______||_______||_________|  |_______________||_________||___________||_______||___|/\/\
</code>```

Input = lorem ipsum

```<code>                                                                                _
                                                                                / \
                                                                              _             | |
                                                                             / \            | |
                          _                                                  | |            | |
                         / \                                                 | |           /   \
                         | |                                    _            | |           |   |
                         | |                                   / \          /   \          |   |
              _          | |                                   | |          |   |          |   |
             / \        /   \                                  | |          |   |         /     \
             | |        |   |              _                   | |          |   |         |     |         _
             | |        |   |             / \                 /   \        /     \        |     |        / \
    _        | |        |   |             | |                 |   |        |     |        |     |        | |
   / \      /   \      /     \            | |                 |   |        |     |       /       \       | |
   | |      |   |      |     |            | |                 |   |        |     |       |       |       | |
   | |      |   |      |     |           /   \               /     \      /       \      |       |      /   \
   | |      |   |      |     |           |   |        _      |     |      |       |      |       |      |   |
  /   \    /     \    /       \          |   |       / \     |     |      |       |     /         \     |   |
  |   |    |     |    |       |          |   |       | |     |     |      |       |     |         |     |   |
  |   |    |     |    |       |         /     \      | |    /       \    /         \    |         |    /     \
  |   |    |     |    |       |         |     |      | |    |       |    |         |    |         |    |     |
 /     \  /       \  /         \   _    |     |     /   \   |       |    |         |   /           \   |     |
 |     |  |       |  |         |  / \   |     |     |   |   |       |    |         |   |           |   |     |
 |     |  |       |  |         |  | |  /       \    |   |  /         \  /           \  |           |  /       \
 |     |  |       |  |         |  | |  |       |    |   |  |         |  |           |  |           |  |       |
/       \/         \/           \ | |  |       |   /     \ |         |  |           | /             \ |       |
|       ||         ||           |/   \ |       |   |     | |         |  |           | |             | |       |
|       ||         ||           ||   |/         \  |     |/           \/             \|             |/         \
|_______||_________||___________||___||_________|  |_____||___________||_____________||_____________||_________|
</code>```

Input = a.a.a.x.x.x.a.a.a

```<code>                             _                    _                    _
                            / \                  / \                  / \
                            | |                  | |                  | |
                            | |                  | |                  | |
                            | |                  | |                  | |
                           /   \                /   \                /   \
                           |   |                |   |                |   |
                           |   |                |   |                |   |
                           |   |                |   |                |   |
                          /     \              /     \              /     \
                          |     |              |     |              |     |
                          |     |              |     |              |     |
                          |     |              |     |              |     |
                         /       \            /       \            /       \
                         |       |            |       |            |       |
                         |       |            |       |            |       |
                         |       |            |       |            |       |
                        /         \          /         \          /         \
                        |         |          |         |          |         |
                        |         |          |         |          |         |
                        |         |          |         |          |         |
                       /           \        /           \        /           \
                       |           |        |           |        |           |
                       |           |        |           |        |           |
                       |           |        |           |        |           |
                      /             \      /             \      /             \
                      |             |      |             |      |             |
                      |             |      |             |      |             |
                      |             |      |             |      |             |
                     /               \    /               \    /               \
 _      _      _     |               |    |               |    |               |     _      _      _
/ \    / \    / \    |               |    |               |    |               |    / \    / \    / \
|_|/\/\|_|/\/\|_|/\/\|_______________|/\/\|_______________|/\/\|_______________|/\/\|_|/\/\|_|/\/\|_|
</code>```

Rules

Of course this is code golf, lowest score in bytes wins

Standard loophole rules apply

Any number of additional blank lines before or after the output are allowed

You can choose to output the entire result in one string or offer the output as an array where each element represents one line of output, or send to STDOUT

Note

This is my first post to PPCG, so please go easy on me. It's been through the sandbox. Any negative points or possible improvements please post as a comment and I'll do what I can

Body:
Haskell, 289 bytes

c?l=c++l++c
c%s=("|"?(drop 2(r s)>>c)):s
g 46=["/\\"?""]
g 32=["  "]
g x="_"%h(mod x 32)
h 1=["/ \\"," _ "]
h x=(" "%h(x-1))!x
v!x|mod x 3/=1=v|z<-'/':r v++"\\"=z:map(" "?)v
r v=v!!0>>" "
f t|l<-map(g.fromEnum)t,m<-maximum(map length l)-1=unlines[l>>= \x->(x++cycle[r x])!!i|i<-[m,m-1..0]]


Title: Calculate 6*9 in different bases

Body:
Output the following result (which is a result of calculating 6 * 9 in bases from 2 to 36). Make sure letters are uppercase, and the multiplication itself is outputed on every line.

```<code>6 * 9 = 110110
6 * 9 = 2000
6 * 9 = 312
6 * 9 = 204
6 * 9 = 130
6 * 9 = 105
6 * 9 = 66
6 * 9 = 60
6 * 9 = 54
6 * 9 = 4A
6 * 9 = 46
6 * 9 = 42
6 * 9 = 3C
6 * 9 = 39
6 * 9 = 36
6 * 9 = 33
6 * 9 = 30
6 * 9 = 2G
6 * 9 = 2E
6 * 9 = 2C
6 * 9 = 2A
6 * 9 = 28
6 * 9 = 26
6 * 9 = 24
6 * 9 = 22
6 * 9 = 20
6 * 9 = 1Q
6 * 9 = 1P
6 * 9 = 1O
6 * 9 = 1N
6 * 9 = 1M
6 * 9 = 1L
6 * 9 = 1K
6 * 9 = 1J
6 * 9 = 1I
</code>```

Shortest code wins.

Body:
///, 133 bytes

/R/6 * 9 = //S/
R/R110110S2000S312S204S130S105S66S60S54S4AS46S42S3CS39S36S33S30S2GS2ES2CS2AS28S26S24S22S20S1QS1PS1OS1NS1MS1LS1KS1JS1I

Try it online!


答:
Pyth, 17

```<code>LSjkPb-fqyTyQSs_y
</code>```

Test suite.

Uses the same observation as from Martin's post.

Expansion:

```<code>LSjkPb        ##  Define a function y(b) to get the sorted string of digits
              ##  of the prime factors of b
    Pb        ##  prime factors
  jk          ##  join to a string with no separator
 S            ##  Sort

-fqyTyQSs_yQQ ##  Auto-fill variables
         _yQ  ##  get reversed value of y(input)
       Ss     ##  convert that string to a list [1 ... y(input)]
 fqyTyQ       ##  keep numbers T from the list that satisfy y(T)==y(input)
-           Q ##  remove the input from the result
</code>```

Title: Prime factors buddies

Body:
Given an integer N > 1, output all other numbers which prime decompositions have the same digits as the prime decomposition of N.

For example, if N = 117, then the output must be [279, 939, 993, 3313, 3331], because

```<code>117 = 3 × 3 × 13
</code>```

therefore, the available digits are 1, 3, 3 and 3 and we have

```<code>279  = 3 × 3 × 31
939  = 3 × 313
993  = 3 × 331
3313 = 3313
3331 = 3331
</code>```

Those are the only other possible numbers, because other combination of these digits yield non-prime integers, which can't be the result of prime factorization.

If N is any of 117, 279, 939, 993, 3313 or 3331, then the output will contain the five other numbers: they are prime factors buddies.

You cannot use leading zeroes to get primes, e.g. for N = 107, its only buddy is 701 (017 is not considered).

Input and Outputs

The input and output buddies must be taken and returned in the decimal base.

N will always be strictly greater than 1.

The output can be formatted rather freely, as long as it only contains the buddies and separators/list syntactic elements.

The ordering of the output is unimportant.

You may take the input through STDIN, as a function argument or anything similar.

You may print the output to STDOUT, return it from a function, or anything similar.

Test cases

Your program should solve any of the test cases below in less than a minute.

```<code>N        Buddies
2        []
4        []
8        []
15       [53]
16       []
23       [6]
42       [74, 146, 161]
126      [222, 438, 483, 674, 746, 851, 1466, 1631, 1679]
204      [364,548,692,762,782,852,868,1268,1626,2474,2654,2921,2951,3266,3446,3791,4274,4742,5426,5462,6233,6434,6542,7037,8561,14426,14642,15491,15833,22547]
</code>```

Scoring

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

Body:
Pyth, 17

LSjkPb-fqyTyQSs_y

Test suite.

Uses the same observation as from Martin's post.

Expansion:

LSjkPb        ##  Define a function y(b) to get the sorted string of digits
              ##  of the prime factors of b
    Pb        ##  prime factors
  jk          ##  join to a string with no separator
 S            ##  Sort

-fqyTyQSs_yQQ ##  Auto-fill variables
         _yQ  ##  get reversed value of y(input)
       Ss     ##  convert that string to a list [1 ... y(input)]
 fqyTyQ       ##  keep numbers T from the list that satisfy y(T)==y(input)
-           Q ##  remove the input from the result


答:
T-SQL (SQL Server 2014), 217 bytes

Golfed

```<code>declare @ table(a char)declare @i int=1while @i<=len(@a)begin insert into @ values(SUBSTRING(@a,@i,1))set @i+=1 end select distinct t.a+u.a+v.a from @ t,@ u,@ v where ASCII(t.a)+1=ASCII(u.a)and ASCII(u.a)+1=ASCII(v.a)
</code>```

Usage

First declare the variable @a as a char of some sort and assign the input like so

```<code>declare @a varchar(max) = 'pneumoultramicroscopicsilicovolcanoconiosis'
</code>```

I didn't count the declare as part of my code, but I didn't find a sql standard for input, so I'm willing to change my counting

Output will either be one row for each triple, or no rows if the word is not close knit

Ungolfed

```<code>declare @temp table ( letter char(1) ) -- table to hold each letter of the word

declare @i int = 1

while @i <= len(@input) -- split each letter, and each row in @temp will have one letter
begin
    insert into @temp values (SUBSTRING(@input, @i, 1))
    set @i = @i + 1
end

-- join the letters table to itself to get three letter triples, where the three are in adjacent increasing order
-- use distinct because there might be duplicates in the word
select distinct t1.letter + t2.letter + t3.letter
from @temp t1
cross apply @temp t2
cross apply @temp t3
where ASCII(t1.letter) + 1 = ASCII(t2.letter)
and ASCII(t2.letter) + 1 = ASCII(t3.letter)
</code>```

Title: Close-Knit Words

Body:
Introduction

According to Rand Al'Thor's post in the Puzzling SE, a close-knit word is any word that contains three alphabetically consecutive letters (in any order).

Words like education, foghorn and cabaret are all considered close-knit words whereas words like learning, klaxon and perform are not close-knit words.

Challenge

The challenge is to code-golf a program capable of taking a single word as input (assumed lower case, for all intents and purposes) and to return output that (if available) lists all consecutive letter sets (also in lower case) if it is a close-knit word, and empty output if it is not a close-knit word.

Examples

```<code>Input: education
Output: cde

Input: foghorn
Output: fgh

Input: cabaret
Output: abc

Input: hijacking
Output: ghi, hij, ijk

Input: pneumonia
Output: mno, nop

Input: klaxon
Output: <<no output>>

Input: perform
Output: <<no output>>

Input: learning
Output: <<no output>>
</code>```

Rules

Whereas input is to be assumed to be a single lower-case word and output must be lower-case, the nature of the output will vary according to the choice of your coding language. Please select a form of output that will best suit the nature of the challenge, whether it be STDOUT, file output, array, etc.

Because this is code-golf, it will be a case of lowest number of bytes being the clear winner.

No silly loopholes.

I will not accept answers that have the consecutive letters in non-alphabetical order... So cab will not be deemed a suitable output for cabaret, for example.

Special note, while the "triplets" don't necessarily have to be in alphabetical order, but the characters within the triplets must be... so in the case of the word "performance", for example, the output mno,nop will be accepted, as will nop,mno. In the case of the word "hijacking", there are six ways that the triplets of ghi, hij and ijk could be arranged in a list, and all six permutations are acceptable as output.

Other than that, on your marks, get set, golf!

Body:
T-SQL (SQL Server 2014), 217 bytes

Golfed

declare @ table(a char)declare @i int=1while @i<=len(@a)begin insert into @ values(SUBSTRING(@a,@i,1))set @i+=1 end select distinct t.a+u.a+v.a from @ t,@ u,@ v where ASCII(t.a)+1=ASCII(u.a)and ASCII(u.a)+1=ASCII(v.a)

Usage

First declare the variable @a as a char of some sort and assign the input like so

declare @a varchar(max) = 'pneumoultramicroscopicsilicovolcanoconiosis'

I didn't count the declare as part of my code, but I didn't find a sql standard for input, so I'm willing to change my counting

Output will either be one row for each triple, or no rows if the word is not close knit

Ungolfed

declare @temp table ( letter char(1) ) -- table to hold each letter of the word

declare @i int = 1

while @i <= len(@input) -- split each letter, and each row in @temp will have one letter
begin
    insert into @temp values (SUBSTRING(@input, @i, 1))
    set @i = @i + 1
end

-- join the letters table to itself to get three letter triples, where the three are in adjacent increasing order
-- use distinct because there might be duplicates in the word
select distinct t1.letter + t2.letter + t3.letter
from @temp t1
cross apply @temp t2
cross apply @temp t3
where ASCII(t1.letter) + 1 = ASCII(t2.letter)
and ASCII(t2.letter) + 1 = ASCII(t3.letter)


Title: Print this Multiplication Table

Body:
C 95 bytes

i=1,j=1;f(){printf("%dx%d=%d %c",j,i,i*j,i!=2||j>4?:32);++i>j?++j,i=1,j<=9?puts(""),f():0:f();}

they want this table:

1x1=1
2x1=2 2x2=4
3x1=3 3x2=6  3x3=9
4x1=4 4x2=8  4x3=12 4x4=16
5x1=5 5x2=10 5x3=15 5x4=20 5x5=25
6x1=6 6x2=12 6x3=18 6x4=24 6x5=30 6x6=36
7x1=7 7x2=14 7x3=21 7x4=28 7x5=35 7x6=42 7x7=49
8x1=8 8x2=16 8x3=24 8x4=32 8x5=40 8x6=48 8x7=56 8x8=64
9x1=9 9x2=18 9x3=27 9x4=36 9x5=45 9x6=54 9x7=63 9x8=72 9x9=81


答:
Jelly, <s>60</s> <s>52</s> <s>51</s> <s>50</s> <s>49</s> 48 bytes

```<code>ṖḤ0;+Ḋ×
“µ³Q~E!G⁸ṗṫ\’ḃ61+9471Ọ⁾# j
ZÑ€4×Z++Ñ€ị¢Y
</code>```

Saved a byte thanks to @Dennis.

The input is a boolean array of 1's and 0's. Iterates over each column and each row converting the head and tail of each infix of size 3 from a pair of binary digits to a decimal, and multiplies that with the center of each infix. Then it sums it with itself to find the index into '#───│┌┐┬│└┘┴│├┤┼ '.

Try it online! (case 2) (case 3) (case 4)

Explanation

This relies on the same idea as my answer in J but instead of processing on each 3x3 subarray, I process over each row and each column while still obtaining the same table of indices.

Over half of the bytes are spent generating the list of box characters '#───│┌┐┬│└┘┴│├┤┼ '. String literals start with “ in Jelly and have different meanings depending on their terminator. Here the terminator ’ means that the string will be parsed as the code points of each character according to the Jelly code page, and convert from a list of base 250 digits to a decimal.

```<code>“µ³Q~E!G⁸ṗṫ\’ => 10041542192416299030874093
(bijective base 61) => [1, 1, 1, 3, 13, 17, 45, 3, 21, 25, 53, 3, 29, 37, 61]
(add 9471 and convert to char) => '───│┌┐┬│└┘┴│├┤┼'
</code>```

Then convert that decimal to a list of digits in bijective base 61 and increment each by 9471 to move it into the range of the box characters and convert each using Python's chr. Then prepend it with a character literal ”# and append a space ⁶.

```<code>ṖḤ0;+Ḋ×  Helper link - Input: 1d list A
Ṗ        Get all of A except the last value
 Ḥ       Double each value in it
  0;     Prepend a 0
    +    Add elementwise with
     Ḋ     All of A except the first value
      ×  Multiply elementwise by A

“µ³Q~E!G⁸ṗṫ\’ḃ61+9471Ọ⁾# j  Nilad. Represents '#───│┌┐┬│└┘┴│├┤┼ '
“µ³Q~E!G⁸ṗṫ\’               Get the code points of each char in the string and
                            convert from a list of base 250 digits to decimal
             ḃ61            Convert that to a list of digits in bijective base 61
                +9471       Add 9400 to each
                     Ọ      Convert from ordinals to chars, gets '───│┌┐┬│└┘┴│├┤┼'
                      ⁾#    A pair of chars ['#', ' ']
                         j  Join the pair using the box characters

ZÑ€4×Z++Ñ€ị¢Y  Input: 2d list M
Z              Transpose
 Ñ€            Apply the helper link to each row of the transpose (each column of M)
   4×          Multiply each by 4
     Z         Transpose
      +        Add elementwise with M
       +       Add elementwise with
        Ñ€       The helper link applied to each row of M
          ị¢   Use each result as an index to select into the nilad
            Y  Join using newlines
               Return and print implicitly
</code>```

Title: Connect the pixels

Body:
Given a text like this:

```<code># #### ## #
## #  ##  #
   ####  ##
</code>```

Output the same text but by connecting the pixels with the characters ─│┌┐└┘├┤┬┴┼. If a pixel doesn't have any neighbours, don't change it.

So the output of the last text is:

```<code>│ ─┬── ┌─ │
└─ │  ┌┘  │
   └──┘  ─┘
</code>```

You can take input as a boolean array.

The input will always contain at least 1 pixel.

You can count box-drawing chars as 1 byte.

You can assume the input is padded with spaces.

Test cases

```<code>## #
=>
── #
</code>```

```<code>###
 #
=>
─┬─
 │
</code>```

```<code>##### ##
 # #  #
########
=>
─┬─┬─ ┌─
 │ │  │
─┴─┴──┴─
</code>```

```<code> # #
#####
 # #
=>
 │ │
─┼─┼─
 │ │
</code>```

```<code># # # # #
 # # # #
# # # # #
 # # # #
# # # # #
=>
# # # # #
 # # # #
# # # # #
 # # # #
# # # # #
</code>```

```<code>#####
#####
#####
#####
#####
=>
┌┬┬┬┐
├┼┼┼┤
├┼┼┼┤
├┼┼┼┤
└┴┴┴┘
</code>```

Since this is code-golf, the shortest code wins.

Body:
Jelly, <s>60</s> <s>52</s> <s>51</s> <s>50</s> <s>49</s> 48 bytes

ṖḤ0;+Ḋ×
“µ³Q~E!G⁸ṗṫ\’ḃ61+9471Ọ⁾# j
ZÑ€4×Z++Ñ€ị¢Y

Saved a byte thanks to @Dennis.

The input is a boolean array of 1's and 0's. Iterates over each column and each row converting the head and tail of each infix of size 3 from a pair of binary digits to a decimal, and multiplies that with the center of each infix. Then it sums it with itself to find the index into '#───│┌┐┬│└┘┴│├┤┼ '.

Try it online! (case 2) (case 3) (case 4)

Explanation

This relies on the same idea as my answer in J but instead of processing on each 3x3 subarray, I process over each row and each column while still obtaining the same table of indices.

Over half of the bytes are spent generating the list of box characters '#───│┌┐┬│└┘┴│├┤┼ '. String literals start with “ in Jelly and have different meanings depending on their terminator. Here the terminator ’ means that the string will be parsed as the code points of each character according to the Jelly code page, and convert from a list of base 250 digits to a decimal.

“µ³Q~E!G⁸ṗṫ\’ => 10041542192416299030874093
(bijective base 61) => [1, 1, 1, 3, 13, 17, 45, 3, 21, 25, 53, 3, 29, 37, 61]
(add 9471 and convert to char) => '───│┌┐┬│└┘┴│├┤┼'

Then convert that decimal to a list of digits in bijective base 61 and increment each by 9471 to move it into the range of the box characters and convert each using Python's chr. Then prepend it with a character literal ”# and append a space ⁶.

ṖḤ0;+Ḋ×  Helper link - Input: 1d list A
Ṗ        Get all of A except the last value
 Ḥ       Double each value in it
  0;     Prepend a 0
    +    Add elementwise with
     Ḋ     All of A except the first value
      ×  Multiply elementwise by A

“µ³Q~E!G⁸ṗṫ\’ḃ61+9471Ọ⁾# j  Nilad. Represents '#───│┌┐┬│└┘┴│├┤┼ '
“µ³Q~E!G⁸ṗṫ\’               Get the code points of each char in the string and
                            convert from a list of base 250 digits to decimal
             ḃ61            Convert that to a list of digits in bijective base 61
                +9471       Add 9400 to each
                     Ọ      Convert from ordinals to chars, gets '───│┌┐┬│└┘┴│├┤┼'
                      ⁾#    A pair of chars ['#', ' ']
                         j  Join the pair using the box characters

ZÑ€4×Z++Ñ€ị¢Y  Input: 2d list M
Z              Transpose
 Ñ€            Apply the helper link to each row of the transpose (each column of M)
   4×          Multiply each by 4
     Z         Transpose
      +        Add elementwise with M
       +       Add elementwise with
        Ñ€       The helper link applied to each row of M
          ị¢   Use each result as an index to select into the nilad
            Y  Join using newlines
               Return and print implicitly


Title: Pointers, pointers, pointers!

Body:
Introduction

In the error outputs of some languages such as Java, a pointer is shown to give the programmer an idea of exactly where the error went wrong.

Take this example on Ideone:

```<code>Main.java:12: error: ';' expected
    Invalid Java!
                ^
</code>```

Notice the caret shows where the invalid code is?

Challenge

Your challenge is: given number N and string S, place a pointer on the Nth character in S.

Examples

Input: 2, "Lorem ipsum, dollar sit amet."

Output:

```<code>Lorem ipsum, dollar sit amet.
 ^
</code>```

Rules

Input is received via STDIN or function parameters

Output is printed out to the console or returned

Trailing new lines, spaces etc are allowed in the output

The pointer character must be a ^ caret and must be on a new line.

This is code golf, so the shortest answer wins. Good luck!

Body:
Haskell, 30 bytes

s!n=s++'\n':([1..n]>>" ")++"^"


Title: Connect the pixels

Body:
R, <s>199</s> 212 bytes

EDIT: It's now a function, rather than a code snippet.

The input is a matrix m of 1s and 0s. This is pretty ugly and hacky.

function(m){
v=strsplit(" #─│┘│┐│┤──└┴┌┬├┼","")[[1]]
d=dim(m)+1
n=array(0,dim=d+1)
n[2:d[1],2:d[2]]=m
for(i in 0:(d[1]-2)){for(j in 0:(d[2]-2))cat(v[1+(p<-n[2+i,2+j])*sum(2^(0:3)*n[1:3+i,1:3+j][1:4*2])+p]);cat("\n")}
}

A couple of tests:

> m = matrix(c(1, 1, 1, 0, 1, 0), nrow=2, byrow=TRUE)
> v=strsplit(" #─│┘│┐│┤──└┴┌┬├┼","")[[1]]
> d=dim(m)+1
> n=array(0,dim=d+1)
> n[2:d[1],2:d[2]]=m
> for(i in 0:(d[1]-2)){for(j in 0:(d[2]-2))cat(v[1+(p<-n[2+i,2+j])*sum(2^(0:3)*n[1:3+i,1:3+j][1:4*2])+p]);cat("\n")}
─┬─
 │
> m = matrix(rep(1, 16), ncol=4)
> v=strsplit(" #─│┘│┐│┤──└┴┌┬├┼","")[[1]]
> d=dim(m)+1
> n=array(0,dim=d+1)
> n[2:d[1],2:d[2]]=m
> for(i in 0:(d[1]-2)){for(j in 0:(d[2]-2))cat(v[1+(p<-n[2+i,2+j])*sum(2^(0:3)*n[1:3+i,1:3+j][1:4*2])+p]);cat("\n")}
┌┬┬┐
├┼┼┤
├┼┼┤
└┴┴┘


答:
SpecBAS - 48 bytes

```<code>1 FOR i=2 TO 36: ?"6 * 9 = ";BASE$(54,i): NEXT i
</code>```

SpecBAS is actually quite competitive for a change :-)

Title: Calculate 6*9 in different bases

Body:
SpecBAS - 48 bytes

1 FOR i=2 TO 36: ?"6 * 9 = ";BASE$(54,i): NEXT i

SpecBAS is actually quite competitive for a change :-)


答:
Julia (236 Bytes, potentially 63) - Could use help.

```<code>A=[1 2 3 4 5 6 7 8 9; 1 2 3 4 5 6 7 8 9; 1 2 3 4 5 6 7 8 9; 1 2 3 4 5 6 7 8 9; 1 2 3 4 5 6 7 8 9; 1 2 3 4 5 6 7 8 9; 1 2 3 4 5 6 7 8 9; 1 2 3 4 5 6 7 8 9;1 2 3 4 5 6 7 8 9]
map(x->x>0?print(x,"x",x,"=",x*x,"\t"):println(),triu!(A'))
</code>```

Someone put in the comments "Who's going to do anything but use 2 loops?"

This guy is!

I don't know how to instantiate matrices easily in Julia, anyone who could help me do the instantiation of the matrix better I will be grateful. I can only get it to make a 2D array, and triu doesn't work on that.

How it works:

A = [...] creates a 9x9 matrix with 1-9 in each vector (someone please teach me to do this right without accidentally creating a 2D array... I want to learn this language better, but I'm confused on the typing differences and a lot of the documentation is pretty terse for matrices.

triu!(A') takes the inverse of the upper triangle of the matrix.

map(x->x?0...:...,A) mapping function that differentiates on x=0, printing a newline when needed.

Output:

```<code>1×1=1
1×2=2  2×2=4
1×3=3  2×3=6  3×3=9
1×4=4  2×4=8  3×4=12 4×4=16
1×5=5  2×5=10 3×5=15 4×5=20 5×5=25
1×6=6  2×6=12 3×6=18 4×6=24 5×6=30 6×6=36
1×7=7  2×7=14 3×7=21 4×7=28 5×7=35 6×7=42 7×7=49
1×8=8  2×8=16 3×8=24 4×8=32 5×8=40 6×8=48 7×8=56 8×8=64
1×9=9  2×9=18 3×9=27 4×9=36 5×9=45 6×9=54 7×9=63 8×9=72 9×9=81
</code>```

Title: Print this Multiplication Table

Body:
Write shortest code to print the following Multiplication Table:</p>

```<code>1×1=1
1×2=2  2×2=4
1×3=3  2×3=6  3×3=9
1×4=4  2×4=8  3×4=12 4×4=16
1×5=5  2×5=10 3×5=15 4×5=20 5×5=25
1×6=6  2×6=12 3×6=18 4×6=24 5×6=30 6×6=36
1×7=7  2×7=14 3×7=21 4×7=28 5×7=35 6×7=42 7×7=49
1×8=8  2×8=16 3×8=24 4×8=32 5×8=40 6×8=48 7×8=56 8×8=64
1×9=9  2×9=18 3×9=27 4×9=36 5×9=45 6×9=54 7×9=63 8×9=72 9×9=81
</code>```

Body:
Julia (236 Bytes, potentially 63) - Could use help.

A=[1 2 3 4 5 6 7 8 9; 1 2 3 4 5 6 7 8 9; 1 2 3 4 5 6 7 8 9; 1 2 3 4 5 6 7 8 9; 1 2 3 4 5 6 7 8 9; 1 2 3 4 5 6 7 8 9; 1 2 3 4 5 6 7 8 9; 1 2 3 4 5 6 7 8 9;1 2 3 4 5 6 7 8 9]
map(x->x>0?print(x,"x",x,"=",x*x,"\t"):println(),triu!(A'))

Someone put in the comments "Who's going to do anything but use 2 loops?"

This guy is!

I don't know how to instantiate matrices easily in Julia, anyone who could help me do the instantiation of the matrix better I will be grateful. I can only get it to make a 2D array, and triu doesn't work on that.

How it works:

A = [...] creates a 9x9 matrix with 1-9 in each vector (someone please teach me to do this right without accidentally creating a 2D array... I want to learn this language better, but I'm confused on the typing differences and a lot of the documentation is pretty terse for matrices.

triu!(A') takes the inverse of the upper triangle of the matrix.

map(x->x?0...:...,A) mapping function that differentiates on x=0, printing a newline when needed.

Output:

1×1=1
1×2=2  2×2=4
1×3=3  2×3=6  3×3=9
1×4=4  2×4=8  3×4=12 4×4=16
1×5=5  2×5=10 3×5=15 4×5=20 5×5=25
1×6=6  2×6=12 3×6=18 4×6=24 5×6=30 6×6=36
1×7=7  2×7=14 3×7=21 4×7=28 5×7=35 6×7=42 7×7=49
1×8=8  2×8=16 3×8=24 4×8=32 5×8=40 6×8=48 7×8=56 8×8=64
1×9=9  2×9=18 3×9=27 4×9=36 5×9=45 6×9=54 7×9=63 8×9=72 9×9=81


问:
Count even steps of 196 algorithm
In the 196-algorithm one starts from an integer and then adds its reverse to it until a palindrome is reached, like this:

```<code>start -> 5280
5280 + 0825 = 6105
6105 + 5016 = 11121
11121 + 12111 = 23232
-end-
</code>```

Write a function that counts how many even numbers are visited before the algorithm ends. Starting and ending numbers are also counted, so, in the example above, visited are consider the numbers: 5280, 6105, 11121, 23232 but not 825, 5016 and 12111.

Examples:

```<code>f(5280) = 2
f(56) = 1
f(59) = 1
f(89) = 13
</code>```

Extended code golf rules apply: shortest number of instructions and operations (like +,-,mod,print,while,if,...) wins.

答:
D: 154 Characters, 22 Instructions

```<code>alias long l;alias string s;l f(l n){l t=!(n&1);auto u=to!s(n);while(u!=to!s(retro(u))){n=to!l(u)+to!l(to!s(retro(u)));if(!(n&1))++t;u=to!s(n);}return t;}
</code>```

More Legibly:

```<code>alias long l;
alias string s;

l f(l n)
{
    l t = !(n & 1);  //3 instructions
    auto u = to!s(n);  //2 instructions

    while(u != to!s(retro(u)))  //4 instructions
    {
        n = to!l(u) + to!l(to!s(retro(u)));  //6 instructions

        if(!(n & 1))  //3 instructions
            ++t;  //1 instruction

        u = to!s(n);  //2 instructions
    }

    return t;  //1 instruction
}
</code>```

I'm not sure that counted instructions quite right, since that's a bit debatable, and of course, there are lots of instructions going on in the functions which get called. So, ultimately, I'm not sure how reasonable or accurate counting instructions is, but I think that 22 is the total.

Title: Count even steps of 196 algorithm

Body:
D: 154 Characters, 22 Instructions

alias long l;alias string s;l f(l n){l t=!(n&1);auto u=to!s(n);while(u!=to!s(retro(u))){n=to!l(u)+to!l(to!s(retro(u)));if(!(n&1))++t;u=to!s(n);}return t;}

More Legibly:

alias long l;
alias string s;

l f(l n)
{
    l t = !(n & 1);  //3 instructions
    auto u = to!s(n);  //2 instructions

    while(u != to!s(retro(u)))  //4 instructions
    {
        n = to!l(u) + to!l(to!s(retro(u)));  //6 instructions

        if(!(n & 1))  //3 instructions
            ++t;  //1 instruction

        u = to!s(n);  //2 instructions
    }

    return t;  //1 instruction
}

I'm not sure that counted instructions quite right, since that's a bit debatable, and of course, there are lots of instructions going on in the functions which get called. So, ultimately, I'm not sure how reasonable or accurate counting instructions is, but I think that 22 is the total.

ContentLicense: CC BY-SA 2.5


答:
R, 220 bytes

My solution is pretty straightforward. It loops through the possible three letter combinations, loops through and checks the characters of the entered string against the three consecutive letters, and adds them to a string. The string is then only printed when three letters are found (c==4).

```<code>f<-function(w){if(nchar(w)>2){for(i in 1:24){
c<-1
t<-""
for(k in 1:3){for(j in 1:nchar(w)){if(substr(w,j,j)==intToUtf8(95+k+i)&c<4){
t<-paste(t,substr(w,j,j),sep="")
c<-c+1
break
}}}
if(c==4){print(paste(t))}}}}
</code>```

input/output

```<code>> f("education")
> [1] "cde"
> > f("foghorn")
> [1] "fgh"
> > f("cabaret")
> [1] "abc"
> > f("hijacking")
> [1] "ghi"
> [1] "hij"
> [1] "ijk"
> > f("pneumonia")
> [1] "mno"
> [1] "nop"
> > f("klaxon")
> > f("perform")
> > f("learning")
> >
</code>```

Title: Close-Knit Words

Body:
R, 220 bytes

My solution is pretty straightforward. It loops through the possible three letter combinations, loops through and checks the characters of the entered string against the three consecutive letters, and adds them to a string. The string is then only printed when three letters are found (c==4).

f<-function(w){if(nchar(w)>2){for(i in 1:24){
c<-1
t<-""
for(k in 1:3){for(j in 1:nchar(w)){if(substr(w,j,j)==intToUtf8(95+k+i)&c<4){
t<-paste(t,substr(w,j,j),sep="")
c<-c+1
break
}}}
if(c==4){print(paste(t))}}}}

input/output

> f("education")
> [1] "cde"
> > f("foghorn")
> [1] "fgh"
> > f("cabaret")
> [1] "abc"
> > f("hijacking")
> [1] "ghi"
> [1] "hij"
> [1] "ijk"
> > f("pneumonia")
> [1] "mno"
> [1] "nop"
> > f("klaxon")
> > f("perform")
> > f("learning")
> >


答:
Retina, <s>106</s> 56 bytes

```<code>D`.
O`.
^
abc¶
{`^(.*)¶.*\1.*
$0¶$1
}T`_l`l;`^.*
2`.*¶?

</code>```

Deduplicate, Sort. Add abc. Find if the substring is found and append if so. Translate to next substring. Repeat. Then remove first two lines.

Try it online

Naive solution:

```<code>D`.
O`.
!&`abc|bcd|cde|def|efg|fgh|ghi|hij|ijk|jkl|klm|lmn|mno|nop|opq|pqr|qrs|rst|stu|tuv|uvw|vwx|wxy|xyz
</code>```

Deduplicate, Sort, then output overlapping matches of 3 sequential letters.

Try it online

Title: Close-Knit Words

Body:
Retina, <s>106</s> 56 bytes

D`.
O`.
^
abc¶
{`^(.*)¶.*\1.*
$0¶$1
}T`_l`l;`^.*
2`.*¶?

Deduplicate, Sort. Add abc. Find if the substring is found and append if so. Translate to next substring. Repeat. Then remove first two lines.

Try it online

Naive solution:

D`.
O`.
!&`abc|bcd|cde|def|efg|fgh|ghi|hij|ijk|jkl|klm|lmn|mno|nop|opq|pqr|qrs|rst|stu|tuv|uvw|vwx|wxy|xyz

Deduplicate, Sort, then output overlapping matches of 3 sequential letters.

Try it online


问:
Find the prime factors
In this task, you have to write a program, that computes the prime factors of a number. The input is a natural number 1 < n < 2^32. The output is a list of the prime factors of the number in the following format. Exponents must be omitted if they are 1. Only output prime numbers. (Assuming the input is 131784):

131784 = 2^3 * 3 * 17^2 * 19

Using the same amount of whitespace is not required; whitespace may be inserted wherever appropriate. Your program should complete in less then 10 minutes for any input. The program with the shortest amount of characters wins.

Title: Find the prime factors

Body:
SageMath, 31 Bytes

N=input()
print N,"=",factor(N)

Test case:
83891573479027823458394579234582347590825792034579235923475902312344444
Outputs:

83891573479027823458394579234582347590825792034579235923475902312344444 = 2^2 * 3^2 * 89395597 * 98966790508447596609239 * 263396636003096040031295425789508274613