What programming language you start with really all depends on where you want to go with programming/coding. The great thing about this field is that there are an absolute abundance of smaller fields that you can go into, all using programming in their own unique ways. For web applications, a good start would be with HTML and later moving your way through CSS, JavaScript, JQuery, PHP, SQL, and any of the JavaScript libraries. Ruby is also a popular choice, so I would recommend checking that out too. For more scientific fields or areas with more machine learning and A.I., Python is generally a great place to start as it is widely used in that field of study. C++ is also a very useful language to know for that, but it can be a little more challenging for beginners. For game and application design, languages such as C#, C, Swift, Kotlin, and Java are most often used for that.
Description
I found the game Hue Drops on a recent flight, turns out it's also a mobile game. One reviewer described it:
You start with one dot, and you can change the colours of the adjacent dots. It's like playing with the paint bucket tool in MS Paint! You slowly change the colour of the entire board one section at a time.
The puzzle opens with a group of tiles of six random colors. The tile in the upper left remains wild for you to change. Tile colors change by flooding from the start tile to directly connected tiles in the four cardinal directions (not diagonals). Directly connected tiles convert to the new color, allowing you to extend the size of the block. The puzzle challenges you to sequentially change the color of the root tile until you grow the block of tiles to the target color in 25 moves or fewer.
Today's challenge is to read a board tiled with six random colors (R O Y G B V), starting from the wild (W) tile in the upper left corner and to produce a sequence of color changes
Input Description
You'll be given a row of two integers telling you how many columns and rows to read. Then you'll be presented the board (with those dimensions) as ASCII art, each tile color indicated by a single letter (including the wild tile as a W). Then you'll be given the target color as a single uppercase letter. Example:
4 4 W O O O B G V R R G B G V O B R O
Output Description
Your program should emit the sequence of colors to change the puzzle to achieve the target color. Remember, you have only 25 moves maximum in which to solve the puzzle. Note that puzzles may have more than one solution. Example:
O G O B R V G R O
Challenge Input
10 12 W Y O B V G V O Y B G O O V R V R G O R V B R R R B R B G Y B O Y R R G Y V O V V O B O R G B R G R B O G Y Y G O V R V O O G O Y R O V G G B O O V G Y V B Y G R B G V O R Y G G G Y R Y B R O V O B V O B O B Y O Y V B O V R R G V V G V V G V
Solution
in python
inp= """10 12
W Y O B V G V O Y B
G O O V R V R G O R
V B R R R B R B G Y
B O Y R R G Y V O V
V O B O R G B R G R
B O G Y Y G O V R V
O O G O Y R O V G G
B O O V G Y V B Y G
R B G V O R Y G G G
Y R Y B R O V O B V
O B O B Y O Y V B O
V R R G V V G V V G
V"""
colors = "R O Y G B V".split()
def deep_copy(l):
return [[i for i in y] for y in l]
def make_iteration(field, flood, colors):
res = [0]*len(colors)
color_flood=[0]*len(colors)
for i, color in enumerate(colors):
#print(i)
color_flood[i] = deep_copy(flood)
temp_res = sum([sum(x) for x in color_flood[i]])
while True:
for x in range(len(flood)):
for y in range(len(flood[0])):
if color_flood[i][x][y] == 1:
if x > 0:
if field[x - 1][y] == color:
color_flood[i][x - 1][y] = 1
if x < len(field)-1:
if field[x + 1][y] == color:
color_flood[i][x + 1][y] = 1
if y > 0:
if field[x][y - 1] == color:
color_flood[i][x][y - 1] = 1
if y < len(field[0])-1:
if field[x][y + 1] == color:
color_flood[i][x][y + 1] = 1
if temp_res == sum([sum(x) for x in color_flood[i]]):
break
else:
temp_res = sum([sum(x) for x in color_flood[i]])
res[i] = temp_res
m = res.index(max(res))
return colors[m], color_flood[m]
inp = inp.split('\n')
size, field, final_col = list(map(int, inp[0].split())), [x.split() for x in inp[1:-1]], inp[-1]
flood = [[0 for i in range(size[0])] for y in range(size[1])]
flood[0][0] = 1
while True:
color, flood = make_iteration(field, flood, colors)
print(color)
#BEGINNING of unnecessary for solution, just for presentation
field = [[color if flood[x][y]==1 else field[x][y] for y in range(len(field[x]))] for x in range(len(field))]
for x in field:
print(x)
# END of unnecessary for solution, just for presentation
if sum([sum(x) for x in flood]) == size[0]*size[1]:
break
print(final_col)
for x in field:
print([final_col]*len(x))
I found the game Hue Drops on a recent flight, turns out it's also a mobile game. One reviewer described it:
You start with one dot, and you can change the colours of the adjacent dots. It's like playing with the paint bucket tool in MS Paint! You slowly change the colour of the entire board one section at a time.
The puzzle opens with a group of tiles of six random colors. The tile in the upper left remains wild for you to change. Tile colors change by flooding from the start tile to directly connected tiles in the four cardinal directions (not diagonals). Directly connected tiles convert to the new color, allowing you to extend the size of the block. The puzzle challenges you to sequentially change the color of the root tile until you grow the block of tiles to the target color in 25 moves or fewer.
Today's challenge is to read a board tiled with six random colors (R O Y G B V), starting from the wild (W) tile in the upper left corner and to produce a sequence of color changes
Input Description
You'll be given a row of two integers telling you how many columns and rows to read. Then you'll be presented the board (with those dimensions) as ASCII art, each tile color indicated by a single letter (including the wild tile as a W). Then you'll be given the target color as a single uppercase letter. Example:
4 4 W O O O B G V R R G B G V O B R O
Output Description
Your program should emit the sequence of colors to change the puzzle to achieve the target color. Remember, you have only 25 moves maximum in which to solve the puzzle. Note that puzzles may have more than one solution. Example:
O G O B R V G R O
Challenge Input
10 12 W Y O B V G V O Y B G O O V R V R G O R V B R R R B R B G Y B O Y R R G Y V O V V O B O R G B R G R B O G Y Y G O V R V O O G O Y R O V G G B O O V G Y V B Y G R B G V O R Y G G G Y R Y B R O V O B V O B O B Y O Y V B O V R R G V V G V V G V
Solution
in python
inp= """10 12
W Y O B V G V O Y B
G O O V R V R G O R
V B R R R B R B G Y
B O Y R R G Y V O V
V O B O R G B R G R
B O G Y Y G O V R V
O O G O Y R O V G G
B O O V G Y V B Y G
R B G V O R Y G G G
Y R Y B R O V O B V
O B O B Y O Y V B O
V R R G V V G V V G
V"""
colors = "R O Y G B V".split()
def deep_copy(l):
return [[i for i in y] for y in l]
def make_iteration(field, flood, colors):
res = [0]*len(colors)
color_flood=[0]*len(colors)
for i, color in enumerate(colors):
#print(i)
color_flood[i] = deep_copy(flood)
temp_res = sum([sum(x) for x in color_flood[i]])
while True:
for x in range(len(flood)):
for y in range(len(flood[0])):
if color_flood[i][x][y] == 1:
if x > 0:
if field[x - 1][y] == color:
color_flood[i][x - 1][y] = 1
if x < len(field)-1:
if field[x + 1][y] == color:
color_flood[i][x + 1][y] = 1
if y > 0:
if field[x][y - 1] == color:
color_flood[i][x][y - 1] = 1
if y < len(field[0])-1:
if field[x][y + 1] == color:
color_flood[i][x][y + 1] = 1
if temp_res == sum([sum(x) for x in color_flood[i]]):
break
else:
temp_res = sum([sum(x) for x in color_flood[i]])
res[i] = temp_res
m = res.index(max(res))
return colors[m], color_flood[m]
inp = inp.split('\n')
size, field, final_col = list(map(int, inp[0].split())), [x.split() for x in inp[1:-1]], inp[-1]
flood = [[0 for i in range(size[0])] for y in range(size[1])]
flood[0][0] = 1
while True:
color, flood = make_iteration(field, flood, colors)
print(color)
#BEGINNING of unnecessary for solution, just for presentation
field = [[color if flood[x][y]==1 else field[x][y] for y in range(len(field[x]))] for x in range(len(field))]
for x in field:
print(x)
# END of unnecessary for solution, just for presentation
if sum([sum(x) for x in flood]) == size[0]*size[1]:
break
print(final_col)
for x in field:
print([final_col]*len(x))
Comments
Post a Comment