Skip to content

Instantly share code, notes, and snippets.

@jgomo3
Created August 1, 2022 01:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgomo3/34ab45c12a923da440a5c69098a67b83 to your computer and use it in GitHub Desktop.
Save jgomo3/34ab45c12a923da440a5c69098a67b83 to your computer and use it in GitHub Desktop.
Solución al ejercicio 2 de Blackbox
(ns jgomo3.playground.blackbox.bb2)
;; v1: No considera el hecho de que hay combinaciones de Rubik imposibles.
(def v1-rubik-base (flatten (map (partial repeat 9) (range 6))))
(defn v1-generar-cubo-rubik-aleatorio!
"Genera un arreglo de 54 casillas con 9 números repetidos cada uno 6
veces en un orden cualquiera"
[]
(shuffle v1-rubik-base))
(comment
v1-rubik-base ;; (0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5)
(v1-generar-cubo-rubik-aleatorio!) ;; [4 3 5 1 3 5 1 2 2 1 5 1 4 3 0 2 5 2 1 1 1 4 4 2 1 0 5 2 5 5 3 5 0 0 3 3 0 3 3 1 2 0 2 4 0 0 4 0 4 2 5 4 3 4]
(frequencies (v1-generar-cubo-rubik-aleatorio!))
;; => {5 9, 1 9, 0 9, 4 9, 2 9, 3 9}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment