Showing posts with label puzzle. Show all posts
Showing posts with label puzzle. Show all posts

19 January 2021

FLPoTD: Writing Checks

This problem was inspired by a puzzle on the 2021 Mystery Hunt:

Given a string S of characters from the latin alphabet (a-z), find the smallest nonnegative amount (dollars and cents) whose spelled-out representation contains S as a subsequence.

  • The dollar amount should not include 'and': 123 is "one hundred twenty three", not "one hundred and twenty three".
  • If the amount is less than $1.00 (one dollar and zero cents), then the dollar amount is omitted: $0.46 is "forty six cents"
  • The cents is always expressed: $46.00 is "forty six dollars and zero cents"
  • This table contains the names of powers of 10: https://en.wikipedia.org/wiki/Power_of_10#Positive_powers
Follow-up:
  • Given a list of strings, all of which use exclusively lowercase letters, find the most expensive word.

16 December 2017

A Number Theory Appetizer

Fix $x, y \in N$ such that $x$ and $y$ are coprime. Prove that there exists $n \in N$ such that $k | x^n - y^n$ for any $k \in N$.

18 May 2017

A C puzzle

Consider the following C code:

#include <stdio.h>

enum bitmask
{
    bitmask_A = 1,
    bitmask_B = 2,
    bitmask_C = 4
};
typedef enum bitmask bitmask;

struct a_s
{
    bitmask member;
};
typedef struct a_s a_t;

bitmask
f(a_t *arg)
{
    arg->member |= bitmask_B;
    return bitmask_C;
}

int
main()
{
    a_t foo;
    foo.member = bitmask_A;
    foo.member |= f(&foo);
    printf("%d\n", foo.member);
    return 0;
}
What happens?

30 January 2017

A Silly Physics Problem

Brought to you by Tyler Christensen

If you have two ideal 1F capacitors, one at 0V and one at 10V, and you connect them together instantaneously with an ideal superconductor, what is the final voltage? Note all components have zero physical size and there is zero parasitic inductance.