How to resolve the algorithm Kernighans large earthquake problem step by step in the zkl programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Kernighans large earthquake problem step by step in the zkl 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 zkl programming language

Source code in the zkl programming language

fcn equake(data,out=Console){ 
   data.pump(out,fcn(line){ 6.0line.split()[-1] },Void.Filter)
}

equake(Data(Void,
#<<<
"8/27/1883    Krakatoa            8.8\n"
"5/18/1980    MountStHelens       7.6\n"
"3/13/2009    CostaRica           5.1\n"
#<<<
));

equake(File("equake.txt"));

$ zkl --eval 'File.stdin.pump(Console,fcn(line){ 6.0

  

You may also check:How to resolve the algorithm Hello world/Text step by step in the IBM Z HL/ASM programming language
You may also check:How to resolve the algorithm Boolean values step by step in the Mathematica/Wolfram Language programming language
You may also check:How to resolve the algorithm Permutations step by step in the OCaml programming language
You may also check:How to resolve the algorithm Associative array/Creation step by step in the Vim Script programming language
You may also check:How to resolve the algorithm Count occurrences of a substring step by step in the F# programming language