Without any other constraints, this is not an interesting challenge.
print("")21–30 of 72 posts
Without any other constraints, this is not an interesting challenge.
print("")Enumerating all values probably can't be done in python as that requires some sort of unchecked loop construct, that is a goto or bare loop nether of which is present in python. perhaps a recursive solution(throws up a little in mouth) baring that I too got nerd sniped by this and unsatisfied by the limitations of the authors solution here is my attempt. and when I read up on fizzbuz to make sure I was solving the co…
What's a "disguised Boolean" in this context?
Much like stop50's solution, I also used the modulo, but I make use of the terminal to overwrite the number. It's only three lines of code, but I split up the list to be more readable on here. This works from 1 to 100000000000000000000 before it overflows, and 100000000000000000000 is above the max size of a unsigned 64 bit int, so I feel that it's good enough fizzbuzz = [ "fizzbuzz ", "", "", "fizz ", "", "buzz ", "…
Unless by conditionals we mean “no if/else” and not “no branch instructions”.
A for loop has a conditional in it. Unless by conditionals we mean “no if/else” and not “no branch instructions”.
Integer extend [
fizzbuzz [
(self \\ 15 = 0)
ifTrue: ['fizzbuzz' printNl]
ifFalse: [
(self \\ 3 = 0)
ifTrue: ['fizz' printNl]
ifFalse: [
(self \\ 5 = 0)
ifTrue: ['buzz' printNl]
ifFalse: [self printNl]
]
]
]
]
1 to: 100 by: 1 do: [:i | i fizzbuzz]A for loop has a conditional in it. Unless by conditionals we mean “no if/else” and not “no branch instructions”.
The conditional here only makes it stop when it reaches 100. The solution can be adapted to use a while loop if you’re okay with it running indefinitely.
One hack would be to use recursion and let stack exhaustion stop you.
Enumerating all values probably can't be done in python as that requires some sort of unchecked loop construct, that is a goto or bare loop nether of which is present in python. perhaps a recursive solution(throws up a little in mouth) baring that I too got nerd sniped by this and unsatisfied by the limitations of the authors solution here is my attempt. and when I read up on fizzbuz to make sure I was solving the co…
Much like stop50's solution, I also used the modulo, but I make use of the terminal to overwrite the number. It's only three lines of code, but I split up the list to be more readable on here. This works from 1 to 100000000000000000000 before it overflows, and 100000000000000000000 is above the max size of a unsigned 64 bit int, so I feel that it's good enough fizzbuzz = [ "fizzbuzz ", "", "", "fizz ", "", "buzz ", "…
A for loop has an implicit conditional in its stop condition check.
If you wanted to be more general, you could use map() to apply the function to every member of the iterator, and implementation details aside, that feels solidly in the spirit of the challenge.