forked from mouredev/retos-programacion-2023
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Llamar a una API es una de las tareas más comunes en programación. | ||
* | ||
* Implementa una llamada HTTP a una API (la que tú quieras) y muestra su | ||
* resultado a través de la terminal. Por ejemplo: Pokémon, Marvel... | ||
* | ||
* Aquí tienes un listado de posibles APIs: | ||
* https://github.com/public-apis/public-apis | ||
*/ | ||
|
||
import 'dart:convert'; | ||
import 'dart:io'; | ||
import 'package:http/http.dart' as http; | ||
|
||
void main(){ | ||
fetchData(); | ||
} | ||
|
||
fetchData() async { | ||
var url = 'https://dog.ceo/api/breeds/list/all'; | ||
var httpClient = new HttpClient(); | ||
var request = await httpClient.getUrl(Uri.parse(url)); | ||
var response = await request.close(); | ||
var responseBody = await response.transform(utf8.decoder).join(); | ||
var data = jsonDecode(responseBody); | ||
print(data); | ||
} |
42 changes: 42 additions & 0 deletions
42
Retos/Reto #9 - HETEROGRAMA, ISOGRAMA Y PANGRAMA [Fácil]/dart/thegera4.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Crea 3 funciones, cada una encargada de detectar si una cadena de | ||
* texto es un heterograma, un isograma o un pangrama. | ||
* - Debes buscar la definición de cada uno de estos términos. | ||
*/ | ||
|
||
void main() { | ||
String texto = 'El veloz murciélago hindú comía feliz cardillo y kiwi.'; | ||
print('Heterograma: ${esHeterograma(texto)}'); | ||
print('Isograma: ${esIsograma(texto)}'); | ||
print('Pangrama: ${esPangrama(texto)}'); | ||
} | ||
|
||
bool esHeterograma(String texto) { | ||
texto = texto.toLowerCase(); | ||
for (int i = 0; i < texto.length; i++) { | ||
if (texto[i] == ' ') continue; | ||
for (int j = i + 1; j < texto.length; j++) { | ||
if (texto[i] == texto[j]) return false; | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
bool esIsograma(String texto) { | ||
texto = texto.toLowerCase(); | ||
for (int i = 0; i < texto.length; i++) { | ||
if (texto[i] == ' ') continue; | ||
for (int j = i + 1; j < texto.length; j++) { | ||
if (texto[i] == texto[j]) return false; | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
bool esPangrama(String texto) { | ||
texto = texto.toLowerCase(); | ||
for (int i = 97; i <= 122; i++) { | ||
if (!texto.contains(String.fromCharCode(i))) return false; | ||
} | ||
return true; | ||
} |