How to resolve the algorithm Kernighans large earthquake problem step by step in the V (Vlang) programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Kernighans large earthquake problem step by step in the V (Vlang) programming language

Table of Contents

Problem Statement

Brian Kernighan, in a lecture at the University of Nottingham, described a problem on which this task is based. You are given a a data file of thousands of lines; each of three whitespace separated fields: a date, a one word name and the magnitude of the event. Example lines from the file would be lines like:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Kernighans large earthquake problem step by step in the V (Vlang) programming language

Source code in the v programming language

import os
fn main() {
    lines := os.read_lines('data.txt')?
    println('Those earthquakes with a magnitude > 6.0 are:\n')
    for line in lines {
        fields := line.fields()
        mag := fields[2].f64()
        if mag > 6.0 {
            println(line)
        }
    }
}

  

You may also check:How to resolve the algorithm Create a two-dimensional array at runtime step by step in the Clean programming language
You may also check:How to resolve the algorithm Compare length of two strings step by step in the V (Vlang) programming language
You may also check:How to resolve the algorithm String case step by step in the Zoea programming language
You may also check:How to resolve the algorithm Kaprekar numbers step by step in the D programming language
You may also check:How to resolve the algorithm Loops/Wrong ranges step by step in the Factor programming language