

Developer only event at SXSW (code puzzle gets harder with more tweets) - nathanh
http://hackerunderground.com

======
redredraider

       $data = "http://hackerunderground.com/solution/blank;
       $ch = curl_init($data); 
       curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
       $base = curl_exec($ch);
    
       for($i=0;$i<10000;$i++)
       {
       $data = "http://hackerunderground.com/solution/$i;
       $ch = curl_init($data); 
       curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
       $response = curl_exec($ch); 
       if($response != $base)
       {
       echo $i;
       }
       }
    
    
    

I like my solution best. Everyone should try it!

~~~
jkkramer
I like how it keeps going even after it finds the solution.

~~~
redredraider
Haha my bad.

------
acgourley
I'm also throwing a hacker only event.

It's called stay home and get shit done.

~~~
emilis_info
Two years ago such a comment would have -2 votes and would be hidden just
because of its tone.

Sorry for the meta, but I am missing the old HN.

I doubt we would be able to have the whole front page dedicated just to Erlang
news if the need appeared.

It seems that the problem of maintaining quality of discussion in an open
forum remains unsolved.

Maybe limits to entry (like the problem in the link) or ability to provide
negative feedback to posters would help.

~~~
bostonpete
How would a comment pining for the days of yore have fared two years ago?

~~~
emilis_info
Even worse.

------
Klonoar
So just to summarize:

Elite 'hacker' group claims to hate marketing guru/bullshit tactics, then
proceeds to ply the hell out of everyone to spread their concept in a viral
Twitter hashtag manner.

Granted, I totally just did it because that puzzle was way too easy, but c'mon
now.

~~~
ejames
In that sense, at least, the event is being held by people who understand the
hack mindset. I noticed that the puzzle was very easy, and that the "elite
hackers" are in fact a recruitment agency, and therefore that the main purpose
of the event is probably for a recruitment agency to put their recruiters in
the middle of a bunch of hackers while eliminating competing recruiters who
have the same goal.

... but I still did the puzzle.

[edit] And everyone else is doing it too, and posting their solutions here!
"Blazing guitarpocalypse"[1] indeed.

I might attend the event, but that's mostly because I'm in Austin and feeling
curious, and not because the website convinces me the event will have a high
quality.

[1][http://www.codinghorror.com/blog/2007/02/fizzbuzz-the-
progra...](http://www.codinghorror.com/blog/2007/02/fizzbuzz-the-programmers-
stairway-to-heaven.html)

------
cstuder
I wonder if having to manually launch the puzzles show() method is part of the
puzzle itself or just a bug. (Checked with Chrome 9 and Firefox 3).

~~~
goldins
Looks like pressing ESC invokes the puzzle.

~~~
jjcm
It has a keypress event tied to it, but it didn't trigger for me. I had to
manually invoke $('the_puzzle').show().

------
colinsidoti
The ways everyone solves the puzzle are much more interesting than the puzzle
itself. I made a mysql table with one column set as the primary key and did an
insert.

This reminds me of this awesome thread on Sitepoint (5 pages of different ways
to output the numbers 0-9): [http://www.sitepoint.com/forums/php-34/write-
loop-php-prints...](http://www.sitepoint.com/forums/php-34/write-loop-php-
prints-numbers-0-9-page-580793.html)

------
mickdarling
Well now they are asking for Prime duplicates, and if they keep it going fo
the next week, you could end up with some complex puzzles.

------
zdw
Not going to SXSW, but...

    
    
         tr ',' '\n' | sort -n | uniq -d

~~~
RodgerTheGreat
It's also pretty easy to do in Excel, favored tool of "marketing gurus".
Find/replace, import, pivot.

~~~
josegonzalez
I actually found a solution for it in excel before writing the following:

    
    
      asort($data);
      $duplicate = function ($val) use (&$data) {
        $count = 0;
        foreach ($data as $i => $entry)
          if ($val == $entry) $count++;
        return $count;
      };
    
      foreach ($data as $v)
        if (($count = $duplicate($v)) > 1) {
          printf("%d, Count %d\n", $v, $count);
          break;
        }
    

I assume it would be possible to use a sort+callback to return the value as
well.

~~~
jeresig
sort + callback is what I did in JavaScript:

    
    
        .sort(function(a,b){if(a==b){throw a;}return a-b;});

~~~
josegonzalez
Did you eval the dom to get the dataset?

~~~
false
I did :)

    
    
      JSON.parse(p.innerHTML.split('\n')[2])

------
51Cards
Text editor, break into lines, numeric sort, find the line where the count
goes out of sync with the line number.

------
primodemus
C#: data.GroupBy(i => i).Where(g => g.Count() > 1) .Select(g => g.Key)
.ToList().ForEach(x => Console.WriteLine(x));

------
tjarratt
node.js + underscore.js

var numbers = [];

require("./underscore-min.js"); var dupe = _.reject(numbers, function(number)
{ return _.lastIndexOf(numbers, number) == _.indexOf(numbers, number); });
console.log(dupe);

------
krisrak
solved it with no code by copying and opening as csv, transpose paste, sort,
scroll to match column number with number, check for mismatch, bingo!

------
janoulle
I'm learning Python (3) w/ MIT OCW and here's my solution
(<http://pastebin.com/EQevWQWC>). def dupefinder(lister): '''Function to find
first duplicate in a list; Variable to pass to this function should be of type
"list" ''' listerdupe = sorted(lister) for index,item in
enumerate(listerdupe): if item == listerdupe[index+1]: print('First duplicate
number is {0}'.format(item)) return item

------
matlaber
Open Matlab --> answer = mode(Copy --> Paste)

------
annon
Open up web inspector.

var arr = (paste)

arr.sort()

for(var i = 0;i<arr.length;i++){if(arr[i+1] == arr[i]){console.log(arr[i])}}

~~~
mitjak
Or the recursive version, upon sorting:

    
    
      function find_dupe(a){ if(a.length==0) return -1; 
      if (a[0]==a[1]) return a[0]; else return find_dupe(a.slice(1,a.length)); }
    

BTW, are loops more efficient than recursion in JS? It sure seems like a lot
of JS libraries out there including jQuery avoid recursion like plague.

~~~
annon
For recursion vs. looping, it really depends on what you're doing. In my js
experience though, most of the time looping is either faster or equal to
recursion, while being significantly easier to understand at a quick glance.

In this case, the loop will outperform recursion because of all of the slice
calls in the recursive version.

------
dotBen
Since they changed the puzzle to now require finding the prime duplicate
number.

Is is each number delimited by a (random?) alphabetic letter? Is this to make
parsing into Excel/an array harder?

Also, even the new 'harder' puzzle is easy to solve in Excel. Maybe that isn't
a bad thing, however.

------
whalesalad
Solved the puzzle with a couple lines of Python ;) Unfortunately, I won't be
attending SXSW this year. Boo. If someone can solve that puzzle, I'll teach
you all the hacks I know.

------
ptarjan
What day is the event?

~~~
swGooF
You need to solve the puzzle or are you joking?

------
zackattack
the lemons of this string when you take out all of the spaces and align the
words end to end and prefix it with the word win

