I've some questions for an exam and wondered if somebody could take a look at my Fibonacci sequence that is supposed to answer this question:
"select the element out of the array if its index is a Fibonacci number"
def fibonacci_sequence(max_num)
sequence = [1, 2]
loop do
fibonacc...
@DanPantry Strictly speaking, it should probably be instancetype rather than id, but other than that, the normal pattern for initializers in Objective-C looks like this...
- (instancetype)init {
self = [super init];
if (self) {
// set up self
}
return self
}
Alternatively...
- (instancetype)init {
if ((self = [super init])) {
// set up self
}
return self
}
Ugh. And he does stupid things like this too: stackoverflow.com/q/35683813/2792531 That's not really helpful. He's right. The question HAS been asked a million times... we don't need a NEW question to post the canonical answer. The canonical answer might even already exist somewhere...
@JohanLarsson It's not purely that always. I have 27.5k rep on Stack Overflow. I also average 2-4 upvotes per post in my top 3 tags. This user averages barely 1 upvote per post in his top 3 tags.
I'm a first year college student, Computer Science major. This is my crack at the FizzBuzz interview question in Java. What kind of improvements could I make?
//Prints numbers 1 - 100, 25 values per line.
//Numbers that are multiples of 3 are replaced with Fizz
//Numbers that are mulitples of 5 ...
You don't always have to put things at the global scope. I don't know why the global scope and singletons is always your default go-to, Duncan... — nhgrif13 secs ago
Well, I'm not sure he'd self-describe himself as a "learning programmer", I mean... other than the notion that most smart people always describe themselves as learning.
with 45k SO rep..
Part of me hopes that he somehow ends up applying to a company I work for some day so I can just immediately tell hiring people we have zero interest in talking to him...
I'm wondering about how to implement a list of FizzBuzz words with corresponding integers... Something like: { (3, "Fizz"), (5, "Buzz") }, and how to iterate over this the easiest way.
for(int i = 1; i <= 100; ++i) {
// make a string builder
for(FizzBuzzRule rule: rules) {
if (i % rule.value == 0) {
// append rule.string to string builder
}
}
// if none of the rules matched, append the number itself
}
This program was inspired by a Code-Golf challenge that I wanted to do properly. It simply converts oOo to Brainfuck and viceversa.
The oOo language basically uses UPPER / lower case information in groups of 3 to encode a Brainfuck program. For further info see the Esolang wiki page of oOo
The ...
Swift's SequenceType is a useful means of generating a sequence of values, and it makes it particularly useful iterate over these values.
I don't really have much experience with these SequenceType types, so I wanted to implement my own for some practice and learning. What better sequence to ta...
I didn't fully read all of it, but that looks like you are taking it to the extreme... Very understandable why you call it the "Ultimate FizzBuzz". :-D
I believe this is layed out in section 6.4.3 of the C# 5 Language Specification.
A first hint is given in section 6.2.8 User Defined explicit conversions (emphasis mine):
A user-defined explicit conversion consists of an optional standard explicit conversion, followed by execution of a user-...