# Text Operations (collab w/ getrithekd, wip, dont click or edit please)

It can be really annoying when you want to perform standard changes to text, like removing characters, splitting strings, and replacing letters. However, gimkit doesn’t offer those capabilities by default, only the ability to get the length of text, combine text, or convert numbers to text. This can be really annoying, and this guide will explain a way to do more with text, using some math.

# The Idea

Think about the device you’re using to read this post. How does it store data? How does it know what words to show you? The answer is numbers. Text and images are stored as numbers on computers, and if a computer can do it then so can we. Let’s make a way to store text as a number. Because computers store text as numbers, and computers can do anything with text, if we store text as a number, then WE can do anything with text.

To do: Boil down to base 72. Add functions. Use decimal places. Rule the world. Autocorrect .

# The System

We need a protocol for storing the text. First, we can encode the alphabet with the numbers 10 to 36. This is done so that there isn’t ever a situation where a number starts with zero. Here is an example of helloworld in this text system.

``````18152222253325282214
``````

If we want to store more characters, like capital letters, punctuation, and spaces, the numbers 37-99 can be used.
And that is how we’ll encode the numbers!

# Manipulating Data

A number isn’t what we want, text is! Below are some formulas I came up with for reading/changing this text.

### Modulo

This won't directly help you with custom text, but it is used in most of the equations here, and while gimkit does not support it by default, it can be recreated like so:

### Backspace

A is the number you want to modify.

mod(a, 100) will extract the last two digits of the number. They are subtracted from the number, then the remaining number is divided by 100 to remove the two zeros created by the subtraction.

### Appending a letter

A is the number you want to modify, L is the letter (in number code) you want to append.

This equation just multiplies the number by 100, then replaces the zeros at the end with whatever number from 1 to 98 you are appending.

### Length of string

A is the number you are getting the length of.

The ceiling ceiling log base 10 returns the number of digits in the base 10 representation of the number. Since each encoded character is two digits long, we divide by two to get the number of encoded characters.

### Nth character of string

Where a is the number you are working with, l1 is the length of the string, and n is the index of the letter you want to get.

This equation basically just clips out the front and end of the number, to leave the original remaining. a divided by 100 to the power of l1 minus n will result in all the digits we don’t want being moved to decimal places in the number. Then, taking the mod of that number and 100 will get the last two numbers in the remaining number, which is the letter code we want.

### A slice of a string

Where a is the string you want to slice, s_1 is the index of the letter you want to start the slice at and s_2 is the index of the letter you want to end the slice at.

This equation can be broken down into two sections. First, we have a/100^l_1-s_2. This clips off everything after the end of the slice by moving it into the decimal place values and rounding down.
Then, by taking the modulo of that and 100^s2-s1+1, we can clip off the front of the number. Now, we have the slice we want!

### Combining strings

Where a and b are both strings, and l_2 is the length of string b.

This equation “pushes” the a string out of the way by multiplying it by the 100^l_2, leaving a bunch of zeros in the lower place values. Then, by adding the b-string, the zeros are filled, and a new string is created.

# Implementing This in GKC

So we have a bunch of equations. You know the theory. Now to get these in GKC.

### Functions

Use the guide below to make functions. I'll explain the theory once more. You'll want to use functions for some of these since the block code can get a bit chunky (Like the slicing a string). I'll post the block code, and then show how to make it into a function, if the block code is above 50 blocks.

Function Guide:

Another Explanation:
There is a property that counts the number of times a function called in the block. Based on that, the block will choose which code to run. Think about it like this: We are using a characteristic of functions in code. After 1 function has run, only the code where only 1 function will run. After this, we either hit the end of the code or a second function called. After the 2nd function, only the code where 2 functions have run will run. Don’t overthink it. If it sounds too simple to be true, then it is simple.

### Modulo

Here is the modulo block code:

In this case, since we are using 100, every time it says the variable base, put the number 100 instead. Also, the round down block is in the dropdown for the round block.

# Conclusion

And that’s that math! It should be noted that due to properties only being able to store numbers up to 99,999,999,999, each property can only store four characters of encoded text. That is the big tradeoff, less text per property for more control over the text. This system would receive a massive buff if the gimkit team set the max for number properties to the 64 bit limit, but for now it’s only four characters per property. If you’re interested in playing around with all the math here, here is a desmos graph.

29 Likes

@getrithekd here

3 Likes

Now this is what I call Advance!

3 Likes

It’s not done lol

2 Likes

We can also use the 5 decimal places, not in a base less than one, but the nth digit represents the n-1th character or something like that.

1 Like

still tho its pretty smart how you came up with this

1 Like

See this is why I don’t call myself the smartest.

3 Likes

It’s standard cs.

2 Likes

i’m not smart enough

also him

(not trying to be mean)

3 Likes

why doesn’t this have the “wiki” tag?

1 Like

I just made it a wiki so that me and getrithekid could both work on it, its not really a proper wiki

3 Likes

I’m only able to get 3 decimal places of accuracy.
So 6 characters

5 Likes

I gotta go to another class, will try to rework the math during lunch in an hour and a half

3 Likes

nice math this could be useful to coders

2 Likes

My name in the title is spelled wrong. Its getrithekd, without an i.

1 Like

Fixed, also am halfway through reworking the math

3 Likes

Wait are we doing 99 characters or 26 characters?

1 Like

Isn’t it just a translation, so like subtract 3 from n each time we see it?

1 Like

What do you mean 99 characters?

The current system supports 99 characcters, the new one is just the same but with numbers 10-99 (so no numbers that start with 0)

3 Likes

Ok I’ll add a section on how to get more characters per property by reducing the base.

1 Like