The following warnings occurred:
Warning [2] Undefined array key 0 - Line: 1669 - File: showthread.php PHP 8.2.30 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/showthread.php 1669 errorHandler->error_callback
/showthread.php 915 buildtree




The MM Network
(09-28-2018, 02:13 PM)rherold9 Wrote:
(09-28-2018, 12:56 PM)Evan Wrote: I dont think what they were asking was out of line for a devops engineer.  
Fizzbuzz and algorithms are out of place for devops,   but sounds like you did better than most anyway

EDIT: just saw the article is from 2007. Figures. These college kids are a lot smarter these days. I know because I do Job Fit Interviews for them.

Just wrote the FizzBuzz program out in my IntelliJ in 5 minutes.... I have a degree in CIS (not CS) and only two years experience in a basic software engineer role. People really can't do that? Wow....

Inefficient but base code with old school Java for loop

void class Fizzbuzz () {
  int[] list = {1, ...100};
  for (int i = 0; int i < list.length; i++){
     if (list[i] % 3 = 0) {
        System.out.println("Fizz");
     }
     else if (list[i] % 5 = 0) {
        System.out.println("Buzz");
     }
     else if (list[i] % 3 = 0 && list[i] % 5 = 0){
        System.out.println("FizzBuzz");
     }
     else {
        System.out.println(list[i].toString());
     }
  }
}

Java 8+ loop:

void class Fizzbuzz () {
  int[] list = {1, ...100};
  for (Int i : list){
     if (i % 3 = 0) {
        System.out.println("Fizz");
     }
     else if (i % 5 = 0) {
        System.out.println("Buzz");
     }
     else if (i % 3 = 0 && i % 5 = 0){
        System.out.println("FizzBuzz");
     }
     else {
        System.out.println(list[i].toString());
     }
  }
}

It still was/is a decent tool. This solution won't work because 15 will satisfy the first condition (and third) you won't ever reach the FizzBuzz portion. You need to check the more specific case first.

if(i%15 == 0){FizzBuzz}
else if (i%3 ==0) {Fizz}
else if(i%5 ==0){Buzz}
  Reply


Messages In This Thread

Forum Jump: