Write a function using the React JavaScript framework to navigate a trireme using the stars.
import React, { useState } from 'react';
// Example star directions
const STAR_DIRECTIONS = [
{ name: 'North Star (Polaris)', heading: 'North' },Write a function using the React JavaScript framework to navigate a trireme using the stars.
import React, { useState } from 'react';
// Example star directions
const STAR_DIRECTIONS = [
{ name: 'North Star (Polaris)', heading: 'North' },| class Solution: | |
| def exist(self, board: List[List[str]], word: str) -> bool: | |
| for x in range(len(board[0])): | |
| for y in range(len(board)): | |
| # doing the equality check here means that we omit one layer of | |
| # recursive function calls, which speeds things up considerably | |
| if board[y][x] == word[0] and self.__continuesFrom(board, word, 0, x, y): | |
| return True | |
| return False |
Write a program that takes in commands and moves one or more robots around Mars.
If I add a boolean auto_onboard_via_dpt column to the cohort_companies table, how can I ensure that at most one row has a true value for this column for a given company id?
To ensure that at most one row in the cohort_companies table has auto_onboard_via_dpt = true for a given company_id, you want to enforce a partial unique index (sometimes called a filtered unique index) at the database level.
Assuming you are using PostgreSQL (the most common DB for Elixir/Phoenix projects), you can do this with the following SQL:
CREATE UNIQUE INDEX unique_auto_onboard_via_dpt_per_company
ON cohort_companies (company_id)
WHERE auto_onboard_via_dpt IS TRUE;Multiverse wants to enhance their Mars Rover system with the following capabilities:
The Mars surface has obstacles that rovers must navigate around. Extend the system to:
| succeed |
| fail |
| defmodule HtmlLintNative do | |
| use Rustler, otp_app: :platform, crate: "platform_plugs_htmllintnative" | |
| def add(_a, _b), do: error() | |
| def lint(_html_string), do: error() | |
| defp error(), do: :erlang.nif_error(:nif_not_loaded) | |
| end |
| #[rustler::nif] | |
| fn lint(env: Env, input: String) -> Result<Term, Error> { | |
| let parse_errors = lint_html::lint(input); | |
| return convert_errors(env, parse_errors); | |
| } | |
| fn convert_errors(env: Env, parse_errors: Vec<(u64, String)>) -> Result<Term, Error> { | |
| if parse_errors.len() == 0 { | |
| return Ok(ok().to_term(env)); | |
| } else { |
| defmodule HtmlLintPlug do | |
| require Logger | |
| def init(opts), do: opts | |
| def call(conn, _opts) do | |
| Plug.Conn.register_before_send(conn, &lint/1) | |
| end | |
| defmodule Error do |