Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
TP-Kotlin-miguel
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Miguel Do Carmo
TP-Kotlin-miguel
Commits
a1687700
Commit
a1687700
authored
Apr 14, 2020
by
Miguel Do Carmo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
archivo kotlin de el ejercicio de GENERALA
parent
ad5bd895
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
+62
-0
src/codigos/java-e003-generala.kt
+62
-0
No files found.
src/codigos/java-e003-generala.kt
0 → 100644
View file @
a1687700
package
codigos
import
java.util.ArrayList
import
java.util.Scanner
import
java.io.File
fun
main
()
{
val
g
=
readLine
()
!!
.
toCharArray
()
//convierte automaticamente lo leido a un array de Chars
g
.
sort
()
//Metodo de ordenamiento de arrays
println
(
jugada
(
g
))
// ESTO SI SE EJECUTA PARA USTEDES
}
// ESTA ES LA FUNCIÓN QUE HAY QUE IMPLEMENTAR
// TAMBIÉN PUEDEN AGREGAR OTRAS FUNCIONES y/o CLASES
// QUE NECESITEN PARA RESOLVER EL EJERCICIO DE LA
// MANERA MÁS ORDENADA POSIBLE
fun
jugada
(
dados
:
CharArray
)
:
String
?
{
val
primerElement
=
dados
[
0
]
var
caraDados
=
intArrayOf
(
0
,
0
,
0
,
0
,
0
,
0
)
///////************* guarda el valor de la jugada
for
(
element
in
dados
)
{
val
nroConvertido
=
Character
.
getNumericValue
(
element
)
if
(
nroConvertido
in
0
..
6
)
caraDados
[
nroConvertido
-
1
]++
else
return
"INVALIDO"
}
var
result
:
String
?
=
null
var
tieneTrio
=
false
var
tieneDoble
=
false
val
primerValor
=
Character
.
getNumericValue
(
dados
[
0
])
var
valorDado
=
0
if
(
dados
.
size
==
5
)
{
for
(
valor
in
caraDados
)
{
//------------> Busca dentro del array que explica de otra manera la jugada que a salido
if
(
valor
==
5
)
result
=
"GENERALA"
if
(
valor
==
4
)
result
=
"POKER"
if
(
valor
==
3
)
tieneTrio
=
true
if
(
valor
==
2
)
tieneDoble
=
true
if
(
tieneDoble
&&
tieneTrio
)
result
=
"FULL"
if
(
valor
==
1
)
{
for
(
indice
in
0
..
4
)
{
valorDado
=
primerValor
-
(
Character
.
getNumericValue
(
dados
[
indice
])
-
indice
)
}
if
(
valorDado
==
0
||
(
caraDados
[
0
]==
1
&&
caraDados
[
1
]==
0
&&
caraDados
[
2
]
==
1
&&
caraDados
[
3
]==
1
&&
caraDados
[
4
]==
1
&&
caraDados
[
5
]==
1
))
{
result
=
"ESCALERA"
break
}
}
}
}
else
{
result
=
"INVALIDO"
}
return
result
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment