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

Published on 12 May 2024 09:40 PM

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

Source code in the ring programming language

# Project  : Kernighans large earthquake problem

load "stdlib.ring"
nr = 0 
equake = list(3)
fn = "equake.txt"
fp = fopen(fn,"r")

while not feof(fp)
         nr = nr + 1 
         equake[nr] = readline(fp)
end 
fclose(fp)
for n = 1 to len(equake)
     for m = 1 to len(equake[n])
          if equake[n][m] = " "
             sp = m
          ok
     next
     sptemp = right(equake[n],len(equake[n])-sp)
     sptemo = number(sptemp)
     if sptemp > 6
        see equake[n] + nl
     ok
next

  

You may also check:How to resolve the algorithm Trigonometric functions step by step in the Forth programming language
You may also check:How to resolve the algorithm Determine if a string has all the same characters step by step in the Maple programming language
You may also check:How to resolve the algorithm Unicode strings step by step in the Lasso programming language
You may also check:How to resolve the algorithm Tic-tac-toe step by step in the Tcl programming language
You may also check:How to resolve the algorithm Iterated digits squaring step by step in the AWK programming language