Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

633
Visualizações
HackerRank says ~ no response on stdout ~ Swift

I'm taking a course with a hands-on question on Swift programming, that redirect me to Hackerrank

Write a function named printMessage that takes two parameters - a string message and an integer count. The message should print and repeat the message as specified in the count parameter.

Message:"Hello , How are You"

For instance take Count as 8

This should print Message:"Hello , How are You" 8 times consecutively.

The problem is when I submit my code always said Wrong answer, then I tried with custom input, and it throws me no response on STDOUT. Anyone knows what's wrong?

import Foundation 

func printMessage(message: String, count: Int) {

    for _ in 0..<count {
        print(message)

    }
}

let message: String = readLine()!
let count: Int = Int(readLine()!)!
printMessage(message: message, count: count)
over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

I have run into this before, the way I solved it was saving my code somewhere and resetting to the boilerplate code. So just reset to the boilerplate and copy your function back in. On many swift hackerrank problems they have something like the following:

func myFunc(param: [Int]) -> [Int] {
    /*
    * Write your code here.
    */
}

// The following is an example of your function being written to stdout

let fileName = ProcessInfo.processInfo.environment["OUTPUT_PATH"]!
FileManager.default.createFile(atPath: fileName, contents: nil, attributes: nil)
let fileHandle = FileHandle(forWritingAtPath: fileName)!

let result = myFunc(param: input)

fileHandle.write(result.map{ String($0) }.joined(separator: "\n").data(using: .utf8)!)
fileHandle.write("\n".data(using: .utf8)!)

The code after the function is what writes to stdout

over 4 years ago · Santiago Trujillo Relatório

0

Hackerrank in some swift exercises fires that message whenever you have a buffer overflow, instead of warning you about it

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda