# Jahooma’s LogicBox, and Jahooma Puzzle 1

Jahooma’s LogicBox is a fantastic game, if you have the proper skills to play it. As in programming interest and somewhat great problem solving skills.

Roughly, you are given a task to perform by placing “boxes” (which represent functions in programming) in a grid. Different levels allow you to use different boxes, and sometimes it becomes extremely challenging because of the nonexistence of some boxes. When the program is run, an object carrying a string appears from the Start box, following the directions and executing the boxes’ purposes, until the object leaves the grid. You must match the direction where you are told to exit from, and the string in your object must have been modified to match the requirements. You probably can understand better by playing it.

So, what’s the point of this post then? As you can probably expect, I love that game, at least until when it requires payment to play a fuller version (it’s still in “lite” version, and judging from the “premium” release name in 2013, it seems like it’s going to need money to play). Well, I’ll just make some puzzles to post here. Yay.

Puzzles!

In each puzzle, you are given an infinite grid to toy with unless otherwise stated; if your object won’t encounter any more box, you can say that it leaves the grid, in the same direction as the game (up = green, down = red, left = yellow, right = blue). You are also given the boxes available and their effects. Finally, you are also obviously given the task, but not the test cases! It’s up to you to determine. You can submit your solutions to me if you want me to check it, but I will analyze your program and give you either the verdict CORRECT or the verdict INCORRECT along with one test case where your program fails the task. Oh yay that looks like a programming contest or something. But then again it’s a programming game, so yeah. After everything that matters with the puzzle, you might be given a Variants section which will adapt your solution into several other similar boxes.

Reminding you again that square boxes cut the input up to just before the first asterisk, aka if you have “ab*cd”, a square box will only accept the argument “ab” and leaves “*cd” unchanged.

Also, Redirect is always an available box, and because I aim this to be more programmer-style, Redirect (and Start) isn’t counted as a box when counting the total number of boxes and not counted as a step when counting the total number of steps.

Puzzle 1.1: Is It A Star? (Easy)
Is Period: Given an input, determine whether the first character is a period or not. You should exit from the green direction if it is, and red direction if it isn’t. The input should stay unchanged when it is output.

Boxes:
Circular Copy (copies the first character of the string to the end of the string)
Circular Delete (deletes the first character of the string)
Circular Compare (compares the first character and the second character of the string; if they are equal, exit green, otherwise exit red; the input is unchanged)

Sample cases:
– “.a” -> “.a”, exit green
– “a.” -> “a.”, exit red
– “period” -> “period”, exit red
– “…” -> “…”, exit green

Variants:
Is Asterisk: Checks whether the first character is asterisk; if it is, exit green, otherwise exit red. Replaces all mentions of “period” in the previous implementation with “asterisk”.

Puzzle 1.2: Finding Star (Medium)
Find Period: Given an input containing at least one period, splice the string into two parts: before the first period and after the first period. Afterwards, change their position so the part after the period appears first. The period is “consumed” and disappears.

Boxes:
Circular Copy (copies the first character of the string to the end of the string)
Circular Delete (deletes the first character of the string)
Circular Compare (compares the first character and the second character of the string; if they are equal, exit green, otherwise exit red; the input is unchanged)
Circular Rotate (moves the first character of the string to the end of the string)
Circular Is period (implemented from your solution to Puzzle 1.1)

Sample cases:
– “abc.def” -> “defabc”
– “a.b.c” -> “b.ca”
– “…” -> “..”
– “.” -> “”

Variants:
Find Asterisk: Splices the argument into two parts, one before asterisk and one after asterisk. The two parts exchange place so the latter appears first while the former follows. is removed. If doesn’t exist, the program gets to an infinite loop. Replaces all mentions of “period” in the previous implementation with “asterisk”.

Puzzle 1.3: Getting A Clearer View (Hard)
Square Back Rotate: Given an input not containing any asterisk, move the last character of the string to the front of the string.

Boxes:
Circular Copy (copies the first character of the string to the end of the string)
Circular Delete (deletes the first character of the string)
Circular Compare (compares the first character and the second character of the string; if they are equal, exit green, otherwise exit red; the input is unchanged)
Circular Rotate (moves the first character of the string to the end of the string)
Circular Is asterisk (implemented from your solution to Puzzle 1.1, replacing period with asterisk)
Circular Find asterisk (implemented from your solution to Puzzle 1.2, replacing period with asterisk)

Sample cases:
– “abcd” -> “dabc”
– “period.” -> “.period”
– “aaa” -> “aaa”
– “ayayay” -> “yayaya”

Puzzle 1.4: Counting Stars (Insane)
Square Increment Number: Given an input of a valid non-negative integer (starts with a digit other than zero except if it has only one character), increment its value by 1.

Boxes:
Circular Copy (copies the first character of the string to the end of the string)
Circular Delete (deletes the first character of the string)
Circular Compare (compares the first character and the second character of the string; if they are equal, exit green, otherwise exit red; the input is unchanged)
Circular Rotate (moves the first character of the string to the end of the string)
Circular Increment (increments the first character of the string (0 -> 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 -> 9 -> 0; * -> *; . -> .))
Circular Is asterisk (implemented from your solution to Puzzle 1.1, replacing period with asterisk)
Circular Find asterisk (implemented from your solution to Puzzle 1.2, replacing period with asterisk)
Circular Is period (implemented from your solution to Puzzle 1.1)
Circular Find period (implemented from your solution to Puzzle 1.2)
Square Back rotate (implemented from your solution to Puzzle 1.3)

Sample cases:
– “123” -> “124”
– “999” -> “1000”
– “0” -> “1”
– “499499” -> “499500”