by fred256 · 6y ago · 0 comments
var buttons = []string{"red", "blue", "green", "yellow", "purple"}
> go run level_9.go
Sending Code Sequence...
1 : red
2 : blue
3 : green
4 : yellow
5 : purple
Sorry, that's not correct
Not sure what the correct sequence is, if not that?I "cheated" on some questions by causing the correct output to be printed without actually doing what the instructions recommend, but in this case, the path of the least resistance is probably to follow the instructions, including leveraging what the lightbulb hint recommends.
Additional Hint 1: Tbebhgvarf nera'g arprffnevyl rkrphgrq va gur beqre gung gurl'er fgnegrq
Additional Hint 2: Qb nf gur vafgehpgvbaf naq uvag fhttrfg naq svk gur enpr pbaqvgvba ol hfvat n zhgrk gb rafher gung bayl bar tbebhgvar ng n gvzr fyrrcf naq gura nccraqf gb gur neenl
Additional Hint 3: Lbh pna eranzr gur frgOhggba zrgubq naq znxr lbhe bja ercynprzrag gung pnyyf gur byq bar
If you want to "cheat": hfr lbhe oebjfre pbafbyr gb frr gur .tb svyrf gung ner ybnqrq juvpu pbagnva gur fgbel, pbqr, naq pbeerpg bhgchg.
Decode hints with https://rot13.com/
But I guess that's not what they were after, the solution was indeed as simple as:
z.Ybpx()
qrsre z.Haybpx()It's a bit annoying that it's depending on such an incidental behavior.
> var buttons = []string{"red", "blue", "green", "yellow", "purple"}
The obvious way to solve it in order to get the answer shown in the source code is
if x == 0 {
*sequence = []Button{{"red"}, {"blue"}, {"green"}, {"yellow"}, {"purple"}}
}
return
This way there is nothing concurrently touching sequence, nor is there anything concurrent touching rand, nor is anything relying on goroutine starting order, nor are there other race conditions. But yet the site says this is wrong.How do we know how the puzzle is executed?
And if you're saying some guarantee exists that the last executes first, then the rest execute in order, that's empirically false:
https://play.golang.org/p/3gV0TYG4GQW
1000
773
774
775
776
...