Want to share your content on R-bloggers? click here if you have a blog, or here if you don’t.
Mind reader game, and Unicode symbols, by Jerry Tuttle
Perhaps you’ve seen this Mind Reader game? Think of a two-digit positive whole number, such as 54. Subtract each of the two digits from your number, such as 54 – 5 – 4 = 45, and call 45 the RESULT. Examine the table of symbols below and find the SYMBOL that corresponds with your RESULT. Concentrate on the SYMBOL, and remember it. Then scroll down below, and I will read your mind to predict your SYMBOL.
Before I get to my prediction, let’s talk about Unicode symbols.
Unicode symbols
Unicode is a standard international system that assigns a unique Unicode number to each letter, digit, or symbol. This permits thousands of symbols to be written across different platforms, programs, and languages. An example of a Unicode number is “U+” followed by a hex number, such as U+1F499.
The table of symbols in the Mind Reader game is based on plotting a variety of Unicode symbols by printing their Unicode numbers.
A Unicode symbol is printed in R with its Unicode number, but beginning with a backslash to escape the U, and omitting the plus sign. For example, here is how to print a heart symbol.
print(“U1F499”)
“”
Example with Hebrew letters
Let’s spell out the Hebrew word shalom , letter by letter, with each letter’s Unicode number, and then use the R paste command to paste the letters together.
shin <- "U05E9" # "ש"
kamatz <- "U05B7" # vowel as two perpendicular lines "ַ"
lamed <- "U05DC" # "ל"
vav <- "U05D5" # "ו"
final_mem <- "U05DD" # "ם"
shin_with_kamatz <- "U05E9U05B7" # "שַ"
paste(shin_with_kamatz, lamed, vav, final_mem, sep = “”)
“שַלום”
Note that the letters are entered in the paste statement in order of first Hebrew letter, second Hebrew letter, etc., but they are printed in Hebrew right-to-left. Also, a better choice than vav is cholam, which is vav with a dot above it, “U05BA”, but this doesn’t print for me.
My prediction
Here is my prediction of your symbol:
Want to play again? Think of another two-digit positive whole number, such as 54. Subtract each of the two digits from your number, such as 54 – 5 – 4 = 45, and call 45 the RESULT. Examine the table of symbols below and find the SYMBOL that corresponds with your RESULT. Concentrate on the SYMBOL, and remember it. Then scroll down below, and I will read your mind to predict your SYMBOL.
Plotting with Unicode characters
Tired of plotting points with those boring 25 pch symbols? You can use Unicode symbols, but you can’t simply use pch = .
Here for no good reason I use a heart and a thumbs up.
library(ggplot2)
x <- seq(from=0,to=4, by=1)
y <- x^2
z <- exp(x)
df1 <- data.frame(x, y)
df2 <- data.frame(x, z)
heart <- "U1F499"
thumbs_up <- "U1F44D"
# Create a custom function to convert Unicode values to GeomPoint
custom_points <- function(data, mapping, ..., shape = heart) {
ggplot2::geom_point(data = data, mapping = mapping, …, shape = shape)
}
ggplot() +
custom_points(data = df1, aes(x = x, y = y, color = “y = x^2”), shape = heart, size=5) +
geom_line(data = df1, aes(x = x, y = y, color = “y = x^2”)) +
custom_points(data = df2, aes(x = x, y = z, color = “z = exp(x)”), shape = thumbs_up, size=5) +
geom_line(data = df2, aes(x = x, y = z, color = “z = exp(x)”)) +
ggtitle(“Plot with Unicode points”) +
labs(color = “Function”) +
theme(legend.position = c(0.15, 0.85),
plot.title = element_text(color=”black”, size=14, face=”bold”),
legend.text = element_text(color=”black”, size=10, face=”bold”))
My second prediction
Here is my second prediction:
Here is the code for the mind reader:
# start with arbitrary set of unicode symbols
description =
c(“a_bengali”,”a_gurmukhi”,”approximately_equal”,”biohazard”,”black_diamond”,
“black_heart”,”black_scissors”,”mercury”,
“mushroom”,”nya_gujarati”,
“section”,”snowflake”,
“snowman”,”teardrop_spoked_asterisk”,”thunderstorm”,
“umbrella_raindrops”,”white_cross”,”white_florette”,
“zhe_cyrillic”, “airplane”,
“black_right_arrow”,”black_telephone”,”blue_heart”,
“two_xs”,”hot_beverage”,”green apple”,”pill”,
“trophy”,”thumbs_up”)
unicode=
c(“U0986″,”U0A05″,”U2248″,”U2623″,”U25C6″,”U2665″,”U2702″,”U263F”,
“U1F344″,”U0A9E”,”U00A7″,”U2746″,
“U26C4″,”U273B”,”U2608″,”U2614″,”U271E”,”U2740″,
“U04DC”,”U2708″,”U27A4″,”U260E”,”U1F499″,”U1F9E0″,”U2615″,”U1F34F”,
“U1F48A”,”U1F3C6″,”U1F44D”)
df_uni <- data.frame(cbind(description, unicode))
n <- nrow(df_uni)
x <- seq(1,n,1)
s <- sample(x, 1)
diag <- unicode[s]
diag
x <- x[-x[s]]
y <- sample(x, 100, replace = TRUE) # randomly choose 100 symbols
df <- data.frame(matrix(ncol = 20, nrow = 10))
for (i in seq(1, 19, by = 2)) {
df[, i] <- seq(99, 9, -10) - (i - 1) / 2 # row i, odd columns
df[, i + 1] <- y[((i - 1) / 2 * 10 + 1):((i - 1) / 2 * 10 + 10)] # row i, even columns
df[, i + 1] <- unicode[df[, i + 1]]
}
for (i in 1:10) {
df[i, 20 – 2*(i – 1)] <- diag
}
op <- par(bg = "thistle")
plot(x = c(0, 50*20), y = c(0, 50*10), type = “n”, xlab = “”, ylab = “”, xaxt = ‘n’,
yaxt = ‘n’, main = “Mind Reader # 1”, cex=2, font=2)
# Loop through each cell of the dataframe to draw rectangles and add text
for (i in 1:20) {
for (j in 1:10) {
# Determine the color based on whether the column index is odd or even
fill_color <- ifelse(i %% 2 == 1, "cornsilk", "lightblue")
# Draw rectangle with the determined color
rect(50*(i-1), 50*(10-j), 50*i, 50*(10-j+1), col = fill_color, border = “blue”)
# Add text in the center of the rectangle
text(50*(i-1) + 25, 50*(10-j) + 25, df[j, i], col = “navyblue”, cex = 1, font = 2)
}
}
# Restore original graphics parameters
par(op)
Hint on prediction
The prediction relies on a little algebra. As a hint, your original two-digit whole number is of the form, 10*T + U. What happens when you subtract the digits?
End
<
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you’re looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don’t.
Continue reading: Mind reader game, and Unicode symbols
Mind Reader Game and the Power of Unicode Symbols
In this mathematics-oriented blog post, Jerry Tuttle presents a simplistic “Mind Reader” game that utilizes Unicode symbols. The game challenges viewers to select a two-digit number, subtract each individual digit from the original number, and correspond the result to a specific Unicode symbol. The premise of the game is for Mr. Tuttle to predict the viewer’s chosen symbol.
What are Unicode Symbols?
Unicode is an internationally recognized standard system that assigns unique numbers to each character, digit, or symbol. This universal coding allows for thousands of symbols to be accurately represented across various platforms, programs, and languages. Each Unicode symbol is identified by “U+” followed by a hexadecimal number, such as U+1F499. However, in the context of the game, a Unicode symbol is printed in R language starting with a backslash to bypass the U, and excluding the plus sign.
Long-term Implications and Future Developments
The use of Unicode in this game showcases how mathematical equations and programming languages can be combined to create engaging and interactive learning experiences. Long-term, the implications are significant for educators and students alike. One can manipulate this concept to teach not only mathematics and programming but also regularization of information across the global digital space.
Education and Learning
In terms of education, the use of Unicode allows students to visualize abstract numerical concepts more tangibly. This enhances comprehension and makes learning more enjoyable, which is particularly beneficial for complex and often tedious subjects like mathematics and programming.
Universal Information Representation
From a more broad perspective, Unicode simplifies the standardization of symbols, allowing consistency in representation across various platforms worldwide. This presents opportunities for improved collaboration and communication, paving the way for more universal and cross-cultural digital interactions.
Actionable Advice
The following are some suggested steps for maximizing the potential of Unicode and its application in teaching and learning:
- Integrate games and interactivities: Utilize the concept of games similar to the Mind Reader game to introduce mathematical and programming concepts.
- Use Unicode for visualization: Make abstract ideas more concrete by using Unicode. This does not limit to mathematics or programming but extends to other subjects as well.
- Include unicode in digitalization efforts: Emphasize the importance of Unicode in international digitalization efforts to ensure a uniform representation of symbols, characters, and digits across different languages and cultures.
In Conclusion
Despite being a simple game, the Mind Reader game highlights both the educational potential of combining mathematics and programming and the broader implications of Unicode in the standardization of the digital world. By harnessing such concepts, we can help create a more engaging, interactive, and universal digital environment and enhance learning experiences substantially.