A/B + C/D

I was contacted by a friend that maintains an online judge, asking about the solution to a particular problem that has existed for how many days on an “easy” section.

Basically, the problem is this: given positive integers A, B, C, D, compute A/B + C/D and simplify it. You are guaranteed that if you represent A/B + C/D = E/F in lowest terms, then all of A,B,C,D,E,F fit in p-bit integers (in the problem, p = 64). Your task is to find this E and F.

Continue reading

12345

12345 Sample Gameplay

12345, a puzzle game where 2+2=3 and 5+5=0. Merge boxes and utilize special blocks to achieve a perfect cover.

Original GameEasy Version • v1.0

This game is now released! Get through 30 mind-boggling levels with quirky mechanics! (But intuitive once you get it. Some levels are intended to be difficult due to discovering the mechanics first.)

Sequels are possible. You can also contribute, sending your ideas (levels/objects) to me, which might get included in official sequels. You can even create your own spin-off if you want!

12345

So, this is what I did today.

Original versionEasy versionVersion 1.0AoPS discussion thread

The original version has no instructions (and is intended), although its mechanics is identical to the easy version, which is intended to be easy and has instructions.

So, feedback! Comments, criticisms, suggestions are much appreciated. Also, open for levels and objects suggestions, as long as it can be implemented in the scripting language I use for this, PuzzleScript. (Just suggest anything; I’ll see if it can be implemented.)

(Oh, also, tip. If you get stuck at figuring out the main screen: Wait until it displays the title and with Start Game and so on, then click the applet (to get focus), then press space bar to select. (If you have a previous saved data, you can use arrow keys to choose the menu “Continue”.) The controls are the arrow keys, plus Z for undo and R for restart.)

Happy New Year!

Unlike last year, I don’t have any puzzle planned. I’m constructing an LMI test for April or May, and considering that I just finished my first semester of university a week or so ago, I’ve been taking the holiday for my usual computer stuff: programming, browsing the net, playing some games…

So what have I done in 2013?

Continue reading

Jahooma 2: Insanity

A single puzzle of hellish difficulty.

Puzzle 2.1: Error-prone Substring (Extreme)
Given an input in the form “start,length,string” (without quotes) where start and length are nonnegative integers and string is a string not containing any asterisk, output substr(string, start, length). That is, starting from the start-th letter (zero-indexed), take the next length characters. It is guaranteed that start + length is less than or equal to the length of the string.

Boxes:
Circular Add asterisk (adds an asterisk in front of the string)
Circular Add period (adds an period in front of the string)
Circular Add zero (adds a zero in front of the string)
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)
Square Rotate (moves the first character of the string to the front of the first asterisk in the original string or to the end of the string if no asterisk is found)
Circular Increment (increments the first character of the string (0 -> 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 -> 9 -> 0; * -> *; . -> .))
Circular Save (copies the first character of the string to the storage stack)
Circular Store (moves the first character of the string to the storage stack)
Circular Load (moves the topmost character of the storage stack to the front 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)
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)
Square Increment Nonnegative Number (implemented from your solution to Puzzle 1.4)

Sample cases:
– “1,2,abcd” -> “bc”
– “0,1,abcd” -> “a”
– “0,0,” -> “”
– “3,3,3,3,3,3,3” -> “,3,”
– “11,11,the insane chaotic_iak posts another puzzle again” -> “chaotic_iak”

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 Add period (adds a period in front of the string)
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 Add period (adds a period in front of the string)
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 Add asterisk (adds an asterisk in front of the string)
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 Add asterisk (adds an asterisk in front of the string)
Circular Add period (adds an period in front of the string)
Circular Add zero (adds a zero in front of the string)
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”