text:
Create an N-Dimensional Simplex (Tetrahedron)
The Simplest N-Dimensional shape one can create for any dimension is a Simplex, and this is a set of N+1 points that are all equal distance away from eachother.
For 2 dimensions, this is an equilateral triangle, for 3 dimensions, this is an regular tetrahedron, at 4 dimensions is the 5-Cell and so on.
The Challenge
Given an Integer dimension N as input, output an Array/List/Stack/Whatever of N Dimensional points that represent a Simplex of this dimension. That is, N+1 vertexes that are equal and non-zero distance from eachother.
Reference implementation in Lua
Examples
1 -> [[0], [1]]
2 -> [[0, 0], [1, 0], [0.5, 0.866...]]
4 -> [[0, 0, 0, 0], [1, 0, 0, 0], [0.5, 0.866..., 0, 0], [0.5, 0.288..., 0.816..., 0], [0.5, 0.288..., 0.204..., 0.790...]]

Notes

Input is a number in any standard format, and will always be an integer greater than 1 and less than 10
Hardcoding is allowed for input of 1, but nothing higher.
Reasonable error is allowed in the output. Issues with floating point arithmetic or trig may be ignored.
Any transformation of the N dimensional simplex is allowed, aslong as it remains Regular and Non-zero.
Standard Loopholes are forbidden.
This is code-golf, so fewest bytes wins.

You realize that you can't force answers to not hardcode? The simplest way to avoid that is to increase the range of input. Also "valid criteria must be objective", reasonable is not objective.

It looks like this can be solved by taking the identity matrix plus one extra vector whose entries are all equal.

@xnor done that ;)

Jelly, 11 bytes
‘½‘÷ẋW
=þ;Ç

Try it online!
Works by generating the identity matrix of size N and concatenating it with the list generated by repeating N times the singleton √(N + 1) + 1, divided by N.
‘½‘÷ẋW – Helper link (monadic). I'll call the argument N.

‘      – Increment N (N + 1).
 ½     – Square root.
  ‘    – Increment (√(N + 1) + 1).
   ÷   – Divide by N.
    ẋ  – Repeat this singleton list N times.
     W – And wrap that into another list.

––––––––––––––––––––––––––––––––––––––––––

=þ;Ç   – Main link.

=þ     – Outer product of equality.
  ;Ç   – Concatenate with the result given by the helper link applied to the input.

Python 78 66 Bytes
lambda n:[i*[0]+[n]+(n+~i)*[0]for i in range(n)]+[n*[1+(n+1)**.5]]

Surely can be improved, especially at handling n=1```. (How is that even a simplex?) Just realized that's not necessary. Can probably be improved still ^^
Try it online!
[i*[0]+[1]+(n+~i)*[0]for i in range(n)] creates identity matrix. All points have distance sqrt(2) from each other. (thanks to Rod for improving)
Now we need a n+1-th point with the same distance to all other points. We have to choose (x, x, ... x).
Distance from (1, 0, ...  ) to (x, x, ... x) is sqrt((x-1)²+x²+...+x²). If we want an n dimensional simplex this turns out to be sqrt((x-1)²+(n-1)x²), as we have one 1 and n-1 0s in the first point. Simplify a bit: sqrt(x²-2x+1+(n-1)x²) = sqrt(nx²-2x+1)
We want this distance to be sqrt(2).
sqrt(2) = sqrt(nx²-2x+1)
2 = nx²-2x+1
0 = nx²-2x-1
0 = x²-2/n*x+1/n
Solving this quadratic equation (one solution, other one works fine, too):
x = 1/n+sqrt(1/n²+1/n) = 1/n+sqrt((n+1)/n²) = 1/n+sqrt(n+1)/n = (1+sqrt(n+1))/n
Put that in a list n times, put that list in a list and join with identity matrix.

-4 Bytes thanks to Alex Varga:
Multiply each vector by n. This changes the creation of the identity matrix to lambda n:[i*[0]+[n]+(n+~i)*[0] (same length) and gets rid of the division by n in the additional point, so it becomes n*[1+(n+1)**.5], saving two brackets and the /n.

Although not in the scope of this challenge, 0 dimensional simplexes are also a thing, as horrible as that may sound.

After reading a bit more, isn't every pair of different numbers a 1-simplex?

Yep, such is the annoying power of simplexes

-2 bytes: lambda n:[[n*int(i==j)for i in range(n)]for j in range(n)]+[n*[1+(n+1)**.5]]

You can change to way to generate the identity matrix to save 8 bytes

66 bytes combining previous comments

Wolfram Language (Mathematica), 46 bytes
IdentityMatrix@#~Join~{Table[1-(#+1)^.5,#]/#}&

Try it online!

APL (Dyalog), 20 18 bytes
1 byte thanks to @ngn
∘.=⍨∘⍳⍪1÷¯1+4○*∘.5

Try it online!

(∘.=⍨⍳) -> ∘.=⍨∘⍳

@ngn I have this golf on stand by, I was waiting to see if I can golf some more bytes before I put this in because editing posts is really pain using mobile

I took the liberty to edit it for you. I too suspect there might be a better answer - it reminds me of ⌹ but I can't quite figure out how it could work...

matrix division was fruitless but I found an interesting circular function: {÷¯1+4○⍵*.5}⍪⍳∘.=⍳

@ngn thanks. I used a tacit version of your solution for the same count

JavaScript (ES7), 70 bytes
n=>[a=Array(n++).fill((1+n**.5)/--n),...a.map((_,i)=>a.map(_=>+!i--))]

Port of @PattuX's Python answer.

Octave, 31 bytes
Saved 2 bytes thanks to Luis Mendo.
@(n)[n*eye(n);~~(1:n)+(n+1)^.5]

Try it online!

You can replace ones(1,n) by ~~(1:n)

Wolfram Language (Mathematica), 205 bytes
f1 = Sqrt[# (# + 1)/2]/# /(# + 1) & ;
f2 = Sqrt[# (# + 1)/2]/# & ;
simplex[k_] := {ConstantArray[0, k]}~Join~Table[
   Table[f1[n], {n, 1, n - 1}]~Join~{f2[n]}~Join~
    ConstantArray[0, k - n],
   {n, k}]

Simplex function in Mathematica
Starting from {0,0,...]},{1,0,0,...]},
Placing first point at origin,
Second point on x axis
Third point in x,y plane,
Fourth point in x,y,z space, etc.
This progression reuses all the previous points, adding one new point at a time in new dimension
simplex[6]={{0, 0, 0, 0, 0, 0}, {1, 0, 0, 0, 0, 0}, {1/2, Sqrt[3]/2, 0, 0, 0,
  0}, {1/2, 1/(2 Sqrt[3]), Sqrt[2/3], 0, 0, 0}, {1/2, 1/(2 Sqrt[3]),
  1/(2 Sqrt[6]), Sqrt[5/2]/2, 0, 0}, {1/2, 1/(2 Sqrt[3]), 1/(
  2 Sqrt[6]), 1/(2 Sqrt[10]), Sqrt[3/5], 0}, {1/2, 1/(2 Sqrt[3]), 1/(
  2 Sqrt[6]), 1/(2 Sqrt[10]), 1/(2 Sqrt[15]), Sqrt[7/3]/2}}

Verification
In[64]:= EuclideanDistance[simplex[10][[#[[1]]]],simplex[10][[#[[2]]]]] & /@ Permutations[Range[10],{2}]//Simplify
Out[64]= {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}

Welcome to the site! 1) This is a code golf, you should aim to make your code as short as possible. 2) Please use Markdown to make your post as readable as possible.

Ruby, 55 bytes
rather than returning similar magnitudes for all dimensions and using the formula (1+(n+1)**0.5)/n I scale up by a factor of n to simplify the formula to (1+(n+1)**0.5)

->n{(a=[n]+[0]*~-n).map{a=a.rotate}+[[1+(n+1)**0.5]*n]}

Try it online!
ungolfed in test program
A lambda function taking n as an argument and returning an array of arrays.
f=->n{
  (a=[n]+[0]*~-n).map{        #setup an array `a` containing `n` and `n-1` zeros. perform `n` iterations (which happens to be the the size of the array.)
  a=a.rotate}+                #in each iteration rotate `a` and return an array of all possible rotations of array `a`
  [[1+(n+1)**0.5]*n]          #concatenate an array of n copies of 1+(n+1)**0.5
}

p f[3]                        # call for n=3 and print output

output
[[0, 0, 3], [0, 3, 0], [3, 0, 0], [3.0, 3.0, 3.0]]

R, 38 bytes
function(n)rbind(diag(n,n),1+(n+1)^.5)

Try it online!

Pari/GP, 37 bytes
n->concat((n+1)^.5-matid(n),1^[1..n])

Try it online!


text:
String replicator
In Vim, you can repeat a command by preceding it with a number, like 3dd is equivalent to dd dd dd. Well, this repeating pattern is not restricted to Vim commands. String can be replicated in this way, too.
Specification:
Given a string, consisting of only digits, alphabetical characters (both upper-case and lower-case) and spaces, with an optional trailing newline, as input, write a program that does the following job:

Each "word" consists of digits and alphabets. If a letter is preceded with a number (there may be more than one digit in a number, or the number is zero), repeat that letter for the given times. For example:
a2bc -> abbc
3xx1yz -> xxxxyz
10ab0c0d0e -> aaaaaaaaaab # No 'cde' because there's a zero
2A2a2A2a -> AAaaAAaa

Words are separated by spaces. There's a maximum of one space between every two adjacent words.

Easy, right? Here's the additional stuff:

If there's a number before the space, repeat the next word for the given times. The number will always be attached to the end of the previous word, or at the start of the string. Example:
a2bc3 2d -> abbc dd dd dd
3 3a -> aaa aaa aaa
33a -> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
0 abcd0 efgh3 2x -> xx xx xx
a3 0xc b -> a c c c b

If an empty word ought to be repeated, don't output multiple spaces in a row. Squash them:
a3 0x2 b -> a b b   # NOT 'a    b b'

In other words, your program should never output two spaces together.
Input is never empty, but it's not necessary for the output to be non-empty:
0 3x -> (empty)

Input and output can be taken in any preferred ways. A function taking input from arguments and giving output via return values is acceptable as well.
If it's a program, it must not exit with error (i.e. return value is zero).
Numbers are always decimal, and never starts with a zero, unless the number itself is zero, in which case there's only one zero. I.e. you don't need to consider 077a or 000a given as input.
All numbers are under 2^31 (2,147,483,648). Maximum output length is under 2^32 (4,294,967,296) bytes.
The program may optionally output one trailing space and/or one trailing newline. Those space and newline do not affect the validity of output. Even if the correct output should be empty, an output of a space followed by a newline will qualify.

In short, a valid input matches this regular expression:
([0-9]+ )?([0-9A-Za-z]*[A-Za-z])([0-9]* [0-9A-Za-z]*[A-Za-z])*( ?\n?)

And for a valid output:
([A-Za-z]+)( [A-Za-z]+)*( ?\n?)

Sample test cases:
abcdefg -> abcdefg
a3bcd -> abbbcd
a3bbbc -> abbbbbc
3a0b -> aaa
abc 3d -> abc ddd
abc3 d -> abc d d d
5 1x5 1y0 z -> x x x x x y y y y y
a999 0x b -> a b
999 0s -> (empty)
0 999s -> (empty)
0 999s4 t -> t t t t
a3 0xc b -> a c c c b
ABC3 abc -> ABC abc abc abc

This is a code-golf, so the shortest program in bytes in each language wins!

.... "program must not exit with error" "input must not be given as a list of character ..." any particular reason? (as you already knew) we generally allow flexible I/O format.

@user202729 I'm consider removing the latter. For the program exit result I want to keep it. Edit: Done.

Similar.

Also similar

I think a test like a3 0xc b -> a c c c b should be added, as I originally had code that worked for all the test cases above, but didn't work correctly for that.

Will the last character of the input ever be a number?

What does 2q! do?

JavaScript (Node.js), 102 129 110 106 bytes
s=>s[p="replace"](/(\d+)( \w*[A-Z])/gi,g=(_,a,b)=>b.repeat(a))[p](/(\d+)(.)/g,g)[p](/ +/g,(_,i)=>i?" ":"")

Try it online!
Thanks for @Arnauld for -4 bytes.

Perl 6, 88 bytes
{$_=$^a;s:g/(\d+):(\w)/{$1 x$0||'_'}/;s:g/(\d+)\s([\w& \D]+)/ {$1 xx$0}/;~S:g/_//.words}

Test it
Expanded:
{ # bare block lambda with placeholder parameter ｢$a｣

  # store a copy of the argument in ｢$_｣
  # (shorter than ｢-> $_ is copy {…}｣)
  $_ = $^a;
  # note that ｢$_｣ is the default scalar,
  # and many things operate on it by default (like ｢s///｣)

  # do the character repeats
  s :global
  /

    (\d+)           # repeat count
    :               # don't backtrack (prevents it from matching word repeats)
    (\w)            # character to repeat

  /{

    $1 x $0         # do the repeat

    || '_'          # replace with ｢_｣ if the repeat was 0 (matched by [\w & \D])
                    # this is so “words” don't get removed yet

  }/;

  # do the word repeats
  s :global
  /

    (\d+)           # repeat count

    \s              # shortest way to match a space

    ([
      \w & \D       # word character and not a digit (doesn't match next repeat)
    ]+)             # match that at least once

  / {               # add a space (as we removed it by matching it)

    $1 xx $0        # list repeat (adds a space between values when stringified)

  }/;

  # the following is the result
  ~                 # stringify (adds spaces between values in a list) # (3)
    S :global /_//  # remove all _ not in-place                        # (1)
    .words          # get a list of words                              # (2)
}

The ~(…).words combination removes extraneous spaces, which is useful if a “word” gets removed.

Perl 5, 77 + 1 (-p) = 78 bytes
s/\d+( .*?)(\d*)( |$)/$1x$&.$2.$3/eg&&redo;s/\d+(\D)/$1x$&/eg;s/ +/ /g;s;^ +;

Try it online!

Python 2, 286 275 260 257 238 bytes
-19 bytes thanks to ovs
def f(s,j=' '.join):exec"s=s.split(%s[-1]):s[i]=s[i][:-1];s[i-1]=j([s[i-1]]*int(w[-1]))\ns=list(j(s[::-1])%s):s[i]='';s[i-1]*=int(w)\nprint j(''.join(s[::-1]).strip().split())"%((')[::-1]\nfor i,w in enumerate(s):\n if str.isdigit(w',)*2)

f takes a string as an argument and prints the formatted string.
Here's a repl.it with the test cases.
Ungolfed code:
def f(s, j=' '.join):
    s = s.split()[::-1]
    for i, w in enumerate(s):
        if str.isdigit(w[-1]):
            s[i] = s[i][:-1]
            s[i - 1] = j([s[i - 1]] * int(w[-1]))
    s = list(j(s[::-1]))[::-1]
    for i, w in enumerate(s):
        if str.isdigit(w):
            s[i] = ''
            s[i - 1] *= int(w)
    print j(''.join(s[::-1]).strip().split())

Still working on improvements.

238 bytes

@ovs Thanks. Can't believe I didn't think of getting rid of the newline and indent for the exec, since it's the only line in the function.

Clean, 443 ... 306 bytes
import StdEnv,StdLib
^ =last
$n|n>"9"=1=toInt n
?v c| ^v<c=init v=v
q=groupBy
f[a:t]|a<"a"=repeatn($a)(hd t)++f(tl t)|t>[]=[a:f t]=[a," "]
f e=e
@l#[h:t]=[[toString[c:if(c<'1')[]k]\\[c:k]<-q(\a b=max a b<'a')s]\\s<-q(\a b=min a b>' ')l|s>[' ']]
=flatten(map f[?h"a":[?u":"\\u<-t&v<-map^[h:t],_<-[1.. $v]]])

Try it online!

Lua, 113 bytes
a="(%d+)(%a)"g=a.gsub function r(c,s)return s:rep(c)end g(g(g(g(...,a,r),"(%d+)( %a*)",r)," +"," "),"%a.*",print)

Try it online!

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Prime numbers between n and 2n
Bertrand's postulate states that there is always at least 1 prime number between n and 2n for all n greater than 1.
Challenge
Your task is to take a positive integer n greater than 1 and find all of the primes between n and 2n (exclusive).
Any default I/O method can be used. Whoever writes the shortest code (in bytes) wins!
Test cases
n    2n     primes

2    4      3
7    14     11, 13
13   26     17, 19, 23
18   36     19, 23, 29, 31
21   42     23, 29, 31, 37, 41

What if n = 1 for which there are no prime in (excluded) range (1, 2)?

I edited your challenge to make it a bit more readable and clear. If you disagree with the changes, feel free to edit back.

The fact of exclude 1 from the possible input was written from Mr Xcoder, not by the original poster

@user202729 where is the problem in the open interval (1 2) not are primes? One has only return the void set

@RosLuP: I doubt that anyone else sees a problem with this addition since it's about Bertand's postulate which talks about N > 1. I really don't get why you're trying to invalidate several answers just to make this a more cumbersome challenge that's not about said postulate.

Closely related, perhaps duplicate. Also closely related.

It is not a duplicate, because the other proposed question do not speak about the range (n+1)..-1+2*n for find primes

@RosLuP Every answer I can understand on this question, just makes a list and applies a primality test to the elements.  This seems to be a trivial modification, in which case it is a duplicate.

Jelly, 4 bytes
‘æRḤ

Try it online!
waiting for OP's answer in comment...
(doesn't work for n=1)

The challenge states "for all n greater than 1".

@Shaggy Thanks! (for future readers, the condition was added after this answer was posted)

Haskell, 45 bytes
-2 bytes thanks to BMO.
f n=[i|i<-[n+1..2*n],all((>0).mod i)[2..i-1]]

Try it online!

Pari/GP, 20 bytes
n->primes([n+1,2*n])

Try it online!

Japt, 6 bytes
ôU Åfj

Explanation:
 ôU Åfj
U        // Implicit input                     7
 ôU      // Inclusive range [Input...Input+U]  [7,8,9,10,11,12,13,14]
    Å    // Remove the first item              [8,9,10,11,12,13,14]
     fj  // Filter primes                      [11,13]

Try it online!

Was just about to suggest a similar 8-byte solution when you edited. Great work!

Ah, so that's what N.ô() does!

Octave, 27 bytes
@(n)(k=n+1:2*n)(isprime(k))

Try it online!

Python 3, 59 57 bytes
def f(n):k=m=1;exec('m%k*k>n!=print(k);m*=k*k;k+=1;'*2*n)

Try it online!

Octave, 24 bytes
@(n)(k=primes(2*n))(k>n)

Try it online!

PL/SQL, 270 bytes
declare
 n number:=7;
 p number;
 v number:=0;
begin
 for i in (n+1)..(n*2)-1 loop
  p:=0;
  for j in 2..trunc(sqrt(n*2)) loop
   if mod(i,j)=0 then p := 1;
    exit;
   end if;
  end loop;
  if p =0 then
   dbms_output.put_line(i);
   v:=v+1;
  end if;
 end loop;
end;

Any solution is worth posting, especially if you want to post something! Every answer needs to be a solution.

Welcome to PPCG! I tried to format your code, but I'm not sure if it came out as you intended. Is indentation meaningful in PL/SQL? Could it be removed to save bytes?

you can pull out the indentation, for what it's worth. It doesn't affect how SQL runs.

@Dennis As user phroureo pointed out above, this solution is suboptimal (i.e. not a serious contender). Why did you undelete it? Also {@}David (I doubt the OP will read this anyway, because their account is unregistered) It's not important whether the solution is short or not, the problem is whether it's the shortest in the language or not.

@user202729 Because the post was deleted for being a stub, and it's not a stub anymore. I don't have the first clue about PL/SQL (or even SQL), so I can't judge whether this is a serious contender or even a valid answer, but I figured it deserved at least a chance to get peer-reviewed.

05AB1E, 5 bytes
·ÅPʒ‹

Try it online!
How?

·ÅPʒ‹ || Full program.
      ||
·     || Double the input.
 ÅP   || Lists all the prime lower than or equal to ^.
   ʒ‹ || Filter-keep those which are greater than the input.

APL NARS, 45 bytes, 26 chars
{⍵≤1:⍬⋄(0πt)/t←(⍵+1)..2×⍵}

Perhaps better the range in Axiom: When a>b than a..b is the void set. Test
  g←{⍵≤1:⍬⋄(0πt)/t←(⍵+1)..2×⍵}
  g 7
11 13
  g 9
11 13 17
  g 0

  g 1

  g 2
3
  g 6.3
DOMAIN ERROR

PowerShell, 57 bytes
param($n)(2*$n-1)..++$n|?{'1'*$_-match'^(?!(..+)\1+$)..'}

Try it online!
Takes input $n, constructs a range from 2*$n-1 to ++$n (i.e., excluding the endpoints), and feeds that range into a Where-Object cmdlet. The clause is the regex pattern match against unary numbers. Thus, those numbers where that clause is true (i.e., they are prime) are filtered out of the range and left on the pipeline. Output is implicit.

JavaScript (ES6), 63 62 bytes
Saved 1 bytes thanks to @Arnauld
f=(n,q=n,x)=>n?q%x?f(n,q,x-1):f(n-1,q+1,q).concat(x<2?q:[]):[]

APL (Dyalog Unicode), 39 bytes
⎕CY'dfns'⋄
{1↓(10pco(⍵+0⍵))/(-⍵)↑⍳⍵+⍵-1}

Try it online!
The characters B← are not counted towards the byte count because they're unnecessary and are added to TIO so it's easier to call the function. Also, ⍎'⎕CY''dfns''⋄⍬' is the equivalent to ⎕CY'dfns'⋄, but TIO doesn't accept the usual APL notation for that, so the extra characters are needed.
Thanks to @ErikTheOutgolfer for 1 byte.
How it works:
⎕CY'dfns'⋄                          ⍝ Imports every direct function. This is needed for the primes function, 'pco'.
{1↓(10pco(⍵+0⍵))/(-⍵)↑⍳⍵+⍵-1}      ⍝ Main function, prefix.
   (10pco      )                   ⍝ Calls the function 'pco' with the modifier 10, which lists every prime between the arguments:
         (⍵+0⍵)                    ⍝ Vector of arguments, ⍵ and 2⍵.
                                   ⍝ The function returns a boolean vector, with 1s for primes and 0s otherwise.
 1↓                                ⍝ Drops the first element of the vector (because Bertrands postulate excludes the left bound).
                /                  ⍝ Replicate right argument to match the left argument.
                      ⍳⍵+⍵-1       ⍝ Generate range from 1 to 2⍵-1 (to exclude the right bound)
                     ↑             ⍝ Take from the range
                 (-⍵)              ⍝ The last ⍵ elements.

You don't need the space in 0 ⍵.

Perl 6, 27 bytes
{grep &is-prime,$_^..^2*$_}

Try it
Expanded:
{  # bare block lambda with implicit parameter ｢$_｣

  grep         # find all values

    &is-prime, # that are prime

               # from the following

      $_
      ^..^     # create a Range that excludes both endpoints
      2 * $_
}

05AB1E, 5 bytes
xŸ¦ʒp

Try it online!
Explanation
xŸ¦ʒp  Full Program
x      double top of stack
 Ÿ     inclusive range
  ¦    remove first element (pop a: push a[1:])
   ʒ   filter to keep
    p  prime elements

-1 byte thanks to Mr. Xcoder

C, 72 bytes
i,k;f(n){for(k=n*2;++n<k;i<k&&printf("%d ",n))for(i=1;++i<n;)i=n%i?i:k;}

Try it online!

Java 8, 95 92 bytes
q->{for(int n=q,i,x;++n<2*q;){for(x=n,i=2;i<x;x=x%i++<1?0:x);if(x>1)System.out.println(n);}}

-3 bytes thanks to @ceilingcat.
Try it online.
Explanation:
q->{                // Method with integer parameter and no return-type
  for(int n=q,i,x;++n<2*q;){
                    //  Loop `n` in the range (q,2q):
    for(x=n,        //   Set `x` to `n`
        i=2;i<x     //   Loop `i` in the range [2,n):
        ;           //     After every iteration:
         x=x%i++<1? //      If `x` is divisible by `i`:
            0       //       Set `x` to 0
           :        //      Else:
            x);     //       Leave it unchanged
    if(x>1)         //    If `x` is larger than 1 at the end of the inner loop
                    //    (which means it's a prime):
      System.out.println(n);}}
                    //     Print this prime `n`

Wolfram Language (Mathematica) 28 bytes
This is fairly straightforward: within the range of (n+1,2n), select numbers that are primes.
Range[#+1,2#]~Select~PrimeQ&

Example
Range[#+1,2#]~Select~PrimeQ&[7]

(* {11, 13} *)

You can save some bytes on the range: Select[#+Range@#,PrimeQ]&

Husk, 6 bytes
fṗtS…D

Try it online!
Explanation
fṗtS…D -- example input: 7
   S…  -- range from itself (inclusive) to itself..
     D -- | .. doubled
       -- : [7,8,9,10,11,12,13,14]
  t    -- tail: [8,9,10,11,12,13,14]
fṗ     -- filter primes: [11,13]

Alternative, 6 bytes
fṗ§…→D

Try it online!
Explanation
fṗ§…→D -- example input: 7
  §…   -- range from ..
     D -- | .. itself incremented to
       -- | .. itself doubled
       -- : [8,9,10,11,12,13,14]
fṗ     -- filter primes: [11,13]

Julia 0.4, 17 bytes
Prime related functions wered moved to a package in Julia 0.5, so this would require using Primes in newer versions, and also TIO doesn't have that package installed.
n->primes(n+1,2n)

Try it online!

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Get ERC-20 token balance
Ethereum is a blockchain platform. It has its own native cryptocurrency, ether, but in this challenge, we'll be focusing on its ability to run smart contracts.
The ERC-20 standard describes an implementation of fungible tokens within a smart contract. Some examples of this implementation are EOS, OmiseGo, and the Golem Network Token. In this challenge, your job is to find the amount of tokens owned by a certain address using the fewest bytes possible.
The standard defines a balanceOf(address) contract method which is simple enough to use; however, it returns it in terms of a much smaller unit. To get the actual balance, you must divide the result by 10 to the power of whatever the decimals() method returns. For example, calling balanceOf(0x4530d03744d7ef769025623d31966da1e8485eef) returns 1.500000000000015e+21, and dividing it by 10^decimals() (10^18) results in the true balance of 1500.000000000015.
Notes

Assume that the computer that your program/function/etc. will be running on is running a fully-synced Geth node on the Ethereum mainnet with the JSON-RPC endpoint listening on the default port of localhost:8545.
Your program should take two inputs: the token contract address (e.g. 0xea097a2b1db00627b2fa17460ad260c016016977) and the wallet address (e.g. 0x4530d03744d7ef769025623d31966da1e8485eef). Input can be taken in any reasonable format, such as a string, an integer, or an array of bytes (NB: Ethereum addresses are 20 bytes long).
It should have one output: the token balance of the address in any reasonable format. Cases where the balance is zero must still be handled.
Loss of fine floating-point precision in the final balance (e.g. the 17th or 18th decimal after dividing the balance by 10^decimals()) is okay.
The ERC-20 standard technically says that the decimals() method might not be implemented; however, you may assume that it is.
The use of libraries like web3.js is permitted, but discouraged.
Standard loopholes are obviously not allowed.

Test Cases
token, wallet -> balance
0xea097a2b1db00627b2fa17460ad260c016016977, 0x4530d03744d7ef769025623d31966da1e8485eef -> 1500.000000000015
0xab95e915c123fded5bdfb6325e35ef5515f1ea69, 0x4530d03744d7ef769025623d31966da1e8485eef -> 317.18737335873794694
0x6810e776880c02933d47db1b9fc05908e5386b96, 0x3257bde8cf067ae6f1ddc0e4b140fe02e3c5e44f -> 8495410
0xb64ef51c888972c908cfacf59b47c1afbc0ab8ac, 0x0be3dead1ba261560362361838dd9671a34b63bb -> 314873.06011271

Reference Implementation
A reference implementation written in Crystal can be found here.

Sandbox link here.


text:
Convert a HTML page into a mountain
Task: convert a HTML page into a mountain!
When HTML pages are indented, they can look like:

But to be honest, a mountain is more representative of this structure.
So we can rewrite it as:
     /\
  /\/  \
 /      \
/        \

The outermost slashes on the left and right correspond to the outer div - each pair of HTML tags should be represented as / for the starting tag and \ for the ending tag - inside all tags are "higher", with the same structure.
Input:

There will be no <!DOCTYPE>
There will be no self-closing tags e.g.  or

There may be attributes or content inside the tags
There may be spaces or tabs - your program should ignore these
There will be no spaces between < or </ and the tag name
All input will be valid HTML

Output - a mountain representing the tags as above.
More testcases:
Input:

 HI

Output:
   /\
/\/  \

Input:
<body id="<">

Output:
/\

A word of caution for golfers...

Will there ever be
? or can we assume the slash is always adjacent to the div

hmmm, I'll be nice - you can assume no spaces after < or </ (until the tag name) - however there may still be spaces for attributes e.g.

Perhaps this could use a few more test cases?

Can we assume the document would be valid? (i.e. every starting tag has a valid ending one, and the order of the tags is nested properly)

@Uriel yes, of course.

Can to-be-ignored text appear before and after the first tag in the document?

No, this will not appear.

OK, thanks for the clarifications

Will there ever be any case where there is a poorly written page with incomplete tags such as
 such as b.)

For what it’s worth I think the challenge is interesting enough focusing only on strings like xxxyyy

zzz

. No attributes, only simple matched tags and lowercase letters as text content. HTML is very complex.

I feel like this challenge has turned into an excuse to get people to use JavaScript for golfing. :) though if everyone thinks this is too restrictive, I'll change the question.

I call dibs on GNU sed.

HTML + CSS + JavaScript, 39 + 141 + 20 = 200 bytes
Outputs visually to the webpage. To allow this to work with special elements like , all letters in the input are replaced.

p.innerHTML=prompt().replace(/\w/g,'a')
#p,#p *{display:flex;padding:0 0 1rem;align-items:flex-end;font-size:0}#p :before,#p :after{content:'/';font-size:1rem}#p :after{content:'\\'

HTML + CSS + JavaScript, 10 + 103 + 20 = 133 bytes
Solution that works if there is no content within tags.

p.innerHTML=prompt()
#p,#p *{display:flex;padding:0 0 1em;align-items:flex-end}#p :before{content:'/'}#p :after{content:'\\'

This is really clever!

I've never seen golfed CSS before :)

This fails both of the test cases.

@Giuseppe I think you may be able to fix it with display = none on all elements and using an iframe instead of a

@Giuseppe Fixed.

Javascript + JQuery, 275 246 bytes
Saved 29 bytes thanks to Rick Hitchcock
j=(a,b,c,i)=>{s=(c=' '.repeat(b))+'/\n';for(i=0;V=a.children[i];i++){s=s+j(V,b+1)}return s+c+'\\\n';};f=s=>{s=j($(s)[0],0).split`
`;w=Math.max.apply(0,s.map(a=>a.length));o='';for(i=w-1;i>=0;i--){for(c=0;C=s[c];c++){o+=C[i]||' '}o+='\n'}alert(o)}

A pretty Naïve solution to the problem. Parses the HTML with JQuery's $(string), then recursively builds a sideways mountain with the format:
/
 /
  children...
 \
\

Then rotates the resulting string counterclockwise, and alerts the result.

    j=(a,b,c,i)=>{s=(c=' '.repeat(b))+'/\n';for(i=0;V=a.children[i];i++){s=s+j(V,b+1)}return s+c+'\\\n';};f=s=>{s=j($(s)[0],0).split`
`;w=Math.max.apply(0,s.map(a=>a.length));o='';for(i=w-1;i>=0;i--){for(c=0;C=s[c];c++){o+=C[i]||' '}o+='\n'}return o}

update=_=>outp.textContent=f(inp.value)

<textarea id=inp oninput=update()></textarea>

Are you sure it's naïve and not naÃ¯ve? (I can stop this joke if you want)

269 bytes by changing to: j=(a,b,c,i)=>{s=(c=' '.repeat(b))+'/\n';for(i ...

Change to for(c=0;c<s.length;c++) to for(c=0;s[c];c++)

Similarly, change for(i=0;i[...(E.innerHTML=s,y=0,o=[],m=n=>1+[...n.children].map(m).join``+0)(E.firstChild)].map((c,x,a)=>{(o[y+=+c]||(o[y]=[...a].fill` `))[x]=`\\/`[c],y+=~-c})&&o.reverse().map(l=>l.join``).join`
`

HTML

f=

s=>[...(E.innerHTML=s,y=0,o=[],m=n=>1+[...n.children].map(m).join``+0)(E.firstChild)].map((c,x,a)=>{(o[y+=+c]||(o[y]=[...a].fill` `))[x]=`\\/`[c],y+=~-c})&&o.reverse().map(l=>l.join``).join`
`

console.log(f(`

`))

Less golfed
s=>{
    E.innerHTML=s,
    y=0,
    o=[],
    m=n=>1+[...n.children].map(m).join``+0,
    [...m(E.firstChild)].map((c,x,a)=>{
        y+=+c
        if(!o[y]) o[y]=[...a].fill` `
        o[y][x]=`\\/`[c]
        y+=~-c
    })
    return o.reverse().map(l=>l.join``).join`\n`
}

Shouldn't the byte count include the id=E HTML element since you are relying on it for the code to work?

@Birjolaxew Whoops! I missed that somehow.

HTML has built-in HTML parser... creative solution.

05AB1E, 38 26 23 bytes
¶¡εDð¢4÷s'/å_„\/sèú}ζR»

Try it online!

I am still golfing this. It assumes that in HTML you will always use 4 spaces for indentation, and does not work on "non-pretty" HTML. Not sure how to handle the "content" part, if this is invalid please edit the question to show an example with a node that has content.

Charcoal, 28 bytes
≔¹ηＦ⮌θ«≡ι"≦¬η<Ｆη¿⁼ζ/←¶\↙/≔ιζ

Try it online! Link is to verbose version of code. Explanation:
≔¹η

The h variable is used to keep track of whether we are inside quotes.
Ｆ⮌θ«

Loop over the string in reverse order.
≡ι

Switch on the currenc character.
"≦¬η

If it's a " then toggle the quote flag.
<Ｆη

If it's a < and we're not inside quotes, then...
¿⁼ζ/

If the next character (previous in the loop because we're looping in reverse) is a /, then...
←¶\

Move up and draw a \ leftwards, else...
↙/

Draw a / and move down and left.
≔ιζ

Remember the character for the next loop iteration.


text:
Collection from a sequence that constitute a perfect square
Given the sequence OEIS A033581, which is the infinite sequence, the n'th term (0-indexing) is given by the closed form formula 6 × n2 .
Your task is to write code, which outputs all the subsets of the set of N first numbers in the sequence, such that the sum of the subset is a perfect square.
Rules

The integer N is given as input.
You cannot reuse a number already used in the sum. (that is, each number can appear in each subset at most once)
Numbers used can be non-consecutive.
Code with the least size wins.

Example
The given sequence is {0,6,24,54,96,...,15000}
One of the required subsets will be {6,24,294}, because
6+24+294 = 324 = 18^2

You need to find all such sets of all possible lengths in the given range.

Good first post! You may consider adding examples and test cases. For future reference, we have a sandbox that you can trial your ideas in.

Is this asking us to calculate A033581 given N? Or am I not understanding this correctly?

@ATaco Like for a sequence (1,9,35,39...) 1+9+39=49 a perfect square (It uses 3 numbers), 35+1= 36 another perfect square but it uses 2 numbers. So {1,35} is the required set.

@prog_SAHIL Adding that, and a few more, as examples to the post would be helpful :)

Let us continue this discussion in chat.

05AB1E, 10 bytes
Ý¨n6*æʒOÅ²

Try it online!
How?

Ý¨n6*æʒOÅ² || Full program. I'll call the input N.

Ý          || 0-based inclusive range. Push [0, N] ∩ ℤ.
 ¨         || Remove the last element.
  n        || Square (element-wise).
   6*      || Multiply by 6.
     æ     || Powerset.
      ʒ    || Filter-keep those which satisfy the following:
       O   ||---| Their sum...
        Å² ||---| ... Is a perfect square?

Haskell, 114 104 103 86 bytes
f n=[x|x<-concat<$>mapM(\x->[[],[x*x*6]])[0..n-1],sum x==[y^2|y<-[0..],y^2>=sum x]!!0]

Thanks to Laikoni and Ørjan Johansen for most of the golfing! :)
Try it online!
The slightly more readable version:
--  OEIS A033581
ns=map((*6).(^2))[0..]

-- returns all subsets of a list (including the empty subset)
subsets :: [a] -> [[a]]
subsets[]=[[]]
subsets(x:y)=subsets y++map(x:)(subsets y)

-- returns True if the element is present in a sorted list
t#(x:xs)|t>x=t#xs|1<2=t==x

-- the function that returns the square subsets
f :: Int -> [[Int]]
f n = filter (\l->sum l#(map(^2)[0..])) $ subsets (take n ns)

@Laikoni That is very ingenious! Thanks!

@Laikoni Right! Thanks!

86 bytes: Try it online!

Pyth, 12 bytes
-2 bytes thanks to Mr. Xcoder
fsI@sT2ym*6*

Try it online!
2 more bytes need to be added to remove [] and [0], but they seem like valid output to me!

Explanataion
    fsI@sT2ym*6*
    f                  filter
           y           the listified powerset of
            m*6*ddQ    the listified sequence {0,6,24,...,$input-th result}
        sT             where the sum of the sub-list
     sI@  2            is invariant over int parsing after square rooting

12 bytes: fsI@sT2ym*6*.

That's the square checking golf I was looking for!

Clean, 145 ... 97 bytes
import StdEnv
@n=[[]:[[6*i^2:b]\\i<-[0..n-1],b<- @i]]
f=filter((\e=or[i^2==e\\i<-[0..e]])o sum)o@

Try it online!
Uses the helper function @ to generate the power set to n terms by concatenating each term of [[],[6*n^2],...] with each term of [[],[6*(n-1)*2],...] recursively, and in reverse order.
The partial function f is then composed (where -> denotes o composition) as:
apply @ -> take the elements where -> the sum -> is a square
Unfortunately it isn't possible to skip the f= and provide a partial function literal, because precedence rules require it have brackets when used inline.

Bah you've got a trick the Haskell answer should steal... :P

JavaScript (ES7), 107 bytes
n=>[...Array(n)].reduce((a,_,x)=>[...a,...a.map(y=>[6*x*x,...y])],[[]]).filter(a=>eval(a.join`+`)**.5%1==0)

Demo

let f =

n=>[...Array(n)].reduce((a,_,x)=>[...a,...a.map(y=>[6*x*x,...y])],[[]]).filter(a=>eval(a.join`+`)**.5%1==0)

console.log(f(6).map(a => JSON.stringify(a)).join('\n'))
console.log(f(10).map(a => JSON.stringify(a)).join('\n'))

Commented
n =>                      // n = input
  [...Array(n)]           // generate a n-entry array
  .reduce((a, _, x) =>    // for each entry at index x:
    [                     //   update the main array a[] by:
      ...a,               //     concatenating the previous values with
      ...a.map(           //     new values built from the original ones
        y =>              //     where in each subarray y:
          [ 6 * x * x,    //       we insert a new element 6x² before
            ...y       ]  //       the original elements
      )                   //     end of map()
    ],                    //   end of array update
    [[]]                  //   start with an array containing an empty array
  )                       // end of reduce()
  .filter(a =>            // filter the results by keeping only elements for which:
    eval(a.join`+`) ** .5 //   the square root of the sum
    % 1 == 0              //   gives an integer
  )                       // end of filter()

Jelly, 12 bytes
Ḷ²6×ŒPSÆ²$Ðf

Try it online!
Output is a list of subsets including 0s and the empty subset.

Wolfram Language (Mathematica), 49 bytes
Brute force approach
Select[Subsets[6Range[#]^2],Sqrt@Tr@#~Mod~1==0&]&

Try it online!

Japt, 15 bytes
ò_²*6Ãà k_x ¬u1

Try it

Explanation
Generate on array of integers from 0 to input (ò) and pass each through a function (_   Ã), squaring it (²) & mutiplying by 6 (*6). Get all the combinations of that array (à) and remove those that return truthy (k) when passed through a function (_) that adds their elements (x), gets the square root of the result (¬) and mods that by 1 (u1)