Challenge: Creating an array using a single variable


Is anyone up for a little challenge? It won't be too hard, I promise. It'll just involve a little math and thinking "outside the box".

Note: First, I'll mention that this concept could find some niche uses for special cases, e.g. one way of storing multiple values in a single clone parameter, but mostly this will just be a thought experiment for anyone who chooses to accept the challenge.

The challenge is to create a demo project of the following:

  • Create a functional approximation of an array where the data is stored in a single variable (no cheating and using clones :wink:)
  • Since Hopscotch doesn't like big numbers, we'll limit the array to 6 indexes
  • The data's number format will be single integers 0 - 9

Hint: "functional approximation" means you need to have to the ability (pun intended) to recall values from the "array" & set/change new values into the "array"

Easy, right?

If anyone's interested in this, I'll edit & post my version of a demo project ( ) after you give it a try. Feel free to discuss & ask questions. The point is to be creative, think outside the box, make use (just for fun) of the Hopscotch tools that we have in a way in which they were not intended, and maybe even learn something. :smiley:

What's an array!?

An array is like a row of cubbies. After you put your PB&J sandwich in one, you can come back later and find it so long as you know which cubby you put it in. Go to a different cubby later on and you get your friend's tuna fish

The row of cubbies has a single name & each cubby gets unique numerical index. The typical form would be MyArray(index)

Oh, and instead of sandwiches people usually put data in them

How to measure the difference between 2 scores without standard maths

Seems interesting. No clue what it should look like tho.


It could really look like anything you want. The interesting bit isn't the GUI but rather the code used for transforming a variable into an array. For a demo project the GUI will probably just be for display and manipulation of the data "under the hood".

I could publish a project for the GUI part of the demo to use as a framework, I'd like to give people a chance to think about it first without influencing them with my ideas. You're ideas may be better than mine!


Would making a group of clones and being able to effect 1 clone or the whole group classify as an "array"?
Like all clones angle is 0 and all clones angle can be changed or just 1 clones angle is changed.


Finished it :smiley: Search

Single-Value Array Demo

to see what I have done.
All values are stored on one central value that can readily be changed with increments or decrements (?) with enough zeros. This could be adapted to allow tens or even hundreds, possibly.


Yes - clones can definitely be used as an array. In fact, you've done that already. How do you use clones so that the angle of any given one could be changed without affecting the others? We utilize an unneeded parameter (speed for example) as an index. Then data is "stored" in the other parameters (eg, the angle). So in effect they become graphical representations of an array (that we can put to cool uses for projects/games). Multi-dimensional arrays can be created in the same manner.

However, for this challenge clones are not allowed! :innocent:


Awesome! That was quick :grinning: I'll check it out tomorrow if that's ok. It's getting late for me here.


Sounds interesting! I'll try it after school.


Great job demonstrating the core idea of reading a single value from the "array"!

Opportunities for improvement

  1. The formula for extracting a value from the array can be simplified. Your use of operators; Round(x - 0.5) & Modulus are exactly right. You have two parts: A - B, however it can be done with just part A with a small tweak. Do you see how?

  2. Each of the text objects (Text1 - Text6) has a different formula. In order to use the "array" functionally it needs to be accessed through a single formula that makes use of an Index value. Do you see how to do this?

The second 1/2 of the problem would be to show how to change a single value once the "array" already has data.


Yay! Arrays! This will be so useful!
Can you give instructions?
Edit: I just noticed that it's a challenge.


Looks kkkkkkool
I might try and participate


@CreationsOfaNoob Did you have a chance to give it a go?
@ThePickle Love the energy. You going to try the challenge?
@Jades Great! I hope you do. Don't hesitate to ask questions.


Just asking, can you reveal it? I really want to be able to use arrays.
I figured out how to use strings.

This is the climax

I have an (brief) idea on how to do this. Only if I still had hopscotch.

I know somewhat how to use strings, although it's not been tested.

If only I still had hopscotch...


I'm thinking I'll wait a day or two. I don't want to spoil the fun if others want to try this.

Bear in mind that the technique of this challenge only works for a special case of "arrays". Ones limited to 6 indices (values) & each value can only be an integer 0 - 9. So this is mostly just a thought experiment.

A much better way to create the effect of arrays in Hopscotch is to use clones, as was touched on above in the conversation with Stradyvarious. I like the interest & I don't want to put you off, but that should be the subject of a different topic. Have you searched the forum? There might already be a topic related to using clones for arrays. I haven't looked. If not, maybe we could explore that topic after this exercise is over.


I'll look. By the way, I know how to have strings.


This just got even more confusing xD I really don't know what to do except make it use different operators


Yeah, i've started thinking. I'm aiming for a pretty advanced project. I am gonna limit the array to six numbers, but make an algorithm that can be used on much bigger arrays.


I'm very curious how or if you could store the data for an "array" with more than 6 indices in a single variable (specifically when the values are 0-9)!

To the best that I can tell, Hopscotch variables can only hold up to 6 digits of precision. This isn't to say that Hopscotch can't handle numbers larger than "a 6 digit number", but it sacrifices precision to do so.

What I mean is that a Hopscotch variable can store the value 1.5 million (1500000) because this number has 2 digits of precision (the trailing zeros don't count because it can be expressed in scientific notation as 1.5e6). On the other hand, Hopscotch can not store 1500001 in a variable (it has 7 digits of precision as 1.500001e6 still has 7 digits). In trying to do so, Hopscotch will round to 6 digits of precision so the value stored will be 1500000. Hopscotch can do math operations with greater than 6 digits of precision, it just can't store the answer in a variable.

I feel that examples will make the point better for many who might read this than the above explaination, so:

This displays 999998 (fail) since the result of the 2nd line is rounded to 1e6 (1000000) when stored in the variable.

Likewise, this displays 1000 (fail) since the result of the 2nd line is rounded to 1001 when stored in the variable.

However, this works (displays 999999) since the results of the math don't get stored into a variable when more than 6 digits of precision are needed

...This was a really long way to explain that Hopscotch doesn't store more than 6 digits in variable :blush:


Which one of my comments are you referring to?

If you're referring to the simplification (1.) then maybe try to introduce an Index variable (2.) into you're equatons first. The simplification may be easier to see then.