-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed codespaces for debugging and fixed day2p1
- Loading branch information
Showing
5 changed files
with
107 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,36 @@ | ||
{ | ||
"image": "mcr.microsoft.com/devcontainers/universal:2", | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"Shopify.ruby-lsp" | ||
] | ||
} | ||
"name": "Ruby", | ||
"build": { | ||
"dockerfile": "Dockerfile", | ||
"args": { | ||
// Update 'VARIANT' to pick a Ruby version: 2, 2.7, 2.6, 2.5 | ||
"VARIANT": "3.2", | ||
// Options | ||
"INSTALL_NODE": "true", | ||
"NODE_VERSION": "lts/*" | ||
} | ||
}, | ||
|
||
// Set *default* container specific settings.json values on container create. | ||
"settings": { | ||
"terminal.integrated.shell.linux": "/bin/bash" | ||
}, | ||
|
||
// Add the IDs of extensions you want installed when the container is created. | ||
"extensions": [ | ||
"rebornix.Ruby" | ||
], | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
// "postCreateCommand": "ruby --version", | ||
|
||
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. | ||
"remoteUser": "vscode", | ||
"features": { | ||
"ghcr.io/devcontainers/features/ruby:1": {} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Number of Cubes | ||
RED = 12 | ||
GREEN = 13 | ||
BLUE = 14 | ||
|
||
def grab_valid(grab) | ||
grab = grab.split(",") | ||
|
||
grab.each do | colors | | ||
color = colors.split(" ") | ||
if color[1].upcase == "GREEN" | ||
if color[0].to_i > GREEN | ||
return false | ||
else | ||
next | ||
end | ||
elsif color[1].upcase == "RED" | ||
if color[0].to_i > RED | ||
return false | ||
else | ||
next | ||
end | ||
elsif color[1].upcase == "BLUE" | ||
if color[0].to_i > BLUE | ||
return false | ||
else | ||
next | ||
end | ||
else | ||
return false | ||
end | ||
end | ||
return true | ||
end | ||
|
||
def game_valid(game_data) | ||
grabs = game_data.split(";") | ||
|
||
grabs.each do | grab| | ||
unless grab_valid(grab) | ||
return false | ||
end | ||
end | ||
return true | ||
end | ||
|
||
def get_game_id(game_header) | ||
id = game_header.split(" ") | ||
id = id[1] | ||
end | ||
|
||
id_sum = 0 | ||
File.open(File.join(File.dirname(__FILE__), "input.txt"), "r") do |file| | ||
file.each_line do | line | | ||
game = line.split(":") | ||
game_id = get_game_id(game[0]).to_i | ||
raw_game_data = game[1] | ||
|
||
if game_valid(raw_game_data) | ||
id_sum += game_id | ||
end | ||
end | ||
end | ||
|
||
|
||
puts id_sum |