Skip to content

Commit 56c4786

Browse files
committed
Merge branch 'main' of github.com:mouredev/roadmap-retos-programacion
2 parents a834fd9 + 771ca76 commit 56c4786

File tree

5 files changed

+1201
-677
lines changed

5 files changed

+1201
-677
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// https://www.javascript.com/
2+
3+
// comentario de una linea
4+
/**
5+
* comentario de varias lineas
6+
*/
7+
8+
let myAge = 21;
9+
const myName = 'josh'
10+
let myNumber = 33;
11+
let MyStrin = 'hola';
12+
let falso = false;
13+
let noDefinido;
14+
let nulo = null;
15+
16+
17+
console.log('hola javascript');
18+
console.log(`tengo ${myAge} anos`);
19+
console.log(`mi nombre es ${myName}`);
20+
console.log(`${myNumber} es un numero`);
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
program operadores
2+
implicit none
3+
integer :: a, b, n, mes
4+
real :: radio
5+
6+
print *, 'Estructuras de Control en Fortran'
7+
print *, 'Estructuras Alternativas'
8+
print *, 'Estructura Alternativa Simple (if-then)'
9+
10+
a = 5; b = 10
11+
if (a < b) then
12+
print *, a, ' es menor que ', b
13+
end if
14+
15+
print *, 'Estructura Alternativa Doble (if-then-else)'
16+
17+
b = 4
18+
if (a < b) then
19+
print *, b, ' es menor que ', a
20+
else
21+
print *, a, ' es mayor que ', b
22+
end if
23+
24+
print *, 'Estructura Multialternativa (case)'
25+
print *, 'Digite el número del mes: '
26+
read *, mes
27+
print *, 'El mes digitado tiene '
28+
select case (mes)
29+
case (1, 3, 5, 7, 8, 10, 12)
30+
print *, '31'
31+
case (4, 6, 9, 11)
32+
print *, '30'
33+
case (2)
34+
print *, '28'
35+
case default
36+
print *, 'Mes incorrecto'
37+
end select
38+
39+
print *, ''
40+
print *, '***********************'
41+
print *, 'Estructuras Repetitivas'
42+
print *, '***********************'
43+
print *, ''
44+
print *, 'Estructura desde hasta (do)'
45+
do n = 1, 10, 2
46+
print *, n
47+
end do
48+
print *, 'Estructura Mientras (do-while)'
49+
radio = -1
50+
do while (radio < 0) ! Se solicita el radio hasta que sea positivo
51+
print *, 'Digite Radio?(Debe ser positivo)'
52+
read *, radio
53+
end do
54+
55+
print *, ''
56+
print *, '**********'
57+
print *, 'RETO EXTRA'
58+
print *, '**********'
59+
print *, ''
60+
do n = 10, 55, 1
61+
if (mod(n, 2) == 0 .and. n /= 16 .and. mod(n, 3) /= 0) then
62+
print *, n
63+
end if
64+
end do
65+
end program operadores
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import java.text.SimpleDateFormat
2+
3+
/*
4+
Las funciones de orden superior son cuyas funciones que pueden recibir una funcion como argumento
5+
o devolver una funcion como resultado.
6+
7+
usos comunes de la funcion de orden superior son el manejo de listas, map, filter, etc.
8+
9+
las funciones de orden superior no mutan las listas originales dan como resultado una nueva lista
10+
por lo cual la mutabilidad se mantiene al minimo.
11+
12+
*/
13+
14+
fun exampleWithOrderSuperiorFunc(){
15+
16+
val list = listOf(1,2,3,4,5,6,7,8,9,10)
17+
println("list of kotlin $list")
18+
19+
// usando map para generar un nuevo resultado este puede recibir una lambda funcion como argumento
20+
val newList = list.map { it * 2 }
21+
println("list of map kotlin $newList")
22+
23+
// forma imperativa
24+
fun multiplyBy2(x:Int):Int = x * 2
25+
26+
fun multipyNumber(listNum:List<Int>, func : (Int) -> Int): List<Int>{
27+
val listResult = mutableListOf<Int>()
28+
for (num in listNum){
29+
listResult.add(func(num))
30+
}
31+
return listResult
32+
}
33+
34+
val newList2 = multipyNumber(list,::multiplyBy2)
35+
println("list of my own function $newList2")
36+
37+
// lambda function
38+
val newList3 = multipyNumber(list){it * 3}
39+
println("list of lambda function $newList3")
40+
41+
}
42+
43+
// ejercicio extra
44+
45+
data class Student(val name:String,val birthDate:String,val scores:List<Int>)
46+
47+
val listOfStudents = listOf(
48+
Student("rodolfo","20/05/1994", listOf(8,9,9,10,9,10)),
49+
Student("martin","27/05/1993", listOf(5,6,7,8,9,9)),
50+
Student("roswell","12/03/1992", listOf(9,7,7,8,0,8)),
51+
Student("salvador","22/04/1995", listOf(9,9,9,10,10,10)),
52+
Student("luis","01/01/1990", listOf(8,9,5,4,9,10))
53+
)
54+
55+
56+
fun calculateAverageScore(student:Student):Int{
57+
val total = student.scores.sum()
58+
return total / student.scores.size
59+
}
60+
61+
62+
63+
fun main() {
64+
exampleWithOrderSuperiorFunc()
65+
66+
// ejercicio extra
67+
val averageScore = listOfStudents.map { it.name to calculateAverageScore(it) }
68+
println("average score $averageScore")
69+
70+
val bestStudents= averageScore.filter { it.second >=9 }
71+
println("best students $bestStudents")
72+
73+
val youngStudents = listOfStudents.sortedByDescending { SimpleDateFormat("dd/MM/yyyy").parse(it.birthDate) }
74+
println("young students $youngStudents")
75+
76+
val majorScores= listOfStudents.map { it.name to it.scores.max() }
77+
println("major scores $majorScores")
78+
}

0 commit comments

Comments
 (0)