Mostrar los tags: LE

Mostrando del 51 al 60 de 471 coincidencias
Se ha buscado por el tag: LE
Imágen de perfil

Imprimir la suma de los N primeros números naturales


Python

Publicado el 19 de Abril del 2021 por Katas (150 códigos)
8.136 visualizaciones desde el 19 de Abril del 2021
Para calcular la suma de los N primeros números naturales, se van sumando todos los numeros hasta llegar al numero N indicado
Si ingresamos 10, entonces sumará: 1+2+3+4+5+6+7+8+9+10 que es lo mismo que 10*(10+1)/2 = 55

Aquí se muestran dos funciones lambda:
- Una que hace el uso del calculo N(N+1)/2
- Otra que lo hace de manera manual, recorriendo todos los valores y sumándolos

1
2
3
naturales(1) # 1
naturales(10) # 55
naturales(100) # 5050
Imágen de perfil

Descargar una pagina web con file_get_contents()


PHP

Publicado el 9 de Abril del 2021 por Xavi (548 códigos)
6.532 visualizaciones desde el 9 de Abril del 2021
Código que muestra como utilizando file_get_contents(), podemos descargar una pagina web a un archivo de nuestro disco duro.

En este ejemplo, se descarga el contenido de la pagina inicial de lawebdelprogramador.com

Puedes ver el mismo código utilizando cURL: https://www.lawebdelprogramador.com/codigo/PHP/2294-descargar-una-pagina-web-mediante-CURL-en-PHP.html
Imágen de perfil

Clase para agregar un atributo del tipo objeto (otra clase) en php


PHP

Actualizado el 6 de Abril del 2021 por Sergio (7 códigos) (Publicado el 19 de Noviembre del 2016)
2.930 visualizaciones desde el 19 de Noviembre del 2016
Clase para agregar un atributo del tipo objeto (otra clase) en php, puede ser utilizado para relacionar maestro detalle, como en este caso cliente - cuenta. Un cliente puede tener una o varias cuentas. La próxima levanto el código ya con la persistencia. Saludos.
Imágen de perfil

Crear un array bidimensional de 10x10 con números aleatorios


JavaScript

Publicado el 25 de Marzo del 2021 por Katas (200 códigos)
3.484 visualizaciones desde el 25 de Marzo del 2021
Código que muestra como crear un array de 10x10 con números aleatorios entre el 0 y el 99

1
2
3
4
5
6
7
8
9
10
[52, 90, 89, 76, 71, 64, 45, 43, 11, 21]
[10, 91, 89, 3, 49, 23, 84, 19, 31, 56]
[3, 23, 26, 41, 4, 24, 20, 55, 90, 0]
[16, 93, 8, 40, 84, 24, 43, 77, 80, 67]
[47, 32, 18, 94, 52, 22, 32, 78, 85, 82]
[93, 12, 67, 71, 56, 27, 9, 81, 5, 94]
[52, 23, 15, 62, 24, 35, 5, 0, 52, 87]
[35, 63, 97, 64, 11, 20, 43, 68, 53, 47]
[39, 97, 61, 83, 14, 21, 76, 93, 25, 88]
[96, 32, 31, 13, 0, 50, 24, 12, 26, 53]

Definimos una constante como un array de 10 valores
1
const y=[..."1111111111"];

Mediante la función map(), recorremos cada uno de los elementos de la constante "y" y asignamos su valor a la variable "x", la cual es nuevamente asignada a la constante "y", la cual a su misma vez mediante la función map() nuevamente le asignamos un valor aleatorio a cada uno de sus 10 elementos, y es asignado a la variable "x" que modifica el primer valor de "y" que se asignara a la variable "arr".
1
let arr=y.map(x => y.map(el => Math.floor(Math.random() * 100)));
Imágen de perfil

Obtener el valor de cualquier estilo de un elemento


JavaScript

Publicado el 19 de Marzo del 2021 por Katas (200 códigos)
693 visualizaciones desde el 19 de Marzo del 2021
Este código muestra como obtener cualquier valor de los posibles estilos que puede tener un elemento.

En este ejemplo, estos son los estilos de nuestro <div>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
-webkit-writing-mode -> horizontal-tb
-webkit-user-modify -> read-only
-webkit-user-drag -> auto
-webkit-text-stroke-width -> 0px
-webkit-text-stroke-color -> rgb(0, 0, 0)
-webkit-text-security -> none
-webkit-text-orientation -> vertical-right
-webkit-text-fill-color -> rgb(0, 0, 0)
-webkit-text-emphasis-style -> none
-webkit-text-emphasis-position -> over right
-webkit-text-emphasis-color -> rgb(0, 0, 0)
-webkit-text-decorations-in-effect -> none
-webkit-text-combine -> none
-webkit-tap-highlight-color -> rgba(0, 0, 0, 0.18)
-webkit-rtl-ordering -> logical
-webkit-print-color-adjust -> economy
-webkit-mask-size -> auto
-webkit-mask-repeat -> repeat
-webkit-mask-position -> 0% 0%
-webkit-mask-origin -> border-box
-webkit-mask-image -> none
-webkit-mask-composite -> source-over
-webkit-mask-clip -> border-box
-webkit-mask-box-image-width -> auto
-webkit-mask-box-image-source -> none
-webkit-mask-box-image-slice -> 0 fill
-webkit-mask-box-image-repeat -> stretch
-webkit-mask-box-image-outset -> 0
-webkit-mask-box-image -> none
-webkit-locale -> auto
-webkit-line-clamp -> none
-webkit-line-break -> auto
-webkit-hyphenate-character -> auto
-webkit-highlight -> none
-webkit-font-smoothing -> auto
-webkit-box-reflect -> none
-webkit-box-pack -> start
-webkit-box-orient -> horizontal
-webkit-box-ordinal-group -> 1
-webkit-box-flex -> 0
-webkit-box-direction -> normal
-webkit-box-decoration-break -> slice
-webkit-box-align -> stretch
-webkit-border-vertical-spacing -> 0px
-webkit-border-image -> none
-webkit-border-horizontal-spacing -> 0px
-webkit-app-region -> none
zoom -> 1
z-index -> auto
y -> 0px
x -> 0px
writing-mode -> horizontal-tb
word-spacing -> 0px
word-break -> normal
will-change -> auto
width -> 1247px
widows -> 2
white-space -> normal
visibility -> visible
vertical-align -> baseline
vector-effect -> none
user-select -> auto
unicode-bidi -> normal
transition-timing-function -> ease
transition-property -> all
transition-duration -> 0s
transition-delay -> 0s
transform-style -> flat
transform-origin -> 623.5px 612px
transform -> none
touch-action -> auto
top -> auto
text-underline-position -> auto
text-transform -> none
text-size-adjust -> auto
text-shadow -> none
text-rendering -> auto
text-overflow -> clip
text-indent -> 0px
text-decoration-style -> solid
text-decoration-skip-ink -> auto
text-decoration-line -> none
text-decoration-color -> rgb(0, 0, 0)
text-decoration -> none solid rgb(0, 0, 0)
text-anchor -> start
text-align-last -> auto
text-align -> start
table-layout -> auto
tab-size -> 8
stroke-width -> 1px
stroke-opacity -> 1
stroke-miterlimit -> 4
stroke-linejoin -> miter
stroke-linecap -> butt
stroke-dashoffset -> 0px
stroke-dasharray -> none
stroke -> none
stop-opacity -> 1
stop-color -> rgb(0, 0, 0)
speak -> normal
shape-rendering -> auto
shape-outside -> none
shape-margin -> 0px
shape-image-threshold -> 0
scroll-padding-inline-start -> auto
scroll-padding-inline-end -> auto
scroll-padding-block-start -> auto
scroll-padding-block-end -> auto
scroll-margin-inline-start -> 0px
scroll-margin-inline-end -> 0px
scroll-margin-block-start -> 0px
scroll-margin-block-end -> 0px
scroll-behavior -> auto
ry -> auto
rx -> auto
ruby-position -> over
row-gap -> normal
right -> auto
resize -> none
r -> 0px
position -> static
pointer-events -> auto
perspective-origin -> 623.5px 1098px
perspective -> none
paint-order -> normal
padding-top -> 0px
padding-right -> 0px
padding-left -> 0px
padding-inline-start -> 0px
padding-inline-end -> 0px
padding-bottom -> 0px
padding-block-start -> 0px
padding-block-end -> 0px
overscroll-behavior-inline -> auto
overscroll-behavior-block -> auto
overflow-y -> visible
overflow-x -> visible
overflow-wrap -> normal
overflow-anchor -> auto
outline-width -> 0px
outline-style -> none
outline-offset -> 0px
outline-color -> rgb(0, 0, 0)
orphans -> 2
order -> 0
opacity -> 1
offset-rotate -> auto 0deg
offset-path -> none
offset-distance -> 0px
object-position -> 50% 50%
object-fit -> fill
mix-blend-mode -> normal
min-width -> 0px
min-inline-size -> 0px
min-height -> 0px
min-block-size -> 0px
max-width -> none
max-inline-size -> none
max-height -> none
max-block-size -> none
mask-type -> luminance
marker-start -> none
marker-mid -> none
marker-end -> none
margin-top -> 0px
margin-right -> 0px
margin-left -> 0px
margin-inline-start -> 0px
margin-inline-end -> 0px
margin-bottom -> 0px
margin-block-start -> 0px
margin-block-end -> 0px
list-style-type -> disc
list-style-position -> outside
list-style-image -> none
line-height -> normal
line-break -> auto
lighting-color -> rgb(255, 255, 255)
letter-spacing -> normal
left -> auto
justify-self -> auto
justify-items -> normal
justify-content -> normal
isolation -> auto
inset-inline-start -> auto
inset-inline-end -> auto
inset-block-start -> auto
inset-block-end -> auto
inline-size -> 1247px
image-rendering -> auto
image-orientation -> from-image
hyphens -> manual
height -> 3456px
grid-template-rows -> none
grid-template-columns -> none
grid-template-areas -> none
grid-row-start -> auto
grid-row-end -> auto
grid-column-start -> auto
grid-column-end -> auto
grid-auto-rows -> auto
grid-auto-flow -> row
grid-auto-columns -> auto
font-weight -> 400
font-variant-numeric -> normal
font-variant-ligatures -> normal
font-variant-east-asian -> normal
font-variant-caps -> normal
font-variant -> normal
font-style -> normal
font-stretch -> 100%
font-size -> 16px
font-optical-sizing -> auto
font-kerning -> auto
font-family -> "Times New Roman"
flood-opacity -> 1
flood-color -> rgb(0, 0, 0)
float -> none
flex-wrap -> nowrap
flex-shrink -> 1
flex-grow -> 0
flex-direction -> row
flex-basis -> auto
filter -> none
fill-rule -> nonzero
fill-opacity -> 1
fill -> rgb(0, 0, 0)
empty-cells -> show
dominant-baseline -> auto
display -> block
direction -> ltr
d -> none
cy -> 0px
cx -> 0px
cursor -> auto
content -> normal
column-width -> auto
column-span -> none
column-rule-width -> 0px
column-rule-style -> none
column-rule-color -> rgb(0, 0, 0)
column-gap -> normal
column-count -> auto
color-rendering -> auto
color-interpolation-filters -> linearrgb
color-interpolation -> srgb
color -> rgb(0, 0, 0)
clip-rule -> nonzero
clip-path -> none
clip -> auto
clear -> none
caret-color -> rgb(0, 0, 0)
caption-side -> top
buffered-rendering -> auto
break-inside -> auto
break-before -> auto
break-after -> auto
box-sizing -> content-box
box-shadow -> none
bottom -> auto
border-top-width -> 0px
border-top-style -> none
border-top-right-radius -> 0px
border-top-left-radius -> 0px
border-top-color -> rgb(0, 0, 0)
border-right-width -> 0px
border-right-style -> none
border-right-color -> rgb(0, 0, 0)
border-left-width -> 0px
border-left-style -> none
border-left-color -> rgb(0, 0, 0)
border-inline-start-width -> 0px
border-inline-start-style -> none
border-inline-start-color -> rgb(0, 0, 0)
border-inline-end-width -> 0px
border-inline-end-style -> none
border-inline-end-color -> rgb(0, 0, 0)
border-image-width -> 1
border-image-source -> none
border-image-slice -> 100%
border-image-repeat -> stretch
border-image-outset -> 0
border-collapse -> separate
border-bottom-width -> 0px
border-bottom-style -> none
border-bottom-right-radius -> 0px
border-bottom-left-radius -> 0px
border-bottom-color -> rgb(0, 0, 0)
border-block-start-width -> 0px
border-block-start-style -> none
border-block-start-color -> rgb(0, 0, 0)
border-block-end-width -> 0px
border-block-end-style -> none
border-block-end-color -> rgb(0, 0, 0)
block-size -> 5292px
baseline-shift -> 0px
background-size -> auto
background-repeat -> repeat
background-position -> 0% 0%
background-origin -> padding-box
background-image -> url("http://localhost/test/image.jpg")
background-color -> rgba(0, 0, 0, 0)
background-clip -> border-box
background-blend-mode -> normal
background-attachment -> scroll
backface-visibility -> visible
backdrop-filter -> none
appearance -> none
animation-timing-function -> ease
animation-play-state -> running
animation-name -> none
animation-iteration-count -> 1
animation-fill-mode -> none
animation-duration -> 0s
animation-direction -> normal
animation-delay -> 0s
alignment-baseline -> auto
align-self -> auto
align-items -> normal
align-content -> normal
Imágen de perfil

Funcion para determinar si dos arrays son iguales en C#


C sharp

Publicado el 16 de Marzo del 2021 por Joan (121 códigos)
1.453 visualizaciones desde el 16 de Marzo del 2021
Función en C Sharp para determinar si dos arrays o vectores son iguales, permitiendo especificar si tiene en cuenta o no la misma posición dentro del array.

1
2
3
4
El array '1 2 3 4' y '5 6 7 8' No son iguales
El array '1 2 3 4' y '1 2 3 4' Son iguales
El array '1 2 3 4' y '1 3 4 2' Son iguales
El array '1 2 3 4' y '1 3 4 2' No son iguales