Робот стартует из точки (0, 0) и смотрит на север. Команды повторяются бесконечно. Нужно определить:
👉Зациклится ли движение робота? (т.е. вернётся ли он в исходную точку или навсегда останется в замкнутом цикле)
📌Примеры:
isLooping("GLGLGLG") => true // движется по квадрату isLooping("GG") => false // уходит навсегда
🧩 Подвох задачи:
На первый взгляд кажется, что нужно бесконечно симулировать команды. Но на самом деле всё решается за один проход строки! Важно: если после одного прохода робот: - вернулся в (0,0) или - сменил направление — значит, будет цикл.
✅ Go-реализация:
```go func isLooping(commands string) bool { dirs := [][2]int{{0,1}, {1,0}, {0,-1}, {-1,0}} // север, восток, юг, запад x, y, d := 0, 0, 0
for _, c := range commands { switch c { case 'G': x += dirs[d][0] y += dirs[d][1] case 'L': d = (d + 3) % 4 case 'R': d = (d + 1) % 4 } }
return (x == 0 && y == 0) || d != 0 } ```
🎯 Отличная задача для собеседования: она проверяет • понимание направления и симуляции • знание работы с векторами • умение заменить бесконечный цикл на математический анализ
Робот стартует из точки (0, 0) и смотрит на север. Команды повторяются бесконечно. Нужно определить:
👉Зациклится ли движение робота? (т.е. вернётся ли он в исходную точку или навсегда останется в замкнутом цикле)
📌Примеры:
isLooping("GLGLGLG") => true // движется по квадрату isLooping("GG") => false // уходит навсегда
🧩 Подвох задачи:
На первый взгляд кажется, что нужно бесконечно симулировать команды. Но на самом деле всё решается за один проход строки! Важно: если после одного прохода робот: - вернулся в (0,0) или - сменил направление — значит, будет цикл.
✅ Go-реализация:
```go func isLooping(commands string) bool { dirs := [][2]int{{0,1}, {1,0}, {0,-1}, {-1,0}} // север, восток, юг, запад x, y, d := 0, 0, 0
for _, c := range commands { switch c { case 'G': x += dirs[d][0] y += dirs[d][1] case 'L': d = (d + 3) % 4 case 'R': d = (d + 1) % 4 } }
return (x == 0 && y == 0) || d != 0 } ```
🎯 Отличная задача для собеседования: она проверяет • понимание направления и симуляции • знание работы с векторами • умение заменить бесконечный цикл на математический анализ
The STAR Market, as is implied by the name, is heavily geared toward smaller innovative tech companies, in particular those engaged in strategically important fields, such as biopharmaceuticals, 5G technology, semiconductors, and new energy. The STAR Market currently has 340 listed securities. The STAR Market is seen as important for China’s high-tech and emerging industries, providing a space for smaller companies to raise capital in China. This is especially significant for technology companies that may be viewed with suspicion on overseas stock exchanges.
Export WhatsApp stickers to Telegram on iPhone
You can’t. What you can do, though, is use WhatsApp’s and Telegram’s web platforms to transfer stickers. It’s easy, but might take a while.Open WhatsApp in your browser, find a sticker you like in a chat, and right-click on it to save it as an image. The file won’t be a picture, though—it’s a webpage and will have a .webp extension. Don’t be scared, this is the way. Repeat this step to save as many stickers as you want.Then, open Telegram in your browser and go into your Saved messages chat. Just as you’d share a file with a friend, click the Share file button on the bottom left of the chat window (it looks like a dog-eared paper), and select the .webp files you downloaded. Click Open and you’ll see your stickers in your Saved messages chat. This is now your sticker depository. To use them, forward them as you would a message from one chat to the other: by clicking or long-pressing on the sticker, and then choosing Forward.