¡Compartir (personajes) es cariñoso!

40

Visión general

Considere la siguiente tarea:

Dado un entero positivo n> 0 , genera su raíz cuadrada entera. La raíz cuadrada entera de un número n es el valor más grande de x donde x 2 ≤ n , generalmente expresado con la fórmula floor(sqrt(n)).

Ejemplos: 25 -> 5, 24 -> 4, 40 -> 6, 1 -> 1.

Esta tarea es bastante fácil por sí sola. Sin embargo, en este desafío, su tarea es resolver esto en tantos idiomas como sea posible utilizando un conjunto de solo 25 caracteres.

Ejemplo

Primero, debe elegir un conjunto (sin duplicados) de 25 bytes. Puede verse más o menos así (tenga en cuenta el espacio inicial):

 ()*-.05:=>Mabdhilmnqrst|

Su desafío es entonces, utilizando solo caracteres en este conjunto, construir una solución al problema en tantos idiomas basados ​​en texto (lo siento, Piet) como sea posible. Puede usar caracteres tantas veces como sea necesario, pero no debe usar caracteres fuera del conjunto.

Las soluciones pueden ser programas completos o funciones , pero no fragmentos. Por ejemplo, usando este conjunto de caracteres, podría hacer:

M -> (int) Math.sqrt(M)    // Java (lambda expression)
M => Math.sqrt(M)|0        // Javascript (unnamed function)
lambda M: int(M**.5)       // Python (lambda function)

Como he usado 3 idiomas, esto me daría una puntuación de 3 .

Incluya también el conjunto de bytes que está utilizando en su respuesta.

Reglas

  • Este es un desafío de : su puntaje es la cantidad de idiomas que incluye su envío. El puntaje más alto gana. Se aplican lagunas estándar.
  • Para este desafío, un 'lenguaje' cuenta como un lenguaje de programación claramente diferente: múltiples versiones del mismo lenguaje (Python 2, Python 3, etc.) están prohibidas.
  • Los programas solo necesitan trabajar para entradas dentro del rango entero estándar del lenguaje.
  • Los programas con exactamente el mismo código fuente (políglotas) no están permitidos.
  • Para ser más específico, es un conjunto de bytes , no caracteres, por lo que puede usar el 05AB1E £y el Jelly ɱcomo el mismo carácter (porque tienen el mismo punto de código).

Por favor, no sienta que tiene que superar todas las demás soluciones; si tiene una respuesta interesante, ¡publíquela!

FlipTack
fuente
2
¿Puede nuestra solución estar en Piet si tenemos que el código sea el ppm bruto? (por ejemplo P3 10 10 255 ...)
Wheat Wizard
Necesitamos otro lenguaje basado en píxeles para que podamos tener políglotas con pobre piet viejo
MildlyMilquetoast
2
¿Podemos contar un políglota de A y B como lenguaje A si proporcionamos otra solución que solo funciona en B?
Wheat Wizard
¿Podría aclarar "claramente diferente"? Por ejemplo, ¿ Numberwang ( usando dígitos en lugar de []<>.,+-) es claramente diferente de Brainfuck? ¿Qué pasa con SNUSP , un derivado 2D Brainfuck? Para ambos, el código resultante no funcionaría en Brainfuck.
JungHwan Min
@WheatWizard no puede tener dos programas que sean exactamente iguales, pero si modifica uno para que sea diferente, entonces está permitido. Y sí, si realmente debe hacerlo, puede usar las ppm sin procesar como "texto" para Piet: P
FlipTack

Respuestas:

37

20 idiomas

Usando  ()-#*.05;=>^Vefikloqrst(24 caracteres) hasta ahora:

let f l=floor(l**0.5);;       OCaml
let f l=floor(l**0.5)         F#
f(l)=floor(l^.5)              Julia
f(o)=floor(o^.5)              PARI/GP
s^+>5 0>5 0*.5l               Pyth
(* **.5).floor                Perl 6
floor.(**0.5)                 Haskell
flr.(tt ^.5)                  Wonder
l=>l**.5^0                    JavaScript
l->l**.5^0                    Cheddar
.5^5*5f                       Pyke
(isqrt)                       Maple
ri.5#i                        CJam
isqrt                         Common Lisp
0.5^k                         MATL
*.5^0                         Jelly
*.^0                          M
t0^                           05AB1E
q f                           Japt
r#                            Pushy
V-                            gs2
Lynn
fuente
Intente agregar flr.(tt ^.5)para Wonder (sin caracteres agregados).
Mama Fun Roll
Si desea agregar {}[] , puede agregar Brain-Flak. Aquí está el programa
Wheat Wizard
Si agregaste ~, podrías hacerlo sqrt~~en Apilado ; toma la entrada del TOS y deja la salida en la pila.
Conor O'Brien
julia también tieneisqrt
rahnema1
isqrten Julia no contaría porque los políglotas no están permitidos.
JungHwan Min
8

10 idiomas

Conjunto de caracteres de 19 caracteres (en CP-1252 ):

,-/12@QUVX^fkmt¬÷␊␍

Donde representa un avance de línea y representa un retorno de carro .

( Guión para verificar los caracteres )


Jalea, 2 bytes

ƽ

Pruébalo en línea!

05AB1E, 2 bytes

t1X-^

Pruébalo en línea!

GS2, 2 bytes

V-

Pruébalo en línea!

Jolf, 3 bytes

mfU

Pruébalo aquí! (funciona mejor en Firefox)

Japt, 2 bytes

¬f

Pruébalo aquí!

MATL, 3 bytes

X^k

Pruébalo en línea!

Pyke, 3 bytes

,1f

Pruébalo aquí!

Pyth, 6 bytes

/@Q2t2

Pruébalo aquí!

Oasis, 6 bytes

1␊2/m1÷

Pruébalo en línea!

2sable, 9 bytes

t1X-XX--^

Pruébalo en línea!

Adnan
fuente
cUTambién trabaja en Jolf.
Conor O'Brien el
@ ConorO'Brien Aunque es más corto, significaría agregar ca la lista de personajes. Ya está usando tanto m(en la respuesta secundaria de Oasis) como f(en las respuestas secundarias de Japt y Pyke).
Kevin Cruijssen
@KevinCruijssen ik, es solo para la posteridad
Conor O'Brien
6

5 idiomas

Voy a agregar más idiomas pronto.

Juego de caracteres (22 bytes):

s^Q.5=>*|0√Lrdmlab :/1

Pyth

s^Q.5

Javascript

Q=>Q**.5|0

Actualmente

√L

CJam

rdmQ

Pitón

lambda Q:Q**.5//1
Maltysen
fuente
2
Puede reemplazar |por ^en su respuesta de JavaScript para guardar un byte en su conjunto de caracteres.
Lynn el
6

5 idiomas

[].,+<>{}()0134879

18 caracteres

Estoy tratando de no usar caracteres alfabéticos ...

Brainfuck , Brainfuck ++ , Brainfuck-ng , Braintrust , ...

,[[>++++++[<++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++]>[+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++<]>[+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<+>]<<<[+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>+<<]],]>>>>>>>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[<<<<<[+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>+>+<<]>[+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<+>]<<+[+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<<+>>>>+<<]>>[+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<<+>>]<<<<[>>[<+>>>+<<+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++]<[>+<+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++]<+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++]>>>>>>>>+<<<<[>>>+<<[+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>+>[+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++]<<]>>[+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>+<]<[+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<+>]<+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++]>[+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++]>>>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++]<<<<<<+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<++++++++++>[+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[<+<<]<[+[+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>+<]<+<<]>>>>>]<<<[<++++++[+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++<]>.[+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++]]++++++[+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++<]>.

No funciona por más 224porque 256(= (sqrt (225) +1) ^ 2) se desborda.

Se reemplazaron todas las -s por +s para usar un personaje menos. (p -. ej. -> 255 +s)

Programa original

,[[>++++++[<-------->-]>[->++++++++++<]>[-<+>]<<<[->>+<<]],]>>>>>>>-[<<<<<[->+>+<<]>[-<+>]<<+[-<<+>>>>+<<]>>[-<<+>>]<<<<[>>[<+>>>+<<-]<[>+<-]<-]>>>>>>>>+<<<<[>>>+<<[->+>[-]<<]>>[->+<]<[-<+>]<-<-]>[-]>>>-]<<<<<<-<++++++++++>[-<-[<+<<]<[+[->+<]<+<<]>>>>>]<<<[<++++++[->++++++++<]>.[-]]++++++[->++++++++<]>.

Brain-Flak

({}(())[()])(()){{}((({})({}((({}())))[{}{({})({}[()])}{}]))[({}[{}])])([({}(())[()])]){(({}()({}[(({}[(())]()){(([({}{})]{}))}{})]{}))[({}[{}])])}{}{}}{}{}({}[()])

@ Código de WheatWizard. Gracias por el permiso!

Flujo cerebral

({}())(())(())({}){{}({})({}<(({})<({({})({}[()])}{})>())>)([{}]<({})>({}))({}<‌​({}<([({})]){()<({}())>}{}(<()>){({}[()])([{}]())}{}>)>)({}<({})>)({})({})}{}({}[‌​()()]){}

Otro código de @ WheatWizard.

Numberwang

8440999999419999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999909999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999997049999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999990999999999917049999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999991907111499999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999900911778700000009999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999994111114999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999090911704999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999190711949999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999991190000911700499999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999911900711114004190009119999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999997140919999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999997199999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999970000000091111400091149999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999990904999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999711700499999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999909171499999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999919071999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999199999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999970499999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999970009999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999997111111999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999199999999990499999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999919999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999994191171494999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999091719117000007111419999994999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999099999999170349999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999997799999949999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999990999999991703

Cuchara

00101100010000100010111111001000110000000000000000000000000100000011010001000000101111111111011001101000100000011101000110110110110010000001001010110110011001100101100011010010010010010010010000001000110110110110110010000001010101011011001101000100000011101000110110111001000000110111010010010010101101100110100100010000001101110100100011011011011011001000100100010001110100100101011011000001101100100010101100000110110000011010010010010010010010010101101101101100100010010010101101100100000010101000100000001101101100110100100010000001010110011011001000000111010001101100001100000110100010000000110100100100000011011011011011011011000011111111111101000100000011000001000111011011001101100100100100000010101100110111011011001101001001001001000110110110110010001111111100100000010111111110110011010001010001000000011001111111100100000010111111110110011010001010

Por meta consenso, este código debería estar bien, aunque actualmente no hay intérpretes disponibles.

JungHwan Min
fuente
4

5 idiomas

Usando ()*/12 dlinpqrstuy nueva línea (18 caracteres) hasta ahora.

Lisp común

isqrt

Una función incorporada.

QBasic

input q
print int(sqr(q))

Python 3

print(int(int(input())**(1/2)))

Python 3 utilizado para la división de punto flotante sin puntos decimales.

Pipa

q**/2//1

Innecesariamente golfista para mostrar el operador de inversión unario /. Toma información de stdin. Pruébalo en línea!

tinylisp

(d sqrt (q((n nsqr input) (i (l input nsqr) (s n 1) (sqrt (s n (s 1 2)) (s 2 (s (s (s 1 n) n) nsqr)) input)))))
(q((input)(sqrt 1 1 input)))

sqrtes una función auxiliar cuyos argumentos son: la suposición actual n, el ncuadrado y el inputnúmero. Si inputes menor que nsqr, hemos ido demasiado lejos, así que devuelve nmenos 1; de lo contrario, recurse, agregando 1 ny agregando n + n + 1a nsqr. (La matemática es un poco complicado porque tinylisp sólo ha construido sustracción in.) La segunda línea define nuestra función real, que tiene un solo inputy devuelve el resultado de sqrtla npartida en 1.

DLosc
fuente
Si desea agregar {}[] , puede agregar Brain-Flak. Aquí está el programa
Wheat Wizard
3

6 idiomas

Usando retun flosq(agm1)\,iy puntos de código extendidos B1y BCpara 22 bytes hasta ahora.

GameMaker Language

return floor(sqrt(argument1))

Pyke

,1f

Julia

isqrt

Arce

(isqrt)

Atascado

i\

TI-Basic (volcado hexadecimal)

B1 BC 72

Tenga en cuenta que 0x72 está ren ASCII.

Timtech
fuente
1

7 idiomas

24 caracteres:

limQi->(nt)Mah.sqr_ ?;:\

CJam

limQ
li       e#Read Int
  mQ     e#Integer square root

Java

i->(int)Math.sqrt(i)

Chaincode

q_
q  #sQuare root
 _ #floor

Math ++

_sqrt ?

Mueca

;q:

Atascado

i\)

Unilineal

iMivMiMs
i            Read input
 Mi          Convert to int
    v        Square root
    Mi       Convert to int
      Ms     Convert to String

R

sqrt

Cuesta demasiado bytes

Pitón

lambda i:int(i**.5)
Roman Gräf
fuente
Puede agregar R:sqrt
JAD