Text-based programs

Text-based programs

These are programs which use nothing but the command window for the user to interact with. Pretty sure I’ll be sticking to this format for a while, seeing how I am an absolute dipshit who doesn’t know how to progress to GUIs.

1. “Google Code Jam”

  1. “Reverse Words”
    • Download here – 320 kB (327,574 bytes)
    • Simple program consisting of two phases: first, the user inputs a number. Then, the user inputs that same number of sentences consisting of words spaced by single whitespace characters and whose words consist of alphanumerical characters, preferrably.
      Example:

      3
      go away
      this program seriously sucks
      lolololol rudeguygames does not even know how to program

      This will output:

      "go away" --> "away go"
      "this program seriously sucks" --> "sucks seriously program this"
      "lolololol rudeguygames does not even know how to program" --> "program to how know even not does rudeguygames lololololol"
  2. “Store Credit”
    • A program consisting of three phases:
      1. An input phase where a number of stores is to be input by the user, followed by the user having to input, in the following order: the credit to be spent at every store; the number of items in every store; and a list of every item’s value in every store, input as a space-separated single-line character string.
      2. An “invisible” phase where the first occurrence of a solution is stored in an N-by-2 array, where N is the number of stores. The idea is that the value of two unique items in the store must add up to the user’s credit in said store for every store. If two items’ values add up to the user’s credit in the store, the solution is stored in the aforementioned array. This calculation is done for every store without needing any input from the user.
      3. An output phase where the solutions are printed for every store, the solutions being the indices in the item value array for the respective item value. If, for whatever reason, no solution could be found, caused by such reasons as there being only one item in a store or no two items’ values adding up to the user’s store credit, the “solution” would be printed as a one-dimensional array  with two integers, both of which hold the value -1.
    • Example:
      1. Input phase:
        1
        100
        4
        10 20 40 80
      2. Solving phase:
        [NO OUTPUT NOR INPUT]
      3. Output phase:
        Store # 0:    1    3
  3. “T9 Spelling”
    • Download here – 3 kB (2,753 bytes)
    • A program which turns an all-lowercase string into a string of numerical characters representing how one would type the input string on one of those überphones of ye olden dayes.
      Compiled using NetBeans as opposed to shitty Eclipse. As you may or may not already have noticed, the file size is quite an improvement.
  4. “Minimal Scalar Product”
    • Download here – 3 kB (3,202 bytes)
    • Takes two strings as input, both of which are numbers separated by spaces to represent vector elements. These two strings must contain an equal number of elements. The program then proceeds to enter an algorithm to find the smallest possible dot product using reordering of the two vectors’ elements. The program ends upon checking every single combination, but only prints the first solution found.
      While this may not be the most efficient program, it prints the correct answer every time assuming that the two vectors are of equal length and contain real numbers. Yes, the most simple way of doing this would be to sort one of the vectors by value in ascending order and the other in descending order and then take the dot product of these two vectors, but that would be using my noodle before creating the algorithm.
      But, as the would-be-great Todd Howard once said: “It just works!”

2. “Learning Experience”

  1. “File IO Test”
    • Download here – 2 kB (2,245 bytes)
    • This program merely tells the user to enter a file name (without a file type suffix) and then creates a text file (.txt) given a name as the string input by the user. The user can then enter lines of text until the string “exit” is input by the user. How useless useful.