全 14 件のコメント

[–]reciam 7ポイント8ポイント  (1子コメント)

Number("3" + "2")

[–]tj-horner 2ポイント3ポイント  (0子コメント)

Number(String(Number("3") + String(Number("2"))))

The sad part is that is valid.

[–]AlphaWhelp 5ポイント6ポイント  (4子コメント)

int x;
try
{
    x = {your user input statement here};
}
catch
{
    x = 0;
}
if (x < 0) x*= -1;
x = (x % 7);
x+= (7-x);
// returns 7 no matter what
return x;

[–]tj-horner 1ポイント2ポイント  (3子コメント)

[–]xkcd_transcriber 2ポイント3ポイント  (2子コメント)

Image

Title: Random Number

Title-text: RFC 1149.5 specifies 4 as the standard IEEE-vetted random number.

Comic Explanation

Stats: This comic has been referenced 357 times, representing 0.4362% of referenced xkcds.


xkcd.com | xkcd sub | Problems/Bugs? | Statistics | Stop Replying | Delete

[–]rlopezcc 4ポイント5ポイント  (0子コメント)

class Span(object):
    def __str__(self):
        return '<span></span>'
    def __mul__(self, n):
        return str(self) * n

class Spinner(object):
    def __str__(self):
        return '<div class="spinner">' + Span() * 4 + '</div>'

def get_spinner():
    """return not hard-coded spinner html"""
    return str(Spinner())

# >>> print(get_spinner())
# >>> "<div class="spinner"><span></span><span></span><span></span><span></span></div>"

[–]BallpointSword 2ポイント3ポイント  (0子コメント)

Here's my go at it. Hint: try changing the comments or adding more.

# Hardcoding data reduces configurability!
# Softcoding for life!


def safe_file_op(func):
    def make_safe(*args, **kwargs):
        return func(__file__)
    return make_safe


@safe_file_op
def add_magic_numbers(filename):
    data = open(filename).readlines()
    dehashed = filter(lambda s: s.startswith('#'), data)
    magic_numbers = map(lambda s: len(s.split(' ')), dehashed)

    return sum(magic_numbers)


print add_magic_numbers('magic_number_file.txt')    

[–]netheril96 0ポイント1ポイント  (0子コメント)

For a moment I thought the intern actually went that far to hide hardcoding.

[–]Sadale- 0ポイント1ポイント  (0子コメント)

import subprocess
def foo():
    return ord(subprocess.check_output("echo -e 'GET /w/api.php?action=query&titles=Main Page&prop=revisions&rvprop=content&format=json HTTP/1.0\r\n\r\n' | nc en.wikipedia.org 80", shell=True)[-2])-ord(' ')+2

List of WTFs:

  • The function does return 32
  • Dependency on the server of wikipedia while it completely has nothing to do with it
  • Only works on unix-like system with nc and echo available
  • While it looks like a wikimedia API access, wikipedia actually doesn't support HTTP access. so the code above relies on the error page of wikipedia returned.

EDIT: formatting

[–]I_RATE_YOUR_BEWBS 0ポイント1ポイント  (2子コメント)

I'd quote xkcd 221, but it's down apparently.

[–]caagr98 2ポイント3ポイント  (1子コメント)

[–]xkcd_transcriber 1ポイント2ポイント  (0子コメント)

Image

Title: Random Number

Title-text: RFC 1149.5 specifies 4 as the standard IEEE-vetted random number.

Comic Explanation

Stats: This comic has been referenced 356 times, representing 0.4350% of referenced xkcds.


xkcd.com | xkcd sub | Problems/Bugs? | Statistics | Stop Replying | Delete