leo3065

LARGE NUMBER ADDER

Jun 29th, 2015
557
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.26 KB | None | 0 0
  1. -- The function get_name() should return a single string that is the name of the puzzle.
  2. --
  3. function get_name()
  4.     return "LARGE NUMBER ADDER"
  5. end
  6.  
  7. -- The function get_description() should return an array of strings, where each string is
  8. -- a line of description for the puzzle. The text you return from get_description() will
  9. -- be automatically formatted and wrapped to fit inside the puzzle information box.
  10. --
  11. function get_description()
  12.     return { "LARGE NUMBERS ARE GIVEN WITH TWO INPUTS WITH UPPER AND LOWER THREE DIGITS OF THE NUMBER", "WRITE THE SUM OF TWO INPUT NUMBERS TO OUTPUTS AS LARGE NUMBERS" }
  13. end
  14.  
  15. -- The function get_streams() should return an array of streams. Each stream is described
  16. -- by an array with exactly four values: a STREAM_* value, a name, a position, and an array
  17. -- of integer values between -999 and 999 inclusive.
  18. --
  19. -- STREAM_INPUT: An input stream containing up to 39 numerical values.
  20. -- STREAM_OUTPUT: An output stream containing up to 39 numerical values.
  21. -- STREAM_IMAGE: An image output stream, containing exactly 30*18 numerical values between 0
  22. --               and 4, representing the full set of "pixels" for the target image.
  23. --
  24. -- NOTE: Arrays in Lua are implemented as tables (dictionaries) with integer keys that start
  25. --       at 1 by convention. The sample code below creates an input array of 39 random values
  26. --       and an output array that doubles all of the input values.
  27. --
  28. -- NOTE: To generate random values you should use math.random(). However, you SHOULD NOT seed
  29. --       the random number generator with a new seed value, as that is how TIS-100 ensures that
  30. --       the first test run is consistent for all users, and thus something that allows for the
  31. --       comparison of cycle scores.
  32. --
  33. -- NOTE: Position values for streams should be between 0 and 3, which correspond to the far
  34. --       left and far right of the TIS-100 segment grid. Input streams will be automatically
  35. --       placed on the top, while output and image streams will be placed on the bottom.
  36. --
  37. function get_streams()
  38.     input1 = {{},{}}
  39.     input2 = {{},{}}
  40.     output = {{},{}}
  41.     for i = 1,39 do
  42.         repeat
  43.             n1 = math.random(0, 999999)
  44.             n2 = math.random(0, 999999)
  45.             n3 = n1 + n2
  46.         until n3 < 1000000
  47.         input1[1][i], input1[2][i] = math.floor(n1/1000), n1 % 1000
  48.         input2[1][i], input2[2][i] = math.floor(n2/1000), n2 % 1000
  49.         output[1][i], output[2][i] = math.floor(n3/1000), n3 % 1000
  50.     end
  51.     return {
  52.         { STREAM_INPUT, "IN.AU", 0, input1[1] },
  53.         { STREAM_INPUT, "IN.BU", 1, input2[1] },
  54.         { STREAM_INPUT, "IN.AL", 2, input1[2] },
  55.         { STREAM_INPUT, "IN.BL", 3, input2[2] },
  56.         { STREAM_OUTPUT, "OUT.U", 1, output[1] },
  57.         { STREAM_OUTPUT, "OUT.L", 2, output[2] },
  58.     }
  59. end
  60.  
  61. -- The function get_layout() should return an array of exactly 12 TILE_* values, which
  62. -- describe the layout and type of tiles found in the puzzle.
  63. --
  64. -- TILE_COMPUTE: A basic execution node (node type T21).
  65. -- TILE_MEMORY: A stack memory node (node type T30).
  66. -- TILE_DAMAGED: A damaged execution node, which acts as an obstacle.
  67. --
  68. function get_layout()
  69.     return {
  70.         TILE_COMPUTE,   TILE_COMPUTE,   TILE_COMPUTE,   TILE_COMPUTE,
  71.         TILE_COMPUTE,   TILE_COMPUTE,   TILE_COMPUTE,   TILE_COMPUTE,
  72.         TILE_COMPUTE,   TILE_COMPUTE,   TILE_COMPUTE,   TILE_COMPUTE,
  73.     }
  74. end
Advertisement
Add Comment
Please, Sign In to add comment