#Challenge 15

1 messages · Page 1 of 1 (latest)

analog star
digital niche
#

debe bajar siempre hacia abajo — midudev 😬

silk notch
#

yo lo veo bien, no deja lugar a dudas

pearl tendon
#

Reto 15

ionic loom
#

Challenge 15, un poco largo, pero funciona 🙂

#

La forma que se me ocurrió a mi fue partir en dos el array original, excluyendo el punto más alto y luego verificar si esos dos arrays suben y bajan consecutivamente. Que otra forma se les ocurrió a ustedes? 👀

grand nebula
#

Reto #15
Belleza y locura funcional. Amor y odio.

export default function checkSledJump(heights) {
  const topHeightIndex = heights.indexOf( Math.max( ...heights ) )
  const upHeights = heights.slice( 0, topHeightIndex + 1 )
  const downHeights = heights.slice( topHeightIndex + 1 )
  const up = ( num1, num2 ) => num1 < num2
  const down = ( num1, num2 ) => num1 > num2
  const isGoing = comparatorFn => ( _, i, list ) => ( i === list.length - 1 ) ? true : comparatorFn( list[ i ], list[ i + 1 ] )
  const check = isGoingFn => list => list.length > 0 && list.every( isGoingFn )
  return check( isGoing( up ) )( upHeights ) && check( isGoing( down ) )( downHeights )
}
zinc mulch
#

Este me quedo un poco largo, pero creo que se entiende bien. No será el mejor, pero funciona!
||```js
function checkSledJump(heights) {
if (heights.length < 3) return false
const max = Math.max(...heights)
const maxIdx = heights.findIndex(item => item === max)

const ascHeights = heights.slice(0, maxIdx + 1)
const descHeights = heights.slice(maxIdx)

if (ascHeights.length <= 1) return false
if (descHeights.length <= 1) return false

const distinctAscHeights = [...new Set(ascHeights)]
const distinctDescHeights = [...new Set(descHeights)]

if (JSON.stringify(ascHeights) !== JSON.stringify(distinctAscHeights)) return false
if (JSON.stringify(descHeights) !== JSON.stringify(distinctDescHeights)) return false

if (JSON.stringify(ascHeights) !== JSON.stringify(ascHeights.sort())) return false
if (JSON.stringify(descHeights) !== JSON.stringify(descHeights.sort((a, b) => b - a))) return false

return true
}

grand nebula
zinc mulch
#

Sii, lo vi en la tuya y dije: auch!

grand nebula
# pearl tendon Reto 15

Sencilla, clásica y eficiente. 👏 La programación funcional nos va a joder la vida a muchos 😅 (yo no soy muy fan, pero la verdad es que en este caso he querido abusar de ella, por tocar las narices, básicamente 😆 )

fresh token
uncut sonnet
digital niche
#

Primera versión, posiblemente lo revise nuevamente más tarde para ver qué se puede mejorar

nimble zephyr
#

Reto 15

silk notch
#

Solución día 15, sin complicarme la vida

lost olive
#

Reto 15

analog violet
#

Solución Reto 15

jovial salmon
#

Reto 15 :3

grand nebula
lost olive
# uncut sonnet

Como se llama la app para tomar esos screnshots de código?

jovial salmon
fleet kraken
true moss
timid adder
#

Ahí va mi solución al reto 15 🦘

grand nebula
grand nebula
median flint
#

Esta es mi solución para el reto

lost olive
golden night
#

Mi solucion, bueno tambien lo hice rapido como ayer, porque la U no me da tiempo para analizar bien las cosas xD

#

Mi otra solucion

tidal cosmos
#

mi solucion para el dia, reto 15 ajjjaaj realmente no es la mejor solucion pero hoy no alcanzo a refactorizar asi que anyway jajaj

neat schooner
hushed ridge
#

Mi solución 🙂