[Swift] Template for receiving standard input of Paiza

Paiza(https://paiza.jp/challenges) Skill check is a service that allows you to solve problems in each language. Not only logical thinking, but also logic withdrawals will increase. Recommended for those who are just starting programming Since there are problems for each level, even people who are accustomed to programming to some extent can improve their skills, You can enjoy it.

However, the first person to get stuck is to stumble. I think it means ** I can't receive the data **. I saw a lot of people stumbling here (as I was) I would like to keep a memorandum of templates for receiving data.

import Foundation
var lines = [String]()
while let line = readLine() {

Let's write this at the beginning. The data is stored as an array in lines. By using while let, it loops only when the data exists It will be stored in lines. After that, operate lines and play around with each data.

Recommended Posts

[Swift] Template for receiving standard input of Paiza
Story of paiza.jp [Java standard input solution]
[Rails] Get standard input for multi-line data
[Ruby] Summary of how to get values from standard input [Paiza skill check measures]
Ruby standard input
paiza skill check standard input / output summary [Java edition]