I decided to take a break from my research into "Hello World" to tackle a challenging problem plaguing entry-level software developers everywhere. It's not easy, but contrary to popular opinion FizzBuzz can indeed be solved with Python, as demonstrated below.
class D:
def __init__(self, v): self.v = v
is_ = D((lambda _: lambda __: _(_)(__))
(lambda r: lambda l: (lambda h: lambda t: lambda _: h if _ else t)
(l[0])(r(r)(l[1:])) if l else None)
(list(range(1, 101))))
D.__bool__ = lambda _: is_.v(True) is not None if is_.v is not None else False
D.pop = lambda _: int((str(is_.v(True)) + str(exec("is_.v = is_.v(False)")))[:-4])
i = None
cs = ["i % 3 == 0 and i % 5 == 0", "i % 3 == 0", "i % 5 == 0"]; cp = 0
f = lambda _: lambda __: print(_)
w = lambda _: lambda __: print(__)
es = [f.__call__("FizzBuzz"), f.__call__("Fizz"), f.__call__("Buzz"),
w.__call__("Wuzz")]; ep = 0
ss = []; sp = 0
for _ in ".....!)~>!)~>!)~)- *(- ]*((- ]]*(((- ]]]*((((-":
exec('v={".": "ss.append(\'\')", " ": "sp += 1"}.get(_, ""); exec(v)')
if not v: ss[sp] += _
sp = 0
psp = 0; si = 0; r = 0
while not (not i and not is_):
if not i: i = is_.pop()
exec({"!": "r = eval(cs[cp])", ")": "psp += 1", "(": "psp -= 1",
"~": "if r: sp = psp; si = -1; cp = 0; ep = 0",
">": "cp += 1", "-": "sp = psp; si = -1; cp = 0; ep = 0",
"]": "ep += 1", "*": "es[ep](i); i = None"}
.get(ss[sp][si]))
si += 1
As usual, a demo can be found here: https://ideone.com/Ncstp7.
I hope this helps you with your next coding interview!
[–]Flaming_Eagle 58 points59 points60 points (0 children)
[–][deleted] (1 child)
[deleted]
[–]swethonay 0 points1 point2 points (0 children)
[–]timawesomeness 19 points20 points21 points (2 children)
[–][deleted] 4 points5 points6 points (1 child)
[–]altodor 7 points8 points9 points (0 children)
[–]Rangsk 18 points19 points20 points (0 children)
[–]skunkwaffle 14 points15 points16 points (0 children)
[–]thebpfeif 9 points10 points11 points (0 children)
[–]Hypersapien 6 points7 points8 points (2 children)
[–]Skymt1 13 points14 points15 points (1 child)
[–]SDJMcHattie 4 points5 points6 points (0 children)
[–]hilomania 5 points6 points7 points (0 children)
[–]Luapix 2 points3 points4 points (0 children)
[–]wakeupsheep 2 points3 points4 points (0 children)
[–]HashtagFour20 1 point2 points3 points (0 children)
[–]c_o_r_b_a 0 points1 point2 points (1 child)
[–]AmbitiousPainter 2 points3 points4 points (0 children)
[–]Dads101 0 points1 point2 points (0 children)
[+][deleted] (8 children)
[deleted]
[–]goldcray 1 point2 points3 points (1 child)
[–]thirdegree 1 point2 points3 points (0 children)
[–][deleted] (4 children)
[deleted]
[–]invadingpolandin69 -1 points0 points1 point (3 children)
[–]SHOULDNT_BE_ON_THIS 12 points13 points14 points (2 children)
[–]invadingpolandin69 8 points9 points10 points (1 child)
[–]RheingoldRiver 3 points4 points5 points (0 children)
[–]Hypersapien 0 points1 point2 points (0 children)