This file contains hidden or 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
## Detailed beginner solution ## | |
# Number of road patterns | |
n = gets.to_i | |
steering_commands = gets.chomp.split(';') | |
# Car position on the road first position is 1 and not 0 | |
# That's why we need to substract 1 | |
car_pos=steering_commands.shift.to_i-1 | |
# We will build an array of all the steering instructions to apply | |
steering_per_turn=[] | |
steering_commands.each do |command_block| |
This file contains hidden or 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
import sys | |
import math | |
grid=[] | |
class Node(object): | |
def __init__(self,x,y): | |
self.x=x | |
self.y=y | |
def right_n(self): | |
right=list(filter(lambda n: n.x>self.x and n.y==self.y, grid)) |
This file contains hidden or 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
# n: the number of temperatures to analyse | |
read n | |
closest_to_zero=9999 | |
read temperatures | |
for t in $temperatures; do | |
# t: a temperature expressed as an integer ranging from -273 to 5526 | |
echo "New temperature: ${t} closest to 0 so far: ${closest_to_zero}" >&2 | |
# Compare absolute values | |
if [[ "${t#-}" -lt "${closest_to_zero#-}" ]]; then | |
closest_to_zero=$t |
This file contains hidden or 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
read N | |
# An array of horses | |
declare -a horses | |
closest_strength=10000000 | |
# Initialize last to -1 because it's an invalid value | |
last=-1 | |
for (( i=0; i<N; i++ )); do | |
read horse | |
# We set the value as the key because it will be sorted automatically | |
horses[$horse]=1 |
This file contains hidden or 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
# Redirection of port 80 to port 443 | |
<virtualhost *:80> | |
ServerName redmine.domain.com | |
KeepAlive Off | |
RewriteEngine On | |
#RewriteCond %{HTTP_HOST} ^[^\./]+\.[^\./]+$ | |
RewriteRule ^/(.*)$ https://%{HTTP_HOST}/$1 [R=301,L] | |
This file contains hidden or 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
#!/bin/sh | |
# XenServer autostart script | |
# Use at your own risks | |
# Do not use with VMs using HA. | |
# Instructions: | |
# 1. Put this script in /root | |
# 2. Give execution permission: "chmod +x /root/xs_autostart.sh" | |
# 3. Add "@reboot /root/xs_autostart.sh" in root's crontab | |
# 4. Add the "autostart" to VM needing it | |
# 5. Add "autostart" in the descriptions of vApps needing it |