Skip to content

Instantly share code, notes, and snippets.

@rossdylan
Last active January 10, 2021 05:38
Show Gist options
  • Save rossdylan/c647feabb70f52b5fa50 to your computer and use it in GitHub Desktop.
Save rossdylan/c647feabb70f52b5fa50 to your computer and use it in GitHub Desktop.
wat
func sleep_cry_pumpkin_snake(horse_ghost_cd_camcorder: [[String]]) -> Void {
var whale_cat_mailbox_flag_symbols = [Int](count: horse_ghost_cd_camcorder.count, repeatedValue: 0)
var shooting_star = 0
ambulance_horse(horse_ghost_cd_camcorder, whale_cat_mailbox_flag_symbols)
while true {
if shooting_star >= horse_ghost_cd_camcorder.count {
return
} else if whale_cat_mailbox_flag_symbols[shooting_star] < horse_ghost_cd_camcorder[shooting_star].count - 1 {
ant_pigsnout_penguin_monkey(&whale_cat_mailbox_flag_symbols, shooting_star)
whale_cat_mailbox_flag_symbols[shooting_star] += 1
shooting_star = 0
} else {
shooting_star += 1
continue
}
ambulance_horse(horse_ghost_cd_camcorder, whale_cat_mailbox_flag_symbols)
}
}
func ambulance_horse(horse_ghost_cd_camcorder: [[String]], whale_cat_mailbox_flag_symbols: [Int]) -> Void {
for(hatching_chick, ambulance_horse) in enumerate(horse_ghost_cd_camcorder) {
print(ambulance_horse[whale_cat_mailbox_flag_symbols[hatching_chick]] + " ")
}
println()
}
func ant_pigsnout_penguin_monkey(inout whale_cat_mailbox_flag_symbols: [Int], shooting_star: Int) -> Void {
for hatching_chick in 0..<shooting_star {
whale_cat_mailbox_flag_symbols[hatching_chick] = 0
}
}
func ladybug_dolphin_whale() {
sleep_cry_pumpkin_snake([["Bob", "Jill", "John"], ["has", "had"], ["dog", "lizard", "cat"]])
}
ladybug_dolphin_whale()
@harlanhaskins
Copy link

Why did you do this to yourself???

@harlanhaskins
Copy link

let words = [["Bob", "Jill", "John"], ["has", "had"], ["dog", "lizard", "cat"]]
let names = words[0]
let verbs = words[1]
let animals = words[2]
for animal in animals {
    for verb in verbs {
        for name in names {
            println("\(name) \(verb) \(animal)")
        }
    }
}

@SawyerHood
Copy link

Or better yet, a recursive version:

func perm(lists: [[String]], prefix: String) {
    if lists.count == 0 {
        println(prefix)
        return
    }
    let first = lists.first
    let rest = Array(lists[1..<lists.count])
    if let words = first {
        for word in words {
            perm(rest, prefix + " " + word)
        }
    }
}

perm([["Bob", "Jill", "John"], ["has", "had"], ["dog", "lizard", "cat"]], "")

@fuhry
Copy link

fuhry commented Oct 10, 2014

I would expect CSHers to be behind something like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment