
Show HN: GoCode.io – A Golang Game in the Browser - everdev
https://www.gocode.io/operation-go
======
abbeyj
This was pretty enjoyable. It reminds me a bit of "return true to win"
([https://alf.nu/ReturnTrue](https://alf.nu/ReturnTrue)).

I think I cheated a bit on Level 7. I just copy-pasted the code that wrote to
epochComms and changed it to write to interceptComms instead. I'm not quite
sure what the intended solution is.

On Level 12, does Secret.extHash serve any purpose? It never gets read.

I was doing this on mobile (Chrome on Android) and I ran into a few odd
problems. If you have two opening curly braces in a row and try to backspace
to delete the first one, it instead inserts a newline and duplicates the rest
of the line. That is, if you have "{{foo" with the cursor after the first
curly brace and you press backspace you end up with two lines each saying
"{foo". This doesn't happen for me on desktop.

Copy-paste also seems to be broken on mobile. You can't select anything and
trying to paste is just ignored.

It would be nice if you go go back and view the hint after you've completed a
level. Or even if you could try different solutions to a level after you've
finished it. You may not always be happy with the first thing that works.

~~~
everdev
Thanks for the feedback!

It uses the Ace Editor: [https://ace.c9.io/](https://ace.c9.io/)

I couldn't find a more mobile friendly code editor, but I'm happy to test out
other recommendations as I'd love for it to be enjoyable on mobile too.

~~~
thesephist
You've probably run across it and maybe even tried it, but I use CodeMirror
for Codeframe [0] and it works well on the every mobile device I've tested on,
and is pretty customizable.

[0] [http://beta.codeframe.co/](http://beta.codeframe.co/)

------
K0SM0S
Very cool! I like that you don't actually _fix_ bad code, you just _hack_ the
hell out of it to get to your objective.

It's a fun and refreshing way to look at code when you're usually always
striving for best practice, idiomatic, etc. Very game-y that way. :)

------
Thorrez
The idea that Epoch writes code under the fear that other parts of the code
are malicious reminded me of

[https://thedailywtf.com/articles/Confessions-Hacker-Proof-
Bo...](https://thedailywtf.com/articles/Confessions-Hacker-Proof-Boolean)

------
empressplay
Cool, but I can't seem to edit the code using Vivaldi, Chrome, Firefox or
Safari (or anything?)

~~~
jxub
Me neither (and I don't have JS blocked or anything). Still can run the code
though.

~~~
everdev
Are you editing the code on the white background? Only certain sections are
editable.

------
fred256

        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?

~~~
re
The story is a little misleading -- the correct sequence is not in fact
"sitting right there in the code."

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/](https://rot13.com/)

~~~
DuskStar
Thanks for the help! Though I would have phrased the first hint as "Gur
qrfverq beqre vf gur beqre va juvpu gur tbebhgvarf ner rkrphgrq"

------
ddlutz
Maybe I'm an idiot, but I don't really get what level two is asking. I "solved
it" in one line by directly returning the two numbers it's looking for. But
that doesn't seem right at all.

~~~
xmprt
If it works then that's probably right. Based on the hint I'm guessing they
want you to set up meters and seconds such that if flows through the if
statement but that seems a bit pointless.

------
xwowsersx
I tried typing full on mobile and it just kept deleting words.

~~~
xwowsersx
Tried on Chrome and FF on Android. Can't type in either.

------
n1try
Very cool hacking challenge! I solved all 12 levels with only looking at the
very last hint... and "wasted" half of my Sunday :-D

------
TheDong
This game reminds me a lot of untrusted [0], though it seems to be much less
polished, and the solutions feel less interesting and elegant.

[0]:
[https://alexnisnevich.github.io/untrusted/](https://alexnisnevich.github.io/untrusted/)

~~~
everdev
Yes, I was inspired by it. It's a great game. Did you finish GoCode? The
problems do get more challenging.

~~~
TheDong
Yup, assuming the Finale with rob is all there is to it. A couple of them were
trickier (like in level 9, it was really not clear at all what the right
output was supposed to be at first), but none of them seemed all that hard.
None of them actually felt "fun".

I think it mostly felt less polished due to things like the lack of music and
the fact that Go itself is a bad language for this sort of thing.

In Untrusted, there were often places where you could monkey-patch objects and
come up with really creative solutions. There were some problems that I felt
like I really had freedom to be creative.

In this game, the imports were always out of bounds for editing, so I could
never pull in 'unsafe' and have any real fun. All the solutions felt far too
restrictive. Sure, there were multiple ways to hack around things, but it
never felt like there was room for a spark of real creative joy.

I think go is just a bad language for "fun". It's not optimized for being able
to write interesting or elegant code. It's not optimized for having fun.

~~~
shurcooL
Not to discount your point, but I want to offer my opinion which is different.

I had fun _because_ it was more constrained. But I also like Go.

As an example, I solved level 6 in what I understand to be an unconventional
way:

(spoiler alert)

I realized I could “get out” of readCodesFromKeypad function scope by ending
it early and then writing the start of another top level function. Once I had
access to global scope, I could add an init() function to modify the
“crypto/rand.Reader” variable and assign to it an io.Reader that I could
control. I was on mobile so I decided to take a shortcut and just overwrite
the global passcode variable instead.

(end spoiler)

I may have “cheated”, but it felt creative and in spirit of the game, and it
got me to the next level.

~~~
shhsshs
I just added two lines to the starting brute-force code:

    
    
        if v, _ := validateCode(passcode); v == 1 {
            return []string{passcode}
        }

~~~
shurcooL
Yep. Based on the hint for that question, I expect this is the "normal"
solution.

~~~
roskilli
Oh heh, I declared another method then used that to set the passcode var
(without the var being shadowed), return it to the hardcoded method name, and
returned that.

    
    
      // readCodesFromKeypad - get codes from keypad input
      func readCodesFromKeypad() []string {
       var passcode string
       var codes = make([]string, 0)
      
      // Agent Getter - bypass keypad input
       // codes := streamKeypad()
      
      // Agent Getter - try brute force login
       // TODO: not finished, someone's coming...
    
          // use shadowed "passcode" to avoid unused var error
          return append([]string{passcode}, unshadowedMethod()...}[1:]
      }
      
      func unshadowedMethod() []string {
          codes := []string{passcode}
      
       return codes
      }

------
danschumann
Mission 4? I should probably be overriding the interface or something right?
gotta get a record function in there somehow.. not as easy as `camera.record =
() => { return 'Idle' }`

~~~
everdev
You're on the right track :)

In the top right, there's a lightbulb you can click to reveal a hint for each
mission. For this level the tip says "RecordingDevice is an interface, so it
should be possible to create your own type of Camera".

On Reddit there's a thread that also contains some additional tips for some of
the missions:
[https://www.reddit.com/r/golang/comments/c2hsaj/operation_go...](https://www.reddit.com/r/golang/comments/c2hsaj/operation_go_programming_game_in_the_browser/)

------
ReverseCold
Everything until 12 was something that I could sort of get without knowing Go,
and then the difficulty magically jumped (which is subjective, but still).

~~~
xmprt
I'm surprised you got things like `init()`, interfaces, json.Marshal, and
channels without knowing Go. I'm assuming you looked things up/used hints?

------
wizardo
Are solutions listed anywhere ?

~~~
everdev
Not officially, but there are some here:
[https://www.reddit.com/r/golang/comments/c2hsaj/operation_go...](https://www.reddit.com/r/golang/comments/c2hsaj/operation_go_programming_game_in_the_browser/)

------
CriticalCathed
Solutions listed anywhere? I'm curious what the expected solutions are.

------
johnmwilkinson
Fun, but terrible on mobile

~~~
Thorrez
Is there any programming that isn't terrible on mobile?

