Submitting mulitfile solutions

Back to General discussions forum

oezguery     2024-01-21 00:37:00
User avatar

Hi!
I just solved the second easiest problem and do not know exactly how to submit a solution that is divided into two files.
I have a Program.fs file that only calls a function from another module. I looked at the previous solutions they only submitted the function without specifying how and where it is called. I can of course also copy paste only the function definition, but in later exercises I will have many functions possibly in multiple files.

qwerty     2024-01-22 18:51:25

I believe you make it too complex. All my solutions on this website are at max 100 lines long... and fit into single file. What problem you are trying to solve?

qwerty     2024-01-22 19:01:02

I checked your profile and have the following suggestion:

namespace Solution

(* Content of Input.fs goes here *)
[<AutoOpen>]
module Input =

    open System

    let readInt() =
        Console.ReadLine() 
        |> int
    (* more code... *)

(* Content of Program.fs goes here *)
module Program =

    readInt() |> ignore
    (* more code... *)

This way you will have your code in single file, but separated to modules as you like.

qwerty     2024-01-22 19:59:27

I checked another solutions of this task and I think that this is a textbook solution

Clearly you see now that without overcomplicating yourself with extra functions and modules you can get a short and concise code!

oezguery     2024-01-22 22:46:00
User avatar

Hi qwerty, Thank you, it is nice of you.
You are right I am overcomplicating a little bit.
I think of every problem as a separate module and every module should reuse already existing functions from earlier modules as much as possible.
The solution is then called from a Main/Program file/class.
Because the structure of the input varies from task to task, I need a utility module with tailored functionsfor preprocessing the input.
The flow of the program should be such that

  1. the main file calls the appropriate utility function to read the input
  2. the utility function returns the list of numbers or objects to be processed
  3. the main file sends the data to the solver function defined in its module
  4. the solver function returns the result
  5. the main file sends the result to the utility function for conversion to string and properly formating
  6. the utility function returns the formatted string that represents the result
  7. the main file prints the result and exits

In other words, I want to

  1. write modules
  2. focus on the arithmetic and the logic
  3. abstract the boiler plate code away
  4. separate parsing and formating, reading and printing
  5. structure my code into modules/classes/packages
  6. pretend writing an open source library that can aid humanity.
Please login and solve 5 problems to be able to post at forum