Skip to content

Commit 4bb23ee

Browse files
committed
Resolución Reto #41 y enunciado Reto #42
1 parent 614eb80 commit 4bb23ee

File tree

4 files changed

+62
-3
lines changed

4 files changed

+62
-3
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ Tienes toda la información extendida sobre los retos de programación semanales
7474
* **#39** - 27/09/22 - [`TOP ALGORITMOS: QUICK SORT`](https://github.com/mouredev/Weekly-Challenge-2022-Kotlin/blob/main/app/src/main/java/com/mouredev/weeklychallenge2022/Challenge39.kt)
7575
* **#40** - 03/10/22 - [`TRIÁNGULO DE PASCAL`](https://github.com/mouredev/Weekly-Challenge-2022-Kotlin/blob/main/app/src/main/java/com/mouredev/weeklychallenge2022/Challenge40.kt)
7676
* **#41** - 10/10/22 - [`LA LEY DE OHM`](https://github.com/mouredev/Weekly-Challenge-2022-Kotlin/blob/main/app/src/main/java/com/mouredev/weeklychallenge2022/Challenge41.kt)
77-
* **#42** - 17/10/22 - `Publicación nuevo reto...`
77+
* **#42** - 17/10/22 - [`CONVERSOR DE TEMPERATURA`](https://github.com/mouredev/Weekly-Challenge-2022-Kotlin/blob/main/app/src/main/java/com/mouredev/weeklychallenge2022/Challenge42.kt)
78+
* **#43** - 24/10/22 - `Publicación nuevo reto...`
7879

7980
<a href="https://youtu.be/ydH_B5KuqGs"><img src="http://i3.ytimg.com/vi/ydH_B5KuqGs/maxresdefault.jpg" style="height: 50%; width:50%;"/></a>
8081

@@ -92,6 +93,10 @@ Tienes toda la información extendida sobre los retos de programación semanales
9293

9394
*Corección retos del 21 al 30 en vídeo*
9495

96+
<a href="https://youtu.be/8-IOU3Qlgws"><img src="http://i3.ytimg.com/vi/8-IOU3Qlgws/maxresdefault.jpg" style="height: 50%; width:50%;"/></a>
97+
98+
*Corección retos del 31 al 40 en vídeo*
99+
95100
### ¿Cómo puedo participar?
96101

97102
**Puedes hacer libremente un fork del proyecto y trabajar con Git para ir sincronizando las actualizaciones del proyecto.**

app/src/main/java/com/mouredev/weeklychallenge2022/Challenge33.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ fun main() {
3434

3535
private fun chineseZodiac(year: Int) : String {
3636

37-
val elements = arrayListOf<String>("madera", "fuego", "tierra", "metal", "agua")
38-
val animals = arrayListOf<String>("rata", "buey", "tigre", "conejo", "dragón", "serpiente", "caballo", "oveja", "mono", "gallo", "perro", "cerdo")
37+
val elements = arrayListOf("madera", "fuego", "tierra", "metal", "agua")
38+
val animals = arrayListOf("rata", "buey", "tigre", "conejo", "dragón", "serpiente", "caballo", "oveja", "mono", "gallo", "perro", "cerdo")
3939

4040
if (year < 604) {
4141
return "El ciclo sexagenario comenzó en el año 604."

app/src/main/java/com/mouredev/weeklychallenge2022/Challenge41.kt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.mouredev.weeklychallenge2022
22

3+
import java.text.DecimalFormat
4+
35
/*
46
* Reto #41
57
* LA LEY DE OHM
@@ -19,4 +21,33 @@ package com.mouredev.weeklychallenge2022
1921
*
2022
*/
2123

24+
fun main() {
25+
println(ohm())
26+
println(ohm(v = 5.0))
27+
println(ohm(v = 5.0, r = 4.0))
28+
println(ohm(v = 5.0, i = 4.0))
29+
println(ohm(r = 5.0, i = 4.0))
30+
println(ohm(v = 5.125, r = 4.0))
31+
println(ohm(v = 5.0, i = 4.125))
32+
println(ohm(r = 5.0, i = 4.125))
33+
println(ohm(v = 5.0, r = 0.0))
34+
println(ohm(v = 5.0, i = 0.0))
35+
println(ohm(r = 5.0, i = 0.0))
36+
println(ohm(v = 5.0, r = 4.0, i = 3.0))
37+
}
38+
39+
// V = R * I
40+
private fun ohm(v: Double? = null, r: Double? = null, i: Double? = null) : String {
41+
42+
val formatter = DecimalFormat("#.##")
43+
44+
if (v != null && r != null && i == null) {
45+
return "I = ${formatter.format(v / r)}"
46+
} else if (v != null && i != null && r == null) {
47+
return "R = ${formatter.format(v / i)}"
48+
} else if (r != null && i != null && v == null) {
49+
return "V = ${formatter.format(r * i)}"
50+
}
2251

52+
return "Invalid values"
53+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.mouredev.weeklychallenge2022
2+
3+
/*
4+
* Reto #42
5+
* CONVERSOR DE TEMPERATURA
6+
* Fecha publicación enunciado: 17/10/22
7+
* Fecha publicación resolución: 24/10/22
8+
* Dificultad: FÁCIL
9+
*
10+
* Enunciado: Crea una función que transforme grados Celsius en Fahrenheit y viceversa.
11+
* - Para que un dato de entrada sea correcto debe poseer un símbolo "°" y su unidad ("C" o "F").
12+
* - En caso contrario retornará un error.
13+
* - ¿Quieres emplear lo aprendido en este reto?
14+
* Revisa el reto mensual y crea una App: https://retosdeprogramacion.com/mensuales2022
15+
*
16+
* Información adicional:
17+
* - Usa el canal de nuestro Discord (https://mouredev.com/discord) "🔁reto-semanal"
18+
* para preguntas, dudas o prestar ayuda a la comunidad.
19+
* - Tienes toda la información sobre los retos semanales en
20+
* https://retosdeprogramacion.com/semanales2022.
21+
*
22+
*/
23+

0 commit comments

Comments
 (0)