Implement a reversi engine Your job, for this golf, is to write a program that will take moves of a game of reversi (othello) and display the result to the user.
Input
A string of numbers taken from the range [0-7]. Each pair of numbers represent first the X coordinate, then the Y coordinate. Any characters not in that range should be ignored.
Output
A visual representation of the result of the game, including who is leading when the input ends. This may be graphical or keystroke output, but it must be a visual grid of the game, with a distinct character/graphical symbol for black, white, and empty.
Additionally, your code should output an error message and stop when an illegal move is entered (the same square more than once, or a square that will not flip any tiles).
Skips should be handled gracefully. A skip occurs when one color has no legal move, their turn is skipped and the other player gets to play.
Black always goes first.
Examples
23
........
........
........
..bbb...
...bw...
........
........
........
b

232425140504032627
........
........
........
b.bbb...
bbbww...
b.b.....
..b.....
..b.....
b

2324322513
........
........
........
..bbb...
..www...
........
........
........
e

23242555
........
........
........
..bbb...
..bbw...
..b.....
........
........
e

Haskell - 1493 bytes

In this version, there are no detailed error messages and the output is much more basic. The major change was replacing Either String a with Maybe a and since they are both monads, this was acheived by simply swapping Right a with Just a and Left String with Nothing.

{-# LANGUAGE OverloadedStrings #-}
import Prelude hiding ((>>=),concatMap,filter,foldl,head,last,map,null,replicate)
import Control.Applicative hiding (empty)
import Control.Monad hiding (replicateM)
import Data.Vector hiding ((++),concat,foldM,reverse,zip)
main=getLine>>= \s->h$t<$>(zip$cycle[w,v])<$>b s>>= \m->u(\b(c,x)->case d b x c of r@(Just _)->r;Nothing->if not$null$findIndices(\y->e$d b y c)$t[(x,y)|x<-[0..7],y<-[0..7]];then é;else d b x$not c)k$n m
 where b(x:y:s)=(:)(read [x],read [y])<$>b s;b(_:_)=é;b[]=è[];d b z c=let d=join$m(f b z c)$m(\v->(head v,last v))$replicateM 2$t[-1,0,1];in if null d;then Nothing;else u(\b (x,y)->case b!?y of Just r->(case r!?x of Just _->è$b//[(y,r//[(x,è c)])];Nothing->é);Nothing->é)b$n$d`snoc`z;e(Nothing)=w;e(Just _)=v;f b(x,y)c z@(u,v)=let r=x+u;s=y+v;t=(r,s);in (case g b t of Just(Just d)->if d==c;then l;else (case g b (r+u,s+v) of Just(Just _)->t`cons`f b t c z;_->l);Just(Nothing)->l;Nothing->l);g b(x,y)=(case b!?y of Just col->col!?x;Nothing->é);h(Just b)=p$(o$n$m(\r->o(n$m(\c->case c of Just False->"B";Just True->"W";Nothing->".")r)++"\n")b)++i(q(\(w,b)(rw,rb)->(w+rw,b+rb))(0,0)$m(\r->q(\s@(w,b)c->case c of Just True->(w+1,b);Just False->(w,b+1);_->s)(0,0)r)b);h Nothing=p"e";i(w,b)|w>b="W"++s w|b>w="B"++s b|v="N"++s(w+b);j=r 8 é;k=r 8 j//[(3,j//[(3,è v),(4,è w)]),(4,j//[(3,è w),(4,è v)])];l=empty;m=map;n=toList;o=concat;p=putStrLn;q=foldl;r=replicate;s=show;t=fromList;u=foldM;v=True;w=False;é=Nothing;è=Just

$ printf "232425140504032627" | ./nano-rve
........
........
........
B.BBB...
BBBWW...
B.B.....
..B.....
..B.....
B11

Original version - 4533 bytes

I will golf when there will be competition!
edit It has arrived

{-# LANGUAGE OverloadedStrings #-}
import Prelude hiding ((>>=),concatMap,filter,foldl,map,null,replicate)
import Control.Applicative hiding (empty)
import Control.Monad
import Data.Either
import Data.Vector hiding ((++),concat,foldM,reverse,zip)

type Case = Maybe Bool
type Board = Vector (Vector Case)
type Coord = (Int,Int)

-- fmap (toList) $ replicateM 2 [-1,0,1] -- minus (0,0)
directions :: Vector Coord
directions = fromList [(-1,-1),(-1,0),(-1,1),(0,-1),(0,1),(1,-1),(1,0),(1,1)]

--  [(x,y) | x <- [0..7], y <- [0..7]]
allCoords :: Vector Coord
allCoords = fromList [(0,0),(0,1),(0,2),(0,3),(0,4),(0,5),(0,6),(0,7),(1,0),(1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(2,0),(2,1),(2,2),(2,3),(2,4),(2,5),(2,6),(2,7),(3,0),(3,1),(3,2),(3,3),(3,4),(3,5),(3,6),(3,7),(4,0),(4,1),(4,2),(4,3),(4,4),(4,5),(4,6),(4,7),(5,0),(5,1),(5,2),(5,3),(5,4),(5,5),(5,6),(5,7),(6,0),(6,1),(6,2),(6,3),(6,4),(6,5),(6,6),(6,7),(7,0),(7,1),(7,2),(7,3),(7,4),(7,5),(7,6),(7,7)]

initBoard :: Board
initBoard = vs // [(3,v1),(4,v2)]
    where va = replicate 8 Nothing
          v1 = va // [(3,Just True),(4,Just False)]
          v2 = va // [(3,Just False),(4,Just True)]
          vs = replicate 8 va

showBoard :: Board -> String
showBoard b = (concat $ toList $ map (showRow) b) ++ (showScore b)
    where showCase :: Case -> String
          showCase c = case c of
              Just False -> "░B"
              Just True -> "▓W"
              Nothing -> "██"
          showRow :: Vector Case -> String
          showRow r = concat (toList $ map (showCase) r) ++ "\n"

showScore :: Board -> String
showScore b = winner score ++ "\n"
    where scoreCase :: (Int,Int) -> (Maybe Bool) -> (Int,Int)
          scoreCase (w,b) (Just True) = (w+1,b)
          scoreCase (w,b) (Just False) = (w,b+1)
          scoreCase s _ = s
          scoreRow :: Vector Case -> (Int,Int)
          scoreRow r = foldl (scoreCase) (0,0) r
          score :: (Int,Int)
          score = foldl (\(w,b) (rw,rb) -> (w+rw,b+rb)) (0,0) $ map (scoreRow) b
          winner :: (Int,Int) -> String
          winner (w,b) | w > b = "White with " ++ show w ++ " against Black with " ++ show b ++ "."
                       | b > w = "Black with " ++ show b ++ " against White with " ++ show w ++ "."
                       | otherwise = "Nobody with " ++ show (w+b) ++ "."

printBoard :: Board -> IO ()
printBoard b = putStrLn $ showBoard b
pm :: Either String Board -> IO ()
pm (Right b) = printBoard b
pm (Left s)  = putStrLn s

lookupBoard :: Board -> Coord -> Either String Case
lookupBoard b (x,y) = case b !? y of
    Just col -> case col !? x of
        Just c -> Right c
        Nothing -> Left "x is out of bounds"
    Nothing -> Left "y is out of bounds"

updateBoard :: Board -> Coord -> Bool -> Either String Board
updateBoard b (x,y) c = case b !? y of
    Just r -> case r !? x of
        Just _ -> Right $ b // [(y,r // [(x,Just c)])]
        Nothing -> Left "x is out of bounds"
    Nothing -> Left "y is out of bounds"

makePath :: Board -> Coord -> Bool -> Coord -> Vector Coord
makePath b (x,y) c (px,py) = case lookupBoard b (nx,ny) of
        Right (Just pc) -> if pc == c
            then empty
            else case lookupBoard b (nx+px,ny+py) of
                Right (Just _) -> (nx,ny) `cons` makePath b (nx,ny) c (px,py)
                _ -> empty
        Right (Nothing) -> empty
        Left _ -> empty
    where nx = x+px
          ny = y+py

makeMove :: Board -> Coord -> Bool -> Either String Board
makeMove b xy@(x,y) c = if null cases
        then Left $ "impossible move " ++ show xy ++ "."
        else foldM (\ob (cx,cy) -> updateBoard ob (cx,cy) c) b $ toList $ cases `snoc` (x,y)
    where cases = join $ map (makePath b (x,y) c) directions

makeMoves :: Board -> Vector (Bool,Coord) -> Either String Board
makeMoves b ms = foldM (\ob (c,xy) -> case makeMove ob xy c of
    rb@(Right _) -> rb
    Left _ -> if not $ null $ findIndices (\xy -> isRight $ makeMove ob xy c) allCoords
        then Left $ "wrong move " ++ show xy ++ "."
        else makeMove ob xy (not c)) b $ toList ms

movesFromString :: String -> Either String (Vector (Bool,Coord))
movesFromString cs = fromList <$> (zip $ cycle [False,True]) <$> coords cs
    where coords (x:y:cs) = (:) (read [x],read [y]) <$> coords cs
          coords (_:cs) = Left "invalid coordinates string"
          coords [] = Right []

isRight :: Either a b -> Bool
isRight (Left _) = False
isRight (Right _) = True

main=getLine>>= \s->pm$movesFromString s>>=makeMoves initBoard

Note : Your second example should be 232425140504032627.

Tests

With screenshots to prevent eye burns.

$ printf "232425140504032627" | ./rve

$ printf "2324" | ./rve

$ printf "1" | ./rve
invalid coordinates string

$ printf "24" | ./rve
wrong move (2,4).

Is is possible to get impossible move (x,y) when you use innardics (functions from the innards of the program and that you should not use) and x/y is out of bounds.


Scale from key and mode Most of you probably know the C major scale:

C D E F G A B C

The major scale is characterised by the intervals between adjacent notes, which measured in semitones are:

2 2 1 2 2 2 1

From these intervales, we can construct any major scale starting in any note (the key of the scale). The 12 notes in our 12-tone equal temperament tuning system are:

C C♯ D D♯ E F F♯ G G♯ A A♯ B

equivalently (substituting some enharmonic equivalents):

C D♭ D E♭ E F G♭ G Ab A B♭ B

with a semitone between each pair of adjacent notes.

Each scale has to have the seven notes in order, starting from the key. Otherwise, you could have two notes in the same line of the pentagram, which would be confusing. So, in G# major/ionian, you have F## instead of G; musicians will just look at where in the pentagram is the note, they already have learned the accidentals for each scale. Indeed, in G# major, F## is represented in the line of F## without accidentals, the accidentals are in the key signature - but since that key signature would require 2 sharps for F, usually this is notated as Ab major.

Shifting the 2 2 1 2 2 2 1 intervals, we arrive at seven different modes of the diatonic scale:

Ionian: 2 2 1 2 2 2 1 - corresponds to the major scale
Dorian: 2 1 2 2 2 1 2
Phrygian: 1 2 2 2 1 2 2
Lydian: 2 2 2 1 2 2 1
Mixolydian: 2 2 1 2 2 1 2
Aeolian: 2 1 2 2 1 2 2 - corresponds to the natural minor scale, and to the melodic minor scale when descending (when ascending, the melodic minor scale has raised 6th and 7th degrees. There is also a harmonic minor scale, with a raised 7th degree compared to the natural minor).
Locrian: 1 2 2 1 2 2 2

So, the challenge is to write a program that takes as input (via stdin) a key and a mode and outputs (via stdout) the corresponding scale. Some test cases (stdin(key mode) => stdout(scale)):

Input:              Output:
C mixolydian   =>   C D E F G A Bb
F mixolydian   =>   F G A Bb C D Eb
G mixolydian   =>   G A B C D E F
G# ionian      =>   G# A# B# C# D# E# F##
Bb aeolian     =>   Bb C Db Eb F Gb Ab

Further references:
How many (major and minor) keys are there? Why?

GolfScript, 96 characters
" "/~5<{+}*7%"v]nwm[{"=2*2base(;\(" #"@?]{.1>))["b""""#"..+]=+\[~@(@+@(7%65+\1$7%4%0>-]}7*;]" "*

Golfscript solution which can be tested online.
Note: As in the examples the key has to be upper case while mode has to be given in lower case.
Examples:
>C lydian
C D E F# G A B

>C mixolydian
C D E F G A Bb


Life and Death of Trees The Challenge

Write a program that takes an integer N as input, and outputs the stage of life or death that a tree is currently in. N will always be between 0 and 10.

The Stages of Life and Death

Life: To draw a stage of life, simply draw a base of size N, consisting of ^ characters, then move up and substract 2 from N, if the result is greater than 0, and draw a line of ^ characters again, again with the size of the new N. Repeat while N is larger than 0. To finish off, place either a single | character if the startoff value of N is odd, or two || characters if it was even.
Example: N = 5

  ^
 ^^^
^^^^^
  |

Note that if N = 0, only the stem will be drawn, without the leaves (^) on them.
Death: This is roughly the same as Life, except that the base is 10 - N, you use M instead of ^ and you add 2 to N and redraw the lines with the same procedure  as above, but this time you add 2 to N while it is smaller or equal to 10.
Example: N = 3

   M
  MMM
 MMMMM
MMMMMMM
   |

The Goal

Your program has to run in 2 different languages both have to take a input N. The first language has to output the life stage of a tree according to N, the second language has to output the death stage.

Rules

This is code-golf, the shortest code in bytes that meets all the requirements wins.
The code has to run in 2 different languages. Yes, Python 2 and Python 3 are different languages.
Standard loopholes are forbidden.
Trailing newlines or spaces are allowed.

Test Cases

Input: N = 1

First language (life):

 ^
 |

Second language (death):

    M
   MMM
  MMMMM
 MMMMMMM
MMMMMMMMM
    |

Input: N = 10

First language (life):

    ^^
   ^^^^
  ^^^^^^
 ^^^^^^^^
^^^^^^^^^^
    ||

Second language (death):

||

Good luck coding!

Dyalog APL / SOGL, 70 65 63 62 bytes

0000000: 7b0d 04eb c0fd 5832 5c49 e32a 2e4c ac20  {.....X2\I.*.L.
0000010: 4d2a 5b3a 836b 6b7d 01ea 500d 9b31 a90f  M*[:.kk}..P..1..
0000020: 7b0f c285 c8c7 b932 c00e f8b1 c70f 7db0  {......2......}.
0000030: 32c2 8531 9c85 80b2 b50f aa32 f97d       2..1.......2.}

Interpreted in the classic Dyalog APL encoding: - life: (contains unprintables), expects ⎕IO←1

{' ^|⎕X2I┤z.L?pMzÅÏÏ}ûP'[1+⍵{⍵,⍨⌽⍉(2|⍺)↓⍉⍵}↑2,⍨1/⍨¨⍳⌈⍵÷2]}

TryAPL here!

{' ^|..'[1+⍵{⍵,⍨⌽⍉(2|⍺)↓⍉⍵}↑2,⍨1/⍨¨⍳⌈⍵÷2]}

         1+      add 1 to every value
 ' ^|..'[  ....] index the array getten below into " ^|.." with SOGLs code never being indexed in

⍵{..}↑2,⍨1/⍨¨⍳⌈⍵÷2

          1/⍨¨      replace each with that many 1s
              ⍳     the first ... numbers
               ⌈      ceiling of
                ⍵÷2     the right argument divided by 2
       2,⍨          append 2
      ↑             mix; convert to a 2D array, padding with zeroes
⍵{..}               execute that function with the arguments ⍵ - my right argument and the result of above

   {⍵,⍨⌽⍉(2|⍺)↓⍉⍵}  helper function
    ⍵,⍨             append the right arg to
               ⍉⍵     the right arg transposed
              ↓       without the first ... rows
         (2|⍺)          remainder of left arg ÷ 2
       ⌽⍉             transposed and reversed

Interpreted in SOGLs encoding - death:

{∑⁴╝υ”X2\I┐*.Lκ M*[:≥kk}¹╚P∑Β1Ι»{»φ√ωΩΡ2υ«⌠ΝΩ»}μ2φ√1β√↓νΟ»ι2⌡}

Try it Here!

Explanation:

{∑⁴╝υ”X                         push "{∑⁴╝υ" and pop it - noop
       2\                       push input divides by 2
         I┐*                    get that many + 1 vertical bars
            .Lκ                 push 10-input
                M*              get that many "M"s as a string
                  [    }        while ToS isn't falsy (here: isn't "")
                   :              duplicate the string
                    ≥             put the duplicate at the stacks bottom
                     kk           remove the last 2 letters (does nothing when the string is empty)
                        ¹       wrap everything in an array
                         ╚      center horizontally
                          P     print that
                           ...  execute a bunch of random nonsense which luckily does nothing

This took way too long.. Golfing tips for the APL part are welcome, everything mostly should be applicable as long as it doesn't change anything before ûP'

You can load the file (after reversing xxd) in SOGL by selecting the file in the Browse... dialog and then clicking load SOGL codepage encoded file.


Collapse consecutive integers Related: Tell me how many math problems I have to do!
Challenge
Given a strictly positive strictly ascending integer list L and an integer 3 ≤ N ≤ length of L, replace the middle integers of L's consecutive integer runs of length ≥ N with a single dash -.
Rules

Horizontal whitespace is irrelevant.
You may optionally preserve the introducer, separator, and terminator characters of your language's default list format. See Format examples, below.

Data examples
All these examples use L = 3 5 6 7 8 10 11 12 14 16 17 18 19 20 21 22 24.
N = 3 → 3 5 - 8 10 - 12 14 16 - 22 24
N = 4 → 3 5 - 8 10 11 12 14 16 - 22 24
N = 5 → 3 5 6 7 8 10 11 12 14 16 - 22 24
N = 8 → 3 5 6 7 8 10 11 12 14 16 17 18 19 20 21 22 24
Format examples
For the inputs
 L = [3,5,6,7,8,10,11,12,14,16,17,18,19,20,21,22,24] and N = 3
all the below lines are examples of valid responses, both as actual lists and as strings:
[3,5,"-",8,10,"-",12,14,16,"-",22,24]
[3,5,-,8,10,-,12,14,16,-,22,24]
[3,5-8,10-12,14,16-22,24]
3,5-8,10-12,14,16-22,24

The same applies with other list formats, like {1 2 3} and (1; 2; 3) etc. In doubt? Ask!

Python 2, 132 115 bytes

-17 bytes thanks to Leaky Nun

x,n=input()
o=[]
i=1
while x:
 t=x[0]
 while[t+i]==x[i:i+1]:i+=1
 o+=[[t,'-',t+i-1],x[:i]][i<n];x=x[i:];i=1
print o

Try it online!


Write a panic script to remote secure a Mac Pro from an untrustworthy local user The Situation

Suppose I allow "Shady Sam" admin access on my workstation to perform an important administrative task on my Mac Pro for me by giving them a temporary root login password. (Assume they were trustworthy, perhaps a systems admin for my company.)

From a remote location (e.g. home), I use my MacBook Pro laptop to observe Sam's activities and learn how to do the task myself via Remote Desktop (VNC).

Without warning, Shady Sam does something dastardly! Perhaps I see him trying to delete data from my hard drive or prying into restricted folders, etc. Whatever the dastardly deed, I want to lock Shady Sam out immediately, and secure the computer as best as possible from my remote location.

Since we share the mouse and keyboard, I couldn't reliably perform an action from within Remote Desktop (besides, they could close the connection). I'd have to write a script and run it remotely.

The Challenge

What's the best script (e.g. panicScript.sh or panicScript.py) I could run remotely to stop Shady Sam from performing his dastardly deed and prevent him from attempting it again?

I envision myself running it in the following way:

scp panicScript.sh remoteMachine:~/panicScript.sh
ssh remoteMachine . ~/panicScript.sh

Possible Features:

Other ideas are expressly encouraged!

Change passwords of any/all accounts on remoteMachine
Disable the keyboard or mouse
Disable the monitor
Reboot the machine

Assumptions

Shady Sam will not damage the Mac Pro in any way or remove any of its components (e.g. physically remove a hard drive or wired network connection), but he will attempt to re-login and continue his dastardly deed as quickly as possible. Sam has (otherwise) unrestricted physical access to the computer and a root login password.

Assume the Mac Pro has a monitor, keyboard, mouse, external hard drive, and an ethernet connection for internet. Let's suppose it can print to a network printer in a common area. For fun, let's suppose I have a standard user account on several coworker's workstations, which are identical to mine (so I can connect to their machines via ssh).

Assume there are a dozen open-air cubicles clustered together so that coworkers can stand up and talk to each other. My coworkers, however, will generally not suspect that Shady Sam is doing something dastardly if they see him at my computer because he has helped several of them in the past and didn't do dastardly things to their computers.

Constraints

The panic script is initially on my laptop at home. You can scp it to my machine and run it there, or run it directly from my laptop at home. (Specify in your response!)

All actions taken by the script must be non-damaging and/or reversible from my remote location so that I can regain access at a later point from my remote location, and must be standard features/commands on a Mac Pro.

The script may call other scripts/programs as long as they come standard with the machine. Command-line scripting tools (e.g. awk) are okay as long as their commands is contained in the main script (e.g. history | awk '{print $2}'). This admittedly limits the scripting languages that could be used.

Calling a custom script or program you wrote (e.g. . ~/myOtherScriptOfKungFoo.sh) isn't okay, unless you generate it from within your script and the generated script is under 32 characters:

echo -e "#"'!'"/bin/bash\necho \"Hello, World\"" >> test.sh
chmod +x test.sh
. test.sh

I shouldn't have to interact with the script more than once (e.g. to type a password).

Criteria

The script should be short (cap of 30 lines), yet readable. Primary criteria is thoroughness, creative features and style, which is better than simplicity.

Ultimately, the most votes wins!

The panic script should be sent to remote machine (Mac Pro) using scp, and then run (no sudo or any input required):

Here is the script: (this assumes that you are John Smith)

#!/bin/bash -m
f() {
 while true
 do
  pmset displaysleepnow
  sleep 0.1
 done
}
f&
while true
do
 osascript -e "set Volume 10"
 say -v Ralph "Stop Shady Sam now. He is trying to do something he is not allowed to."
 for n in {1..10};
 do
  afplay /System/Library/PrivateFrameworks/ScreenReader.framework/Versions/A/Resources/Sounds/Hit.aiff
  sleep 0.05
 done
 sleep 0.1
 say -v Ralph "This is John Smith speaking."
done

For maximum effiency, you should run this on every single machine in room to ensure that everybody will notice the problem and stop him.


Hole 2 - Prime Quine Find Hole 1 here.
Make a quine that, when run, outputs its own source code block multiple times. In fact, it must output it n times, where n in the next prime number.
I think an example shows it best.
[MY QUINE][MY QUINE]
[MY QUINE][MY QUINE][MY QUINE]
[MY QUINE][MY QUINE][MY QUINE][MY QUINE][MY QUINE]
[MY QUINE][MY QUINE][MY QUINE][MY QUINE][MY QUINE][MY QUINE][MY QUINE]
[MY QUINE][MY QUINE][MY QUINE][MY QUINE][MY QUINE][MY QUINE][MY QUINE][MY QUINE][MY QUINE][MY QUINE][MY QUINE]

Each Program will output its base "block" (so [MY QUINE]) the next prime number times.
Built in functions to calculate whether a number is prime, (like an isPrime function), or to determine the next prime (like a nextPrime() function) are not allowed.

This means that functions to list the number of divisors is not allowed
Functions that return the prime factorization are likewise disallowed

This should be a true quine (except for some leeway, see next point), so you should not read your own source code.
Because languages like Java and C# are already at a disadvantage, You need not output totally working code. If it could be put in a function (that is called) and output the next quine, you are good.
This is code-golf, so shortest code wins!

CJam, 31 bytes

{'_'~]-3>U):U{)__,1>:*)\%}g*}_~

Try it online in the CJam interpreter.

Idea

To check for primality, we'll use Wilson's theorem, which states that an integer n > 1 is prime if and only if (n - 1)! ≡ -1 (mod n), which is true if and only if (n - 1)! + 1 % n == 0.

Code

{                           }_~ e# Define a block and execute a copy.
                                e# The original block will be on top of the stack.
 '_'~]                          e# Push those characters and wrap the stack in an array.
      -3>                       e# Keep only the last three elements (QUINE).
         U):U                   e# Increment U (initially 0).
             {           }g     e# Do-while loop:
              )__               e# Increment the integer I on the stack (initially U).
                 ,1>            e#   Push [1 ... I-1].
                    :*          e#   Multiply all to push factorial(I-1).
                      )\%       e#   Push factorial(I-1) + 1 % I.
                                e# While the result is non-zero, repeat.
                                e# This pushes the next prime after U.
                           *    e# Repeat QUINE that many times.


My device malfunctions... Abuse its undefined string behaviour! Help! My device malfunctions and whenever I try to repeat a String, I get a messy results. Instead of repeating the same string N times, it fills an NxN square with each of its characters, and stacks the squares up.
For example, given the String "Test" and the number 2, instead of "TestTest", I get:
TT
TT
ee
ee
ss
ss
tt
tt

After I have seen this for a while, I started to like it. Your task today is to reproduce this strange behaviour. Given a non-empty string that consists of printable ASCII only, and a positive integer, output the String my malfunctioning device returns.

All standard rules apply.

The input and output may be handled through any reasonable mean.

This is code-golf, so the shortest code in bytes in each language wins.

Test Cases

Input
Output

----------

"Test", 2

TT
TT
ee
ee
ss
ss
tt
tt

----------

"UuU", 3

UUU
UUU
UUU
uuu
uuu
uuu
UUU
UUU
UUU

----------

"A", 5

AAAAA
AAAAA
AAAAA
AAAAA
AAAAA

----------

You can find a larger test case here. Good luck and have fun golfing!

Jelly, 5 bytes

This is exactly what we are asked to do... Abuse undefined behaviour!*

×+⁷×⁴

Try it online!

* By undefined behaviour I am talking about using × for repeating strings. Sometimes it's shorter than usual behaviour, so why not?


Decompose binary into alternating subsequences This was inspired by Problem 13 - Non-Repeating Binary of HP CodeWars' recent competition.

Let's take a random decimal number, say

727429805944311

and look at its binary representation:

10100101011001011111110011001011101010110111110111

Now split that binary representation into subsequences where the digits 0 and 1 alternate.

1010 010101 10 0101 1 1 1 1 1 10 01 10 0101 1 1010101 101 1 1 1 101 1 1

And convert each subsequence back into decimal.

10 21 2 5 1 1 1 1 1 2 1 2 5 1 85 5 1 1 1 5 1 1

The Task

Take a single, positive integer as input and output the sequence of positive integers obtained by the above process.

Details

Input and output must be in decimal or unary.
Numbers in the output must be separated in a sensible, human-readable fashion, and they must be in decimal or unary. No restriction on white space. Valid output styles: [1,2,3], 1 2 3, 1\n2\n3 where \n are literal newlines, etc.

Test cases

 Input | Output
     0 | 0
     1 | 1
     2 | 2
     3 | 1 1
     4 | 2 0
     5 | 5
     6 | 1 2
     7 | 1 1 1
     8 | 2 0 0
     9 | 2 1
    10 | 10
    50 | 1 2 2
   100 | 1 2 2 0
  1000 | 1 1 1 1 10 0 0
 10000 | 2 1 1 2 0 2 0 0 0
 12914 | 1 2 2 1 1 2 2
371017 | 5 42 10 2 1

Additional note: all numbers in the output should be of the form (2^k-1)/3 or 2*(2^k-1)/3. That is, 0 1 2 5 10 21, 42, 85, 170, ..., which is A000975 in the OEIS.

Pyth, 17 16 bytes

1 byte thanks to Jakube

iR2cJ.BQx1qVJ+dJ

Demonstration

A nice, clever solution. Uses some lesser known features of Pyth, like x<int><list> and c<str><list>.

iR2cJ.BQx1qVJ+dJ
                    Q = eval(input())
    J.BQ            Store in J the input in binary.
          qV        Vectorize equality function over
            J+dJ    J and J with a leading dummy char, to get the offset right.
                    This calculates whether each element matches its successor.
        x1          Find all of the indexes of 1 (True) in this list.
   cJ                Chop J at those locations.
iR2                  Convert from binary back to base ten and output.


Generate Toothpick Sequence What is Toothpick Sequence?
According to Wikipedia

In geometry, the toothpick sequence is a sequence of 2-dimensional
patterns which can be formed by repeatedly adding line segments
("toothpicks") to the previous pattern in the sequence.
The first stage of the design is a single "toothpick", or line
segment. Each stage after the first is formed by taking the previous
design and, for every exposed toothpick end, placing another toothpick
centered at a right angle on that end.
This process results in a pattern of growth in which the number of
segments at stage n oscillates with a fractal pattern between 0.45n2
and 0.67n2. If T(n) denotes the number of segments at stage n, then
values of n for which T(n)/n2 is near its maximum occur when n is near
a power of two, while the values for which it is near its minimum
occur near numbers that are approximately 1.43 times a power of two.
The structure of stages in the toothpick sequence often resemble the
T-square fractal, or the arrangement of cells in the Ulam–Warburton
cellular automaton.
All of the bounded regions surrounded by toothpicks in the pattern,
but not themselves crossed by toothpicks, must be squares or
rectangles. It has been conjectured that every open rectangle in the
toothpick pattern (that is, a rectangle that is completely surrounded
by toothpicks, but has no toothpick crossing its interior) has side
lengths and areas that are powers of two, with one of the side lengths
being at most two.

Task
You must make a program or function that take input from STDIN, function argument, or commandline argument and make a tootpick fractal at that stage. Leading and trailing newline is prohibited except if it is unavoidable. Bounding box must be at minimum, including leading and trailing space. For inital line, we make two \ diagonal in space. The input is guaranteed to be less than two thousand. At least one line have non-space character. Trailing space is allowed.
Test Cases
1
\
 \

5
    \
    /\
   /\
  / /\
\/\/\ \ \
 \ \ \/\/\
    \/ /
     \/
    \/
     \


Is there a shorter way to express this haskell idiom? Every so often I have a function of type a -> b and a function of type b -> b -> c and I would like a function of type a -> a -> c.  For example if I wanted to check the second element of each two tuples were equal

snd :: (a , b) -> b
(==) :: Eq a => a -> a -> Bool

And I want something of type

Eq b => (a, b) -> (c, b) -> Bool

The best way I have found to do this so far is

f g z=(.g).z.g

Which is ok, but it feels unneccessarily complex for something that is this simple.
The pointfree representation is even worse:

flip=<<((.).).(.).flip(.)

Additionally it feels like this idiom should be representable with some sort of abstraction (it feels a lot like (<*>)).  I attempted to find a replacement by abstracting our functions to functors, the result is not very enlightening

flip=<<(fmap.).fmap.flip fmap ::
  Functor f => f a -> (a -> a -> b) -> f (f b)

Is there a shorter way to express this idea?  Particularly the pointfree version?

I think eta-reduction is severely overrated. I see a lot more attempts at eta-reduction in the wild than I think is reasonable.

So it is in this case: eta-reducing this function is not helpful, I think. It's much more readable and elegant in its full form:

f :: (a -> a -> c) -> (a -> b) -> b -> b -> c
f g h a b = g (h a) (h b)

On a related note, such function exists in the standard libraries. It's called on, and the idea is to use it in infix form, so that it almost reads like English:

eqAmounts = (==) `on` amount
cmpNames = compare `on` name


Nth term of Van Eck Sequence Output the Nth term of the Van Eck Sequence.

Van Eck Sequence is defined as:

Starts with 0.
If the last term is the first occurrence of that term the next term is 0.
If the last term has occurred previously the next term is how many steps back was the most recent occurrence.

https://oeis.org/A181391

https://www.youtube.com/watch?v=etMJxB-igrc

https://www.youtube.com/watch?v=8VrnqRU7BVU

Sequence:
0,0,1,0,2,0,2,2,1,6,0,5,0,2,...

Tests:

Input | Output

1  | 0
8  | 2
19 | 5
27 | 9
52 | 42
64 | 0

EDIT

1 indexed is preferred, 0 indexed is acceptable; that might change some of the already submitted solutions.

Just the Nth term please.

Same (except for the seeing it already posted part), it seems code golfers and numberphile watchers have a decent overlap.

JavaScript (ES6),  46 41  37 bytes

n=>(g=p=>--n?g(g[p]-n|0,g[p]=n):p)(0)

Try it online!
How?
We don't need to store the full sequence. We only need to keep track of the last position of each integer that appears in the sequence. We use the underlying object of the recursive function \$g\$ for that purpose.
For a given term \$p\$, we don't need either to set \$g[p]\$ to its actual absolute position in the sequence because we're only interested in the distance with the current position. That's why we can just store the current value of the input \$n\$, which is used as a decrementing counter in the code.
Therefore, the distance is given by \$g[p]-n\$. Conveniently, this evaluates to NaN if this is the first occurrence of \$p\$, which can be easily turned into the expected \$0\$.
Commented
n => (             // n = input
  g = p =>         // g = recursive function taking p = previous term of the sequence
                   //     g is also used as an object to store the last position of
                   //     each integer found in the sequence
    --n ?          // decrement n; if it's not equal to 0:
      g(           //   do a recursive call:
        g[p] - n   //     subtract n from the last position of p
                   //     if g[p] is undefined, the above expression evaluates to NaN
        | 0,       //     in which case we coerce it to 0 instead
        g[p] = n   //     update g[p] to n
      )            //   end of recursive call
    :              // else:
      p            //   we've reached the requested term: stop recursion and return it
)(0)               // initial call to g with p = 0


Open the browser to http://codegolf.stackexchange.com Your job is to open a browser window of the default browser to http://codegolf.stackexchange.com.

Your code must open the browser itself, and cannot rely on an open one.

This is code-golf, so the shortest answer in bytes wins.

Oration, 41 bytes
Not winning, but sure was fun.  As of right now, I'm only 1 bytee behind python!
I need webbrowser
Now open "http:ppcg.ga"

Explanation:
I need compiles to import $1 with webbrowser being the module.
Now runs the following command from the module as module.command with the arguments of anything following.
So this compiles to:

#!/usr/bin/env python3
import webbrowser
webbrowser.open("http:ppcg.ga")

I do end up needing the http: part though, and it can't be shortened.


The pirate world's rules of distribution There is an existing "game" where pirates rationally divide gold coins according to certain rules. Quoting from Wikipedia:

There are 5 rational pirates, A, B, C, D and E. They find 100 gold coins. They must decide how to distribute them.
The pirates have a strict order of seniority: A is superior to B, who is superior to C, who is superior to D, who is superior to E.
The pirate world's rules of distribution are thus: that the most senior pirate should propose a distribution of coins. The pirates, including the proposer, then vote on whether to accept this distribution. In case of a tie vote the proposer has the casting vote. If the distribution is accepted, the coins are disbursed and the game ends. If not, the proposer is thrown overboard from the pirate ship and dies, and the next most senior pirate makes a new proposal to begin the system again.
Pirates base their decisions on three factors. First of all, each pirate wants to survive. Second, given survival, each pirate wants to maximize the number of gold coins each receives. Third, each pirate would prefer to throw another overboard, if all other results would otherwise be equal. The pirates do not trust each other, and will neither make nor honor any promises between pirates apart from a proposed distribution plan that gives a whole number of gold coins to each pirate.

Challenge
Take as input an integer n, 1<=n<=99, where n is the number of pirates - and output the distribution of coins, starting with the first pirate.
Test cases (first line is input; the second output):
1
100

2
100 0

3
99 0 1

5
98 0 1 0 1

This is code-golf, so the shortest solution in bytes wins.

Jelly, 11 10 bytes

R%2ḊµSȷ2_;

Try it online! or verify all test cases at once.

How it works

For input n, the task boils down to creating the list x, 0, 1, 0, … of length n whose sum is 100.

R%2ḊµSȷ2_;  Main link. Input: n

R           Yield [1, 2, ..., n].
 %2         Replace each integer by its parity. Yields [1, 0, 1, 0, ...].
   Ḋ        Dequeue; remove the first 1. This yields the list a = [0, 1, ...].
    µ       Begin a new, monadic link. Argument: a
     S      Compute the sum of a.
      ȷ2_   Subtract the sum from 100. (ȷ2 is 1e2 in Python syntax)
         ;  Prepend the difference to a.


Find relevant digit groupings Recently, my reputation was 25,121. I noticed that each digit grouping (i.e. the numbers separated by commas) was a perfect square.

Your challenge is, given a non-negative integer N and a unary boolean Black Box Function f : Z* → B , yield a truthy value if each value of f applied to the digit groupings of N is truthy, and falsey otherwise.

One can find the digit groupings by splitting the number into groups of 3, starting from the right side. The leftmost group may have 1, 2, or 3 digits. Some examples:

12398123  -> 12,398,123    (3 digit groupings)
10        -> 10            (1 digit grouping)
23045     -> 23,045        (2 digit groupings)
100000001 -> 100,000,001   (3 digit groupings)
1337      -> 1,337         (2 digit groupings)
0         -> 0             (1 digit grouping)

Additional rules

This function can map to either booleans (e.g. true and false), 1s and 0s, or any truthy/falsey value. Please specify which format(s) are supported by your answer.
You may take an integer as input, or an integer string (i.e. a string composed of digits).
You may write a program or a function.
When passing the digital groups to the function f, you should trim all unnecessary leading zeroes. E.g., f, when applied to N = 123,000 should be executed as f(123) and f(0).

Test cases

Function notation is n -> f(n), e.g., n -> n == 0. All operators assume integer arithmetic. (E.g., sqrt(3) == 1)

function f
integer N
boolean result

n -> n == n
1230192
true

n -> n != n
42
false

n -> n > 400
420000
false

n -> n > 0
0
false

n -> n -> 0
1
true

n -> sqrt(n) ** 2 == n
25121
true

n -> sqrt(n) ** 2 == n
4101
false

n -> mod(n, 2) == 0
2902414
true

n -> n % 10 > max(digits(n / 10))
10239120
false

n -> n % 10 > max(digits(n / 10))
123456789
true

Brachylog, 8 bytes

ḃ₁₀₀₀↰₁ᵐ

Try it online!

The blackbox function goes on the second line (or the "Footer" on TIO) and the integer is read from STDIN. Prints true. or false. accordingly.

ḃ₁₀₀₀      Compute the base-1000 digits of the input.
     ↰₁ᵐ   Map the blackbox predicate over each digit. We don't care about the
           result of the map, but the predicate must succeed for each digit,
           otherwise the entire map fails.


Tic-tac-toe with only crosses as quick as possible As per Luke's request and Peter Taylor's addition to this challenge.
Introduction
Everyone knows the game tic-tac-toe, but in this challenge, we are going to introduce a little twist. We are only going to use crosses. The first person who places three crosses in a row loses. An interesting fact is that the maximum amount of crosses before someone loses, is equal to 6:
X X -
X - X
- X X

That means that for a 3 x 3 board, the maximum amount is 6. So for N = 3, we need to output 6.
Another example, for N = 4, or a 4 x 4 board:
X X - X
X X - X
- - - -
X X - X

This is an optimal solution, you can see that the maximum amount of crosses is equal to 9. An optimal solution for a 12 x 12 board is:
X - X - X - X X - X X -
X X - X X - - - X X - X
- X - X - X X - - - X X
X - - - X X - X X - X -
- X X - - - X - - - - X
X X - X X - X - X X - -
- - X X - X - X X - X X
X - - - - X - - - X X -
- X - X X - X X - - - X
X X - - - X X - X - X -
X - X X - - - X X - X X
- X X - X X - X - X - X

This results in 74.
The task
Your task is to compute the results as fast as possible. I will run your code on the test case 13. This will be done 5 times and then the average is taken of the run times. That is your final score. The lower, the better.
Test cases
N     Output
1       1
2       4
3       6
4       9
5       16
6       20
7       26
8       36
9       42
10      52
11      64
12      74
13      86
14      100
15      114

More information can be found at https://oeis.org/A181018.
Rules

This is fastest-code, so the fastest submission wins!
You must provide a full program.
Please also provide how I have to run the program. I am not familiar with all programming languages and how they work, so I need a little bit of help here.
Of course, your code needs to compute the correct result for each test case.

Submissions:

feersum (C++11): 28s
Peter Taylor (Java): 14m 31s

Java, 14m 31s

This is essentially the program which I posted to OEIS after using it to extend the sequence, so it's a good reference for other people to beat. I've tweaked it to take the board size as the first command-line argument.

public class A181018 {
    public static void main(String[] args) {
        int n = Integer.parseInt(args[0]);
        System.out.println(calc(n));
    }

    private static int calc(int n) {
        if (n < 0) throw new IllegalArgumentException("n");
        if (n < 3) return n * n;

        // Dynamic programming approach: given two rows, we can enumerate the possible third row.
        // sc[i + rows.length * j] is the greatest score achievable with a board ending in rows[i], rows[j].
        int[] rows = buildRows(n);
        byte[] sc = new byte[rows.length * rows.length];
        for (int j = 0, k = 0; j < rows.length; j++) {
            int qsc = Integer.bitCount(rows[j]);
            for (int i = 0; i < rows.length; i++) sc[k++] = (byte)(qsc + Integer.bitCount(rows[i]));
        }

        int max = 0;
        for (int h = 2; h < n; h++) {
            byte[] nsc = new byte[rows.length * rows.length];
            for (int i = 0; i < rows.length; i++) {
                int p = rows[i];
                for (int j = 0; j < rows.length; j++) {
                    int q = rows[j];
                    // The rows which follow p,q cannot intersect with a certain mask.
                    int mask = (p & q) | ((p << 2) & (q << 1)) | ((p >> 2) & (q >> 1));
                    for (int k = 0; k < rows.length; k++) {
                        int r = rows[k];
                        if ((r & mask) != 0) continue;

                        int pqrsc = (sc[i + rows.length * j] & 0xff) + Integer.bitCount(r);
                        int off = j + rows.length * k;
                        if (pqrsc > nsc[off]) nsc[off] = (byte)pqrsc;
                        if (pqrsc > max) max = pqrsc;
                    }
                }
            }

            sc = nsc;
        }

        return max;
    }

    private static int[] buildRows(int n) {
        // Array length is a tribonacci number.
        int c = 1;
        for (int a = 0, b = 1, i = 0; i < n; i++) c = a + (a = b) + (b = c);

        int[] rows = new int[c];
        int i = 0, j = 1, val;
        while ((val = rows[i]) < (1 << (n - 1))) {
            if (val > 0) rows[j++] = val * 2;
            if ((val & 3) != 3) rows[j++] = val * 2 + 1;
            i++;
        }

        return rows;
    }
}

Save to A181018.java; compile as javac A181018.java; run as java A181018 13. On my computer it takes about 20 minutes to execute for this input. It would probably be worth parallelising it.


Chess - Find all legal moves (except castling and en passant) Write the shortest code that calculates all possible (legal) moves of current player from a given FEN string. What is FEN string? (Wikipedia)

Shortest code wins, language doesn't matter.
Output moves must obey chess rules of movement except en passant, castling, and pawn promotion.
Ignore check, checkmate, and stalemate, king cannot be captured situations too.

You can set outputs differently as you want (for example: A2-A4, A2A4, a2a4, a2->a4...)

Test cases:

# INPUT 1:

rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1

# OUTPUT 1

A2-A4, A2-A3, B2-B4, B2-B3, C2-C4, C2-C3, D2-D4, D2-D3, E2-E4, E2-E3,
F2-F4, F2-F3, G2-G4, G2-G3, H2-H4, H2-H3, B1-A3, B1-C3, G1-F3, G1-H3

# INPUT 2

7k/8/8/8/8/8/PP6/Q1q4K w - - 0 1

# OUTPUT 2

A1-B1, A1-C1, A2-A3, A2-A4, B2-B3, B2-B4, H1-H2, H1-G1, H1-G2

C - 391 bytes
Takes input as command line arguments and prints to stdout with the squares labeled from 0 to 63.
OK, I had a few minutes so I tried to delete all the bits relating to the detection of check. I think it is now not very efficient though...
O(x,y){return((x&7)-(y&7))/5;}
B[64],*b=B,J=32,M,L,x,*X,N;
main(int c,char**V){
for(;x=*V[1]++;c=J&2**V[2])
x>56?*b++=x:x>47?b+=x-48:0;
for(;b-->B;)
for(M=-1,N=*b%J^16,*V=strchr("bGInFJOQrAHkAGHIqAGHIpGHIx",*b|J);*b&&*b&J^c&&(M=M<0?*++*V%J:-M,**V<96);)
for(x=b-B,L=N?9^*b&8:1+(x/8==1+c/6);L--*!(O(x,x+M)|O(x>>3,x+M>>3));L=!*X|~*X&J^c&&N|(!*X^M&1&&M<0^!c)?printf("%d-%d ",b-B,x),L*!*X:0)
X=B+(x+=M);}

478 byte check-detecting version
O(x,y){return((x&7)-(y&7))/5;}
B[64],*b=B,c,I,J=32;
main(int C,char**V){
int*D,M,L,t,x,*X,N;
for(;b-B<64;C=c=J&2**V[2])
(t=*V[1]++)>56?*b++=t:t>47?b+=t-48:0;
for(D=b;D-->B;)
for(M=-1,N=*D%J^16,*V=strchr("bGInFJOQrAHkAGHIqAGHIpGHIx",*D|J);*D&&*D&J^C&&(M=M<0?*++*V%J:-M,**V<96);)
for(x=D-B,L=N?9^*D&8:1+(x/8==1+C/6);L--*!(O(x,x+M)|O(x>>3,x+M>>3));L=!*X|~*X&J^C&&N|(!*X^M&1&&M<0^!C)?c^C?I|=*X%J==11:(*X=*D,*D=I=0,main(C^J,V+1),*D=*X,I||printf("%d-%d ",D-B,x)),L*!(*X=t):0)
X=B+(x+=M),t=*X;}


Will Jimmy fall off his platform? Backstory
Meet my friend Jimmy:
/o\

Jimmy is a little character who likes to stand on platforms. Here's Jimmy safely standing on a platform:
         /o\
  -------------

Now, Jimmy has a good sense of balance, so he can safely stand with one leg off of the platform, like so:
   /o\
    -------------------

Although if he stands with two or more body parts off of the platform, he will fall. Both of these are examples where Jimmy will fall:
/o\                                       /o\
  ----------        ----------------------

The challenge
Your challenge is to write a program to determine, given a string with Jimmy's platform and position, if Jimmy can stand on the platform without falling off.

Input: Two lines showing Jimmy's position and the position of the platform under him. This can be from two separate inputs, a single input, or an array of some sort.

You may take input through any reasonable form, includings functions and standard input. Only resort to hard-coding if your language does not support the other input methods.

Output: The boolean values true and false, or the integers 1 or 0 to represent true/false respectively.

The boolean value is based off of whether Jimmy can stay on the platform or not - true if Jimmy can stay on the platform, or false if he will fall off.

The platform size is arbitrary and can be changed at will. Your program should account for that.

The platform cannot be a length of zero, and the platform must be complete (no holes in the platform).

Remember that Jimmy falls off when two of his body parts are hanging off the platform. A body part is one ASCII character of his body.

Trailing whitespace at the end of the platform is not required, but your program should account for both situations, where there is whitespace after the platform and where there is not.

Be mindful of the standard loopholes that are forbidden.

Test cases
         /o\               ✔ TRUE
  -------------

/o\                        ✔ TRUE
 ----------

                    /o\    ❌ FALSE
  ------------------

               /o\         ❌ FALSE
  -------

    /o\                    ❌ FALSE
     -

Scoring
This is code-golf, so lowest byte count wins.
Leaderboard
You can view the leaderboard for this post by expanding the widget/snippet below. In order for your post to be included in the rankings, you need a header (# header text) with the following info:

The name of the language (end it with a comma , or dash -), followed by...

The byte count, as the last number to appear in your header.

For example, JavaScript (ES6), 72 bytes is valid, but Fortran, 143 bytes (8-bit) is invalid because the byte count is not the last number in the header (your answer will be recognized as 8 bytes - don't take advantage of this).

<!-- Run the snippet to see the leaderboard. Report any bugs to @ozewski on Github -->    <iframe src="https://ozewski.github.io/ppcg-leaderboard/?id=187586" width="100%" height="100%" style="border:none;">Oops, your browser is too old to view this content! Please upgrade to a newer version of your browser that supports HTML5.</iframe><style>html,body{margin:0;padding:0;height:100%;overflow:hidden}</style>

Jelly, 6 bytes

n⁶Sċ2Ẓ

Try it online!

Explanation:

n⁶Sċ2Ẓ  args: z (e.g. [['/', 'o', '\\'], [' ', '-']] => 0)
        implicit return value: z ([['/', 'o', '\\'], [' ', '-']])
n⁶      dyad-nilad pair ([[1, 1, 1], [0, 1]])
 ⁶       4th command-line argument or space [4th CLA assumed absent] (' ')
n        vectorized inequality ([[1, 1, 1], [0, 1]])
  S     reduction by addition with base case 0 ([1, 2, 1])
   ċ2   dyad-nilad pair (1)
    2    literal (2)
   ċ     number of occurrences of right in left (1)
     Ẓ  primality (0)


Encrypt a string using vigenere techniques Your task:

Create a program that encrypts a string with another string using a key, using
the vigenere cipher.

What a vigenere cipher does

Ciphertext:   string
Key:          keya
 |             |
 v             v
string
keyake
 |
 v
(18)(19)(17)(08)(13)(06)
(10)(04)(24)(00)(10)(04)
 |
 v
(28)(23)(41)(08)(23)(10)
 |
 v
cxpixk

If it still isn't clear, read here.

Rules: No built-ins, shortest code in bytes wins, input and output will/should always be either completely lowercase, or completely uppercase.

string, keya -> cxpixk
aaaaaaaaaaaaaaaaaaaaaaaa,abcdefghijklmnopqrstuvwxyz -> abcdefghijklmnopqrstuvwxyz
vigenere, cipher -> xqvlrvtm
short, longkey -> dvbxd

Jelly, 9 bytes

2 bytes thanks to Dennis.

ṁ⁹,OS‘ịØA

Try it online!

How it works

ṁ⁹,OS‘ịØA            arguments: "KEYA", "STRING"

ṁ⁹         reshape   "KEYAKE"
  ,        pair      ["KEYAKE","STRING"]
   O       codepoint [[75,69,89,65,75,69],[83,84,82,73,78,71]]
    S      sum       [158,153,171,138,153,140]
     ‘     add 1     [159,154,172,139,154,141]
      ịØA  index ØA  "CXPIXK"
           where ØA is "ABCDEFGHIJKLMNOPSRQTUVWXYZ"


What are the repeating Fibonacci Digits? As you probably know, a Fibonacci Number is one which is the sum of the previous two numbers in the series.
A Fibonacci Digit™ is one which is the sum of the two previous digits.
For instance, for the series beginning 1,1, the series would be 1,1,2,3,5,8,13,4,7,11,2... The change occurs after the 13, where, instead of adding 8+13, you add 1+3. The series loops at the end, where 4+7=11, and 1+1=2, same as the series starts.
For another example, the series beginning 2,2: 2,2,4,6,10,1,1,2,3,5,8,13,4,7,11,2,3.... This one starts out uniquely, but once the digits sum to 10, you end up with 1+0=1, 0+1=1, and the series continues - and loops - the same way the 1,1 series did.

The Challenge
Given an integer input 0≤n≤99, calculate the loop in the Fibonacci Digit series beginning with those two digits. (You are certainly allowed to consider integers out of this range, but it's not required.) If given a one-digit input, your code should interpret it to denote the series beginning 0,n.
All numbers in the loop that are two-digits must be outputted as two digits. So, for instance, the loop for 1,1 would contain 13, not 1,3.
The output begins with the first number in the loop. So, based on the above restrictions, the loop for 1,1 begins with 2, since 1,1 and 11 are counted separately.
Each number of the output may be separated by whatever you want, as long as it's consistent. In all of my examples I use commas, but spaces, line breaks, random letters, etc. are all allowed, as long as you always use the same separation. So 2g3g5g8g13g4g7g11 is a legal output for 1, but 2j3g5i8s13m4g7sk11 is not. You can use strings, lists, arrays, whatever, provided that you have the correct numbers in the correct order separated by a consistent separator. Bracketing the entire output is also allowed (ex. (5,9,14) or [5,9,14], etc.).
Test Cases:
1 -> 2,3,5,8,13,4,7,11
2 -> 2,3,5,8,13,4,7,11
3 -> 11,2,3,5,8,13,4,7
4 -> 3,5,8,13,4,7,11,2
5 -> 2,3,5,8,13,4,7,11
6 -> 3,5,8,13,4,7,11,2
7 -> 14,5,9
8 -> 13,4,7,11,2,3,5,8
9 -> 11,2,3,5,8,13,4,7
0 -> 0
14 -> 5,9,14
59 -> 5,9,14

This is code-golf, so the lowest number of bytes wins.

Jelly, 15 bytes

DFṫ-SṭḊ
d⁵ÇÐḶZḢ

Try it online!

How it works

d⁵ÇÐḶZḢ  Main link. Argument: n (integer)

d⁵       Divmod 10; yield [n:10, n%10].
  ÇÐḶ    Call the helper link until a loop is reached. Return the loop.
     Z   Zip/transpose the resulting array of pairs.
      Ḣ  Head; extract the first row.

DFṫ-SṭḊ  Helper link. Argument: [a, b] (integer pair)

D        Decimal; replace a and b with the digits in base 10.
 F       Flatten the resulting array of digit arrays.
  ṫ-     Tail -1; take the last two digits.
    S    Compute their sum.
      Ḋ  Dequeue; yield [b].
     ṭ   Append the sum to [b].


Smallest number you can get by adding up numbers in sequence You a sequence of numbers like this one given to you as a string:

"1 2 3 4 8 11 19 33 59 154 196 260"

Create a program (any language) that calculates the smallest outcome you can't get by adding two of those numbers together.

The numbers given must be integers, and are always positive.

You can only use each number once.

The answer must be > 0 and a whole number. The given string must contain at least a 1.

Examples of invalid outcomes:

"1 2 3 4 8 11 19 33 59 154 196 260"

3 (1 + 2)
54 (19 + 33 + 8 + 2)

Example of valid outcome:

"1 2 7 34 34 78"

4 (1 + 2 = 3, can't get 4 by adding any numbers.)

The shortest answer wins, answers can be submitted until october 30th, 18:00 CET.

Python - 104 99

My interpretation:

L=map(int,input().split())
k=1
while k in map(sum,[[i,j]for i in L for j in L if i<j]):k+=1
print k

I tested it with the input string 0 1 2 3 4 8 11 19 33 59 154 196 260 containing a 0 to avoid the trivial solution 0.

Result:

16


ASCII ruler generation The challenge is to generate an ASCII character count ruler in the following format:

+-------------------------------------------------------------------------+
||    |    |    |    |    |    |    |    |    |    |    |    |    |    |  |
|0         10        20        30        40        50        60        70 |
|                                                                         |
+-------------------------------------------------------------------------+

The length of the ruler should be scalable to any multiple of 10.

Rules:

Ruler must be horizontal.
Let's say, to keep things simpler, that the ruler must work until the 1000 mark, all numbers left-aligned, one space after the final number.
Asking for a ruler with zero length should print NaR
Negative numbers should print a reversed ruler (-90, -80, -70, ...) with right-aligned numbers, in the exact same format as the one above otherwise

And, just printing to console is fine

Ready, set, golf!

Not going to beat the dynamic languages today, but anyway...

Haskell, 341

import Data.List
main=interact$unlines.m.map read.words
m[l,r]|r>l=ᴛ.("┌│││└":).(++["┬   ─","┐│││┘"]).ʀ.t.ʀ.t.takeWhile((>4).length).ᴛ$[c"┬",c"│    ",[l,l+10..r]>>=h.show,c" ",c"─"]|True=["NaR"]
h s=p s$length s;p s@('-':_)l=r(6-l)ꜱ++s++r 4ꜱ;p s l=r 5ꜱ++s++r(5-l)ꜱ
ᴛ=transpose;ʀ=reverse;r=replicate;c=cycle
ꜱ=' ';t l@(c:o)|c!!2==ꜱ=t o|True=l

I took the liberty of exchanging the actual ASCII characters with better-looking unicode box drawing chars.

$ echo "-50 30" | runhaskell  def0.hs
┌┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┐
│  │    │    │    │    │    │    │    │    │    │    │    │    │    │    │    │    │  │
│-50       -40       -30       -20       -10         0         10        20        30 │
│                                                                                │
└─────────────────────────────────────────────────────────────────────────────────────┘


Single Perceptron Implementation Challenge

Train a single perceptron with 2 inputs and 1 output.

Step 1: Initialize the weights

Step 2: Calculate the output

For inputs: [i1, i2, ..., in] and  weights: [w1, w2, ..., wn] the output is:

i1 * w1 + i2 * w2 + ... + in * wn

Step 3: Apply activation function on the output (i.e sigmoid)

Step 4: Update the weights

w(t + 1) = w(t) + r * (desired_output - actual_output)

Where r: learning rate

Step 5 Repeat steps 2, 3 and 4

Input

iterations: how many times you repeat steps 2, 3 and 4
input: a list with 2 input values i.e. [1, 0]
output: the desired output
learning_rate: the learning rate i.e.0.3

Output

It should print the last calculated output. Keep in mind this should be very close to the desired output i.e 0.96564545 for desired output 1

Example

For input (training for XOR):

1000, [1 0], 1, 0.3

The output should be:

0.9966304251639512

Note The output will never be the same even for identical test cases due to random weights initialization.

Here's some non-golfed code in Python for this test case:

Try it Online!

Rules

The inputs and outputs of the perceptron are fixed to: 2 and 1 respectively.
The output needs to be close to the desired output (see example).
You can use any activation function you want, just mention it.

JavaScript (Node.js), 121 110  bytes

Same as TFled. A "golfed" version of the example.

-11 bytes from @Arnauld

with(Math)f=(a,[b,B],c,d)=>(g=w=>a--?g(w.map(_=>_+d*(c-(y=1/(1+exp(B*w[1]-b*w[0])))))):y)([random(),random()])

Try it online!


Draw the EU Estimated Sign The specification of the "estimated" sign used by the European Union Directive (U+212e in Unicode, which you may not simply print for this challenge) is quite precise.

To copy some restrictions from this question: Render the symbol to file or screen using vector or raster graphics. If your output is rasterised, your image must have dimensions of 264 pixels × 240 pixels or more. Any other helping lines or length indicators must not be drawn.

VBA, 587 560 bytes

Sub S(a,b,c,d,e,f)
Set v=ActiveSheet.Shapes.AddShape(a,b,c,d,e)
v.Fill.ForeColor.RGB=f
v.Line.Visible=0
If a=5 Then v.Adjustments(1)=.5
End Sub
Sub U():p=91.5:w=-1
S 1,0,0,500,450,w
S 9,0,0,500,450,0
S 9,38.5,13.5,423,423,w
S 1,36,120,29,210,0
S 1,65,80,26.5,290,0
S 1,435,120,29,105,0
S 1,408.5,80,26.5,145,0
q=212.25:S 1,9,q,480,19,0
S 5,p,205.75,317,13,w
S 1,405,231.25,95,131.5,w
r=14.5:S 1,p,70.5,r,30,0
q=85:S 9,p,59.6,q,q,w
S 1,p,349.5,r,30,0
S 9,p,305.4,q,q,w
S 1,395,70.5,r,30,0
S 9,323.5,59.6,q,q,w
q=231.25:S 1,p,q,6.5,6.5,0
S 9,p,q,13,13,w
End Sub

Invoke macro U. Basically a lot of shape drawing. Shape 1 is a rectangle, 5 a rounded rectangle and 9 is an oval. Output is 500 wide by 450 high.

Edit: added the rounded rectangle (with adjustment to turn the ends into semicircles) to produce the radiused corners on top of the bar with one shape draw.


Play a Game of Minigolf Background
I feel that for a site named code-golf we have a shockingly little amount of golf being played. Let's fix that.
Challenge
Determine whether the hole of a minigolf course can be reached after exactly a certain number of movements and whether it can be reached at all.
How to play
Inputs are an integer "power level" and an ASCII art minigolf course. The ball starts on the X (capital) and the hole is an O (capital). The walls of the course are made of the characters + | - \ and /. The characters + | and - rotate the direction of the ball 180 degrees and the characters \ and / rotate the direction 90 degrees as you would expect. When a ball hits the wall it enters the wall for that turn and then leaves the next turn.
Launch the ball in each of the four cardinal directions from the starting X.

If the ball enters the hole after exactly the power level moves, then output truthy.
If the ball could make it to the hole given a different power level, then output mediumy.
If the ball cannot enter the hole regardless of the power level, output falsy.

Rules

This is code-golf so shortest answer in bytes wins.
Assume only valid input will be given.
All input strings will be rectangular. (All rows will be the same length)
Assume that there is no way to escape the course and leave the edge of the string.
No solution will require the ball to be in the same place facing the same direction twice.
Standard loopholes disallowed.
Only a string or a list of strings is acceptable for the course input.
Output can be any three distinct values.
The ball will never hit the characters | or - "end-on."

Example
11
   -----+
  /   X |
 | +----+
 | |
 |O|
 +-+

This is true. If the ball starts heading east it will be on the wall after two movements.
   -----+
  /   X o<- ball right here. movements:2
 | +----+
 | |
 |O|
 +-+

It will then change directions until it hits the corner
   -----+
  o   X | movements:8
 | +----+
 | |
 |O|
 +-+

Now it is heading south and will end in the hole after 11 moves. Note that 13 would also be true as the ball could bounce off of the bottom wall and into the hole. Other valid power levels for this course are 7 and 9.
Test Cases
All answers validated using this java code: https://github.com/Dragon-Hatcher/CodeGolfMiniGolf/tree/master/MinigolfCodeGolf/src
power
course
output

11
   -----+
  /   X |
 | +----+
 | |
 |O|
 +-+

truthy

10
    +---+
    | X |
    +---+
 +-+
 |O|
 +-+

falsy

25

      ---------
     /     X   \
    +++-------+ |
    | |       | |
    |O|       | |
    | \-------/ |
     \         /
      ---------

truthy

2

 +-+
 |X|
 | |
 | |
 |O|
 +-+

mediumy

34

      +------+
      |/    \|
      | +--+ |
      |X|  | |
  +---+ +--+ |
  |    O    /|
  +---+ +----+
      +-+

true

APL (Dyalog Unicode), 146 115 bytes
{(∨/+⍺⊃⊢)∨⌿↑{'O'=1↓⊃¨⊢∘(((⊢,⍉∘⊖∘⌽¨)1⌽¨⊂,⊂∘⍉)⊃⍨1⌈¯2+'X O\/'⍳⊃)\(4×≢,⍵)⍴⊂⍵}¨({¯1+⊃⊃⍸'X'=⍵}⌽⍉)⍣2¨(⊢,⌽∘⊖¨)(⊂,⊂∘⍉)⍵,⍳≢⍵}

-31 bytes (!) thanks to @Bubbler (combining transformations; simplifying iteration end condition; smaller details)
Try it online!
Outputs 2 for truthy, 1 for mediumy, and 0 for falsy.
Similarly to my solution to Solve the Halting Problem for Modilar SNISP, this moves the grid around the ball location, so the ball is always in the top-left, moving right. This might not be the best strategy (as opposed to storing a pointer position and direction) in this case because the ball doesn't always start from the top-left moving right, so I spend many bytes rotating and aligning the grid.
Details
Append 1,2,3,4,...,n to the input grid.
This prevents symmetric grids from comparing equal after some sequence of moves
⍵,⍳≢⍵

We must be careful here and elsewhere in the code that we do not affect
the angle of / and \. Using a simple reflection ⌽ to reverse direction
should change / to \, but the reflection of the character '/' is '/'.
Conveniently, APL matrix reflection operators are visually sensible:

⌽ reflects across a vertical line: swaps / and \
⊖ reflects across a horizontal line: swaps / and \
⍉ (transpose) reflects across the main diagonal: no change

Thus we must use an even total number of ⌽ and ⊖ in all transforms.
Obtain all 4 starting directions/rotations:
(⊢,⌽∘⊖¨)(⊂,⊂∘⍉)

Shift each grid so that 'X' is in the top left
(Shifts 'X' to the left edge twice, transposing the matrix in between)
{(¯1+⊃⊃⍸'X'=⍵)⌽⍉⍵}⍣2¨

For each starting grid, beginning with the starting grid, repeat 4×#coordinates (= max # of states) times...
\(4×≢,⍵)⍴⊂⍵

...move by one step:
(((⊢,⍉∘⊖∘⌽¨)1⌽¨⊂,⊂∘⍉)⊃⍨1⌈¯2+'X O\/'⍳⊃)
  ⍝ Get the ID of the entry: `X`, ` `, or `O`:1, `\`:2, `/`:3, `|`,`+`, or `-`:4
  ⍝ We can consider |, +, and - as the same because we are always travelling
  ⍝ horizontally (albeit on a rotated grid), and these all do the same action
  1⌈¯2+'X O\/'⍳⊃
  ⍝ Get the corresponding grid position after the move
  ((⊢,⍉∘⊖∘⌽¨)1⌽¨⊂,⊂∘⍉)⊃⍨

1 if there exists a move history whose final move's top-left element is O, and add another 1 if there exists a move history where the ⍺-th move has top-left element equal to O.
(∨/+⍺⊃⊢)∨⌿↑{'O'=1↓⊃¨


Generate n-ary numbers A secondary number is a positive integer whose prime factors (without multiplicity) are all less than or equal to its square root. 4 is a secondary number, because its only prime factor is 2, which equals its square root. However, 15 is not a secondary number, because it has 5 as a prime factor, which is larger than its square root (~ 3.9). Because all prime numbers have themselves as prime factors, no prime number is a secondary number. The first few secondary numbers are as follows:
1, 4, 8, 9, 12, 16, 18, 24, 25, 27, 30, 32, 36, 40, 45, 48, 49, 50, 54, 56

A tertiary number is defined similarly, except all the prime factors must be less than or equal to its cube root. The first few tertiary numbers are as follows:
1, 8, 16, 27, 32, 36, 48, 54, 64, 72, 81, 96, 108, 125, 128, 135, 144, 150, 160, 162

In general, an n-ary number is one whose prime factors are all less than or equal to its n-th root. Thus, a positive integer \$x\$ is an n-ary number iff each of its prime factors \$p\$ satisfies \$p^n ≤ x\$. Thus, primary numbers are all positive integers (all prime factors less than or equal to themselves), quartenary numbers have all their prime factors less than or equal to their fourth root, and so on.
The Challenge
Given integers k and n as inputs, output the kth n-ary number. k may either be zero- or one-indexed (your choice), and n will always be positive.
Examples
These are the first 20 elements in each sequence up to 10-ary numbers:
Primary: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
Secondary: 1, 4, 8, 9, 12, 16, 18, 24, 25, 27, 30, 32, 36, 40, 45, 48, 49, 50, 54, 56
Tertiary: 1, 8, 16, 27, 32, 36, 48, 54, 64, 72, 81, 96, 108, 125, 128, 135, 144, 150, 160, 162
Quarternary: 1, 16, 32, 64, 81, 96, 108, 128, 144, 162, 192, 216, 243, 256, 288, 324, 384, 432, 486, 512
5-ary: 1, 32, 64, 128, 243, 256, 288, 324, 384, 432, 486, 512, 576, 648, 729, 768, 864, 972, 1024, 1152
6-ary: 1, 64, 128, 256, 512, 729, 768, 864, 972, 1024, 1152, 1296, 1458, 1536, 1728, 1944, 2048, 2187, 2304, 2592
7-ary: 1, 128, 256, 512, 1024, 2048, 2187, 2304, 2592, 2916, 3072, 3456, 3888, 4096, 4374, 4608, 5184, 5832, 6144, 6561
8-ary: 1, 256, 512, 1024, 2048, 4096, 6561, 6912, 7776, 8192, 8748, 9216, 10368, 11664, 12288, 13122, 13824, 15552, 16384, 17496
9-ary: 1, 512, 1024, 2048, 4096, 8192, 16384, 19683, 20736, 23328, 24576, 26244, 27648, 31104, 32768, 34992, 36864, 39366, 41472, 46656
10-ary: 1, 1024, 2048, 4096, 8192, 16384, 32768, 59049, 62208, 65536, 69984, 73728, 78732, 82944, 93312, 98304, 104976, 110592, 118098, 124416

Jelly, 12 bytes

Æf*³<‘Ạ
1Ç#Ṫ

Takes n and k (one-indexed) as command-line arguments.

Try it online!

How it works

1Ç#Ṫ     Main link. Left argument: n. Right argument: k

1        Set the return value to 1.
 Ç#      Execute the helper link above for r = 1, 2, 3, ... until k of them return
         a truthy value. Yield the list of all k matches.
   Ṫ     Tail; extract the last match.

Æf*³<‘Ạ  Helper link. Argument: r

Æf       Compute all prime factors of r.
  *³     Elevate them to the n-th power.
    <‘   Compare all powers with r + 1.
      Ạ  All; return 1 if all comparisons were true, 0 if one or more were not.


Collatz, Sort, Repeat Background
The Collatz (or 3x+1) map (A006370) is defined as the following:
$$
  a(n) =
\begin{cases}
n/2,  & \text{if $n$ is even} \\
3n+1, & \text{if $n$ is odd}
\end{cases}
$$
Now, let's define the sequence \$s_0\$ as the infinite sequence of positive integers \$1, 2, 3, 4, \cdots\$, and define \$s_k\$ as the result of applying the process \$k\$ times to \$s_0\$:

Apply Collatz map to each term of the input sequence.
Sort all the terms to get a non-decreasing sequence.

Here are first few terms of \$s_0, \cdots, s_3\$:
s0: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, ...
s1: 1, 2, 3, 4, 4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 14, 15, 16, 16, 17, ...
s2: 1, 2, 2, 3, 4, 4, 5, 5, 6, 7, 8, 8, 9, 10, 10, 11, 11, 12, 13, 14, 14, ...
s3: 1, 1, 2, 2, 3, 4, 4, 4, 5, 5, 6, 7, 7, 8, 8, 9, 10, 10, 10, 11, 11, 12, ...

Challenge
Given \$k\$ as input, output the sequence \$s_k\$.
Default sequence I/O methods are allowed. For this challenge, this means you can use one of the following:

Take \$k\$ as input, and output the terms of \$s_k\$ forever.
Take \$k, n\$ as input, and output the value of \$s_k(n)\$ (0- or 1-indexed).
Take \$k, n\$ as input, and output the first \$n\$ values of \$s_k\$.

You can also use 0- or 1-indexing for \$k\$.
Standard code-golf rules apply. The shortest code in bytes wins.

Python 2, 81 bytes

f=lambda k,n:k and sorted([x/2,x*3+1][x%2]for x in f(k-1,n*2))[:n]or range(1,n+1)

Try it online!
-19 bytes thanks to Leo and Bubbler
-11 bytes thanks to dingledooper (-6 + -5 from Python 2)
-8 bytes by swapping over to the brute force solution
-2 bytes thanks to Noodle9
To get \$s_k\$ up to \$n\$ elements, we only need to get \$s_{k-1}\$ up to \$2n\$ elements.


How should you arrange your chairs? You teach a class of students with interesting preferences for how their chairs are arranged. There are 3 very specific requirements they have for how the chairs are arranged:

They most be arranged in a rectangle, even if it means some chairs go empty.

There must be as few empty chairs as possible.

They must be as "squarey" as possible. Squarey-ness is determined by the distance between the width and the height of the rectangle, lower is better. For example, a rectangle that is 4x7 has a squarey-ness of 3.

To be more specific, the "score" of an arrangement is the distance between the width and height plus the number of chairs that would go empty.
Let's take an example. Let's say you have 13 students. You could arrange the chairs any of these ways:
1x13
2x7
3x5
4x4

1x13 is not very squarey. In fact, 1 and 13 are 12 apart, so we give this arrangement 12 points. It also has 0 empty chairs, so we add 0 points, giving this arrangement a score of 12. Not that great.
2x7 is certainly better. 2 and 7 are only 5 apart, so we give this arrangement 5 points. However, if you actually arranged 2 rows of seven chairs, that would take 14 chairs, meaning one chair would be empty. So we add one point, giving this arrangement a score of 6.
We could also do 3x5. 3 and 5 are 2 apart, so +2 points. It takes 15 chairs, meaning we'd have two extra chairs, so another +2 points, for a score of 4.
Last option, 4x4. 4 and 4 are 0 apart, so we give this +0 points. 4x4 takes 16 chairs, so 3 chairs go empty, for a total score of 3. This is the optimal solution.
In case of a tie, the optimal solution is the one with less empty chairs.
The challenge
You must write a program or function that takes an integer and outputs the optimal arrangement of chairs for that number of students. IO can be in any reasonable format. Here is sample output for any number of students from 1 to 100:
1:  (1, 1)
2:  (1, 2)
3:  (2, 2)
4:  (2, 2)
5:  (2, 3)
6:  (2, 3)
7:  (3, 3)
8:  (3, 3)
9:  (3, 3)
10: (2, 5)
11: (3, 4)
12: (3, 4)
13: (4, 4)
14: (4, 4)
15: (4, 4)
16: (4, 4)
17: (3, 6)
18: (3, 6)
19: (4, 5)
20: (4, 5)
21: (3, 7)
22: (5, 5)
23: (5, 5)
24: (5, 5)
25: (5, 5)
26: (4, 7)
27: (4, 7)
28: (4, 7)
29: (5, 6)
30: (5, 6)
31: (4, 8)
32: (4, 8)
33: (6, 6)
34: (6, 6)
35: (6, 6)
36: (6, 6)
37: (5, 8)
38: (5, 8)
39: (5, 8)
40: (5, 8)
41: (6, 7)
42: (6, 7)
43: (5, 9)
44: (5, 9)
45: (5, 9)
46: (7, 7)
47: (7, 7)
48: (7, 7)
49: (7, 7)
50: (5, 10)
51: (6, 9)
52: (6, 9)
53: (6, 9)
54: (6, 9)
55: (7, 8)
56: (7, 8)
57: (6, 10)
58: (6, 10)
59: (6, 10)
60: (6, 10)
61: (8, 8)
62: (8, 8)
63: (8, 8)
64: (8, 8)
65: (6, 11)
66: (6, 11)
67: (7, 10)
68: (7, 10)
69: (7, 10)
70: (7, 10)
71: (8, 9)
72: (8, 9)
73: (7, 11)
74: (7, 11)
75: (7, 11)
76: (7, 11)
77: (7, 11)
78: (9, 9)
79: (9, 9)
80: (9, 9)
81: (9, 9)
82: (7, 12)
83: (7, 12)
84: (7, 12)
85: (8, 11)
86: (8, 11)
87: (8, 11)
88: (8, 11)
89: (9, 10)
90: (9, 10)
91: (7, 13)
92: (8, 12)
93: (8, 12)
94: (8, 12)
95: (8, 12)
96: (8, 12)
97: (10, 10)
98: (10, 10)
99: (10, 10)
100: (10, 10)

As usual, this is code-golf, so standard loopholes apply, and the winner is the shortest answer in bytes.

Jelly, 16 15 14 bytes

÷RĊ,Rµạ/+PỤḢịZ

Try it online! or verify all test cases.

How it works

÷RĊ,Rµạ/+PỤḢịZ  Main link. Argument: n

 R              Range; yield [1, ..., n].
÷               Divide n by each k in [1, ..., n].
  Ċ             Ceil; round the quotients up to the nearest integer.
    R           Range; yield [1, ..., n].
   ,            Pair; yield A := [[ ⌈n ÷ 1⌉, ..., ⌈n ÷ n⌉ ], [ 1, ..., n ]].
     µ          Begin a new, monadic chain. Argument: A
      ạ/        Reduce A by absolute difference.
                This yields [ |⌈n ÷ 1⌉ - 1|, ..., |⌈n ÷ n⌉ - n| ].
         P      Product; reduce A by multiplication.
                This yields [ ⌈n ÷ 1⌉ × 1, ..., ⌈n ÷ n⌉ × n].
       +        Add the results to left and right, element by element. This yields
                [ |⌈n ÷ 1⌉ - 1| + ⌈n ÷ 1⌉ × 1, ..., |⌈n ÷ n⌉ - n| + ⌈n ÷ n⌉ × n ].
          Ụ     Grade up; sort the indices of the list of sums by their values.
           Ḣ    Head; extract the first value, which corresponds to the smallest
                sum. Grading up is stable, so this selects the first index of all
                with the smallest sum in case of a tie. In this event, the first
                index will have the highest absolute difference of all indices
                with the smallest sum, meaning that it has the lowest product and,
                therefore, the lowest number of empty chairs.
             Z  Zip; transpose A's rows and columns.
                This yields [[ ⌈n ÷ 1⌉, 1 ], ..., [ ⌈n ÷ n⌉, n ]].
            ị   Retrieve the pair at that index.


Interpret your lang, but not yourself? There are many challenges that say "interpret X", where X is a simple language. In my opinion, that is way too boring. To give all the procrastinating people on the internet something interesting to do, you can try to do this challenge:
Challenge
Choose a language $LANG. $LANG can be any turing complete programming language or a turing complete subset of a programming language. Beware that if you omit a feature of your language in $LANG for interpretation, you must not use it for your own program, too, since your submission must be written in $LANG, too.
Write a compiler / interpreter for $LANG written in $LANG. You may use all facilities (including eval and friends) of your language that are available to write this compiler. To make the task more challenging, there is one restriction: You program should be able to interpret / compile all valid programs of $LANG except your interpreter / compiler itself. If it occurs that the program to be interpreted / compiled is your interpreter or compiler itself (regardless of the filename), your program should do something completely unrelated to the functionality of an interpreter or compiler (such as barfing or printing Hello, world!).
To make this task even more complex, your program must not read its own source when compiling or interpreting.
Specifications

This task is code golf. The submission with the least characters that is correct wins. In case of a tie, the solution that was submitted first wins.
Your program / script should read the program to be interpreted from a file. You may hardcode its path and name. When the file is read, you may either compile the file to another file (That must be executable on your system) or run it directly. If $LANG lacks file-reading capabilities, you can choose another way to read in the code that fits $LANG. You may not choose $LANG as a subset of another language but with file-reading capabilites removed.
Usual code-golf rules apply. That is: your personal pet-language that you made up just to solve this challenge is forbidden, if the solution becomes trivial using it (Such as defining a single-char program that exactly implements the solution). Abuse of rules is encouraged.

Perl, 89 chars, no cheating
$_=q($_=q(Q);s/Q/$_/;($q=join"",<>)eq$_?die:eval$q);s/Q/$_/;($q=join"",<>)eq$_?die:eval$q

Note that this code is extremely picky about what counts as "itself".  In particular, it will not recognize itself if there are any trailing newlines or other extra whitespace in the input.  To test it, save it into a file named (for example) unquine.pl and do this:
$ perl unquine.pl unquine.pl
Died at unquine.pl line 1, <> line 1.

Remember, the unquine.pl file should be exactly 89 bytes long, no more, no less.  Running it with some other Perl script as input just executes the other script, as it should:
$ perl unquine.pl hello.pl
Hello, world!

As the name might suggest, the implementation is based on a quine — specifically, this one:
$_=q($_=q(Q);s/Q/$_/);s/Q/$_/

This code sets $_ equal to itself; the rest of the program (which, of course, must be duplicated inside $_) just compares $_ to the input, dies if they match and evaluates the input otherwise.


List the Cases of Two Finnish Nouns Introduction

In this challenge, your task is to correctly list the cases of two Finnish nouns.
The twist is that you may use one of the listings as a guide to produce the other.

The Nouns

We use the following two declination tables as our data.
They list the cases of two nouns, one case per line in the same order as in the Wikipedia article linked above, in the form singular : plural where applicable.

Table 1: Cases of ovi ("door")

ovi : ovet
oven : ovien
oven : ovet
ovea : ovia
ovessa : ovissa
ovesta : ovista
oveen : oviin
ovella : ovilla
ovelta : ovilta
ovelle : oville
ovena : ovina
oveksi : oviksi
ovin
ovetta : ovitta
ovine

Table 2: Cases of jalka ("foot")

jalka : jalat
jalan : jalkojen
jalan : jalat
jalkaa : jalkoja
jalassa : jaloissa
jalasta : jaloista
jalkaan : jalkoihin
jalalla : jaloilla
jalalta : jaloilta
jalalle : jaloille
jalkana : jalkoina
jalaksi : jaloiksi
jaloin
jalatta : jaloitta
jalkoine

The Task

Your task is to write two programs f and g (possibly with different names) that take one string as input, give one string as output, and have the following property.
If Table 1 is given to f as input, it outputs Table 2, and if Table 2 is given to g, it outputs Table 1.
All other inputs result in undefined behavior.
The tables must appear exactly as above in both input and output.
You may optionally assume that there is a trailing newline, but then it must be used in both tables, and in both input and output.
There is no preceding newline.

Rules and Bonuses

You can write f and g as either functions or full programs, but they must be of the same type, and they must be completely separate (if you write a helper function for f, you must re-write it in g if you want to use it there).
The lowest total byte count wins, and standard loopholes are disallowed.

There is a bonus of -25 % for not using regular expressions.

Some Clarifications

It is perfectly fine to write a function/program f that ignores its input and always returns Table 2, and a function/program g that always returns Table 1.
It is only required that f(Table 1) == Table 2 and g(Table 2) == Table 1; the behavior of f and g on all other inputs is irrelevant.

The "completely separate" part means the following.
Your answer provides two pieces of code, one for f and one for g, preferably in different code boxes.
If I put the code for f in a file and run it, it works, and the same for g.
Your score is the sum of the byte counts of the two pieces of code.
Any duplicated code is counted twice.

Perl, 105 + 54 = 159

Program f (try me):

#!perl -p
s/vi /vka /;s/ve/va/g;s/en/an/;s/vi/voi/;s/ov/1&34960>>$.?jalk:jal/eg;s/ii/ihi/;s/loia/lkoje/;s/oia/oja/

Program g (try me):

#!perl -p
s/jalk?o?/ov/g;s/va /vi /;s/va/ve/g;s/an/en/;y/jh/i/d

An alternative version of f, only 2 bytes longer (this method can be also applied to g but it would be too long):

#!perl -p0
ka1a1a1koj1a1a1ka1koj1a1o0a1o0kaa2koih1a1o0a1o0a1o0ka1ko0a1o0o0a1o0ko=~s!\D+!"s/ov".'.'x$'."/jal$&/"!gree

Technically this still uses a regexp (to decode the substitution string and then to apply them) so I cannot claim the bonus here.


Output the simplified Goodstein sequence A number is in base-b simplified Goodstein form if it is written as

b + b + ... + b + c,   0 < c ≤ b

The simplified Goodstein sequence of a number starts with writing the number in base-1 simplified Goodstein form, then replacing all 1's with 2's and subtracting 1. Rewrite the result in base-2 simplified Goodstein form, then replace all 2's with 3's and subtract 1, etc. until you reach 0.

Your program is to take a positive integer input and output/print its Goodstein sequence and terminate. Your program should handle numbers less than 100, though it may not terminate in a reasonable amount of time.

For example, given 3 as the input, your program should output (the right side is just explanation)

1 + 1 + 1                | 3 = 1 + 1 + 1
2 + 2 + 1                | Change 1's to 2's, then subtract 1. (2 + 2 + 2 - 1 = 2 + 2 + 1)
3 + 3                    | 3 + 3 + 1 - 1 = 3 + 3
4 + 3                    | 4 + 4 - 1 = 4 + 3
5 + 2                    | 5 + 3 - 1 = 5 + 2
6 + 1                    | 6 + 2 - 1 = 6 + 1
7                        | 7 + 1 - 1 = 7
7                        | 8 - 1 = 7
6                        | Numbers are now lower than the base, so just keep subtracting 1.
5                        |
4                        |
3                        |
2                        |
1                        |
0                        | End

Spacing doesn't matter.

Winning criterion:

This is code-golf. Shortest code wins.

Python 2, 77 74 bytes

-3 bytes thanks to Lynn

n=input();b=1
while n:print"+".join(n/b*[`b`]+[`n%b`][:n%b]);n+=n/b-1;b+=1

Try it online!

Easily runs up to n = 100 (though the output is too long for tio fully show).


Bootloader golf: Brainf*** Create a bootloader that executes given Brainfuck program. This is code-golf, so the program with least bytes wins. Being a bootloader, the size of the program is counted in non-zero bytes in the compiled code.

Brainfuck

30000 8-bit overflowing cells. Pointer wraps over.

Some notes about operations:

Input must be read in a way that all printable ASCII characters are correctly supported. Other keystrokes may either insert an arbitrary character or do nothing at all.
Reading user input must be character buffered, not line buffered.
Reading user input must echo inserted character.
Output must follow either the code page 437 or your built-in VGA adapters default codepage.

Bootloader

This is a x86 bootloader. A bootloader ends with the traditional 55 AA sequence. Your code must run either on VirtualBox, Qemu or other well-known x86 emulator.

Disk

Executable Brainfuck is located at second disk sector, right after your bootloader, which is placed, as usually, in MBR section, the first sector on disk. Additional code (any code over 510 bytes) can be located at other disk sectors. Your storage device must be either a hard drive or a floppy disk.

STDIO

Of course, a bootloader cannot have an access to the operating system's IO capabilities. Therefore BIOS functions are used instead for printing text and reading user input.

Template

To get started, here is a simple template written in Nasm (intel syntax) assembly:

[BITS 16]
[ORG 0x7c00]

; first sector:

boot:
    ; initialize segment registers
    xor ax, ax
    mov ds, ax
    mov es, ax
    mov ss, ax

    ; initialize stack
    mov sp, 0x7bfe

    ; load brainfuck code into 0x8000
    ; no error checking is used
    mov ah, 2       ; read
    mov al, 1       ; one sector
    mov ch, 0       ; cylinder & 0xff
    mov cl, 2       ; sector | ((cylinder >> 2) & 0xc0)
    mov dh, 0       ; head
                    ; dl is already the drive number
    mov bx, 0x8000  ; read buffer (es:bx)
    int 0x13        ; read sectors

; fill sector
times (0x200 - 2)-($-$$) db 0

; boot signature
db 0x55, 0xaa

; second sector:

db 'brainfuck code here'

times 0x400-($-$$) db 0

Compiling this is pretty easy:

nasm file.asm -f bin -o boot.raw

And the run it. For example, with Qemu:

qemu-system-i386 -fda boot.raw

Addtional information: OsDev wiki, Wikipedia

171 bytes1

Wooohoooo! It took half the day, but it was fun...

So, here it is. I think it conforms to the specs (wraparound of cell pointer, echo of characters on input, reading char by char, echo of input chars, ...), and it seems to actually work (well, I didn't try many programs, but given the simplicity of the language, the coverage isn't that bad, I think).

Limitations

One important thing: if your brainfuck program contains other chars than the 8 brainfuck instructions, or if the [] are not well-balanced, it will crash on you, mouhahahaha!

Also, the brainfuck program can't exceed 512 bytes (a sector). But this seems conforming since you say "executable Brainfuck is located at second disk sector".

Last detail: I didn't explicitly initialized the cells to zero. Qemu seem to do it for me, and I'm relying on this, but I don't know whether a real BIOS on a real computer would do it (initialization would just take a few bytes more, anyway).

The code

(based on your template, and by the way, thanks for this, I would never have tried without it):

[BITS 16]
[ORG 0x7C00]

%define cellcount 30000 ; you can't actually increase this value much beyond this point...

; first sector:

boot:
    ; initialize segment registers
    xor ax, ax
    mov ss, ax
    mov ds, ax
    mov es, ax
    jmp 0x0000:$+5

    ; initialize stack
    mov sp, 0x7bfe

    ; load brainfuck code into 0x8000
    ; no error checking is used
    mov ah, 2       ; read
    mov al, 1       ; one sector
    mov ch, 0       ; cylinder & 0xff
    mov cl, 2       ; sector | ((cylinder >> 2) & 0xc0)
    mov dh, 0       ; head
                    ; dl is already the drive number
    mov bx, 0x8000  ; read buffer (es:bx)
    int 0x13        ; read sectors

    ; initialize SI (instruction pointer)
    mov si, bx ; 0x8000
    ; initialize DI (data pointer)
    mov bh, 0x82
    mov di, bx ; 0x8200

decode:
    lodsb ; fetch brainfuck instruction character
.theend:
    test al, al ; endless loop on 0x00
    jz .theend
    and ax, 0x0013 ; otherwise, bit shuffling to get opcode id
    shl ax, 4
    shl al, 2
    shr ax, 1
    add ax, getchar ; and compute instruction implementation address
    jmp ax

align 32, db 0

getchar:
    xor ah, ah
    int 0x16
    cmp al, 13
    jne .normal
    mov al, 10 ; "enter" key translated to newline
.normal:
    mov byte [di], al
    push di
    jmp echochar

align 32, db 0

decrementdata:
    dec byte [di]
    jmp decode

align 32, db 0

putchar:
    push di
    mov al, byte [di]
echochar:
    mov ah, 0x0E
    xor bx, bx
    cmp al, 10 ; newline needs additional carriage return
    jne .normal
    mov al, 13
    int 0x10
    mov al, 10
.normal:
    int 0x10
    pop di
    jmp decode

align 32, db 0

incrementdata:
    inc byte [di]
    jmp decode

align 32, db 0

decrementptr:
    dec di
    cmp di, 0x8200 ; pointer wraparound check (really, was that necessary?)
    jge decode
    add di, cellcount
    jmp decode

align 32, db 0

jumpback:
    pop si
    jmp jumpforward

align 32, db 0

incrementptr:
    inc di
    cmp di, 0x8200+cellcount  ; pointer wraparound check
    jl decode
    sub di, cellcount
    jmp decode

align 32, db 0

jumpforward:
    cmp byte [di], 0
    jz .skip
    push si
    jmp decode
.skip:
    xor bx, bx ; bx contains the count of [ ] imbrication
.loop:
    lodsb
    cmp al, '['
    je .inc
    cmp al, ']'
    jne .loop
    test bx, bx
    jz decode
    dec bx
    jmp .loop
.inc:
    inc bx
    jmp .loop

; fill sector
times (0x1FE)-($-$$) db 0

; boot signature
db 0x55, 0xAA

; second sector contains the actual brainfuck program
; currently: "Hello world" followed by a stdin->stdout cat loop

db '++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.,[.,]'

times 0x400-($-$$) db 0

Tricks used

Ok, I cheated a bit. Since you said "being a bootloader, the size of the program is counted in non-zero bytes in the compiled code", I made the code smaller by allowing "holes" between the implementation of the eight brainfuck opcodes. This way, I don't need a big sequence of tests, a jump table, or anything: I just jump to the brainfuck "opcode id" (from 0 to 8) multiplied by 32 to execute the brainfuck instruction (worth to note that it means the implementation of the instructions can't take more than 32 bytes).

Moreover, to get this "opcode id" from the brainfuck program character fetched, I noticed just a bit of bit shuffling was necessary. Indeed, if we just consider bits 0, 1 and 4 of the opcode character, we end up with the 8 unique combinations:

   X  XX
00101100 0x2C , Accept one byte of input, storing its value in the byte at the pointer.
00101101 0x2D - Decrement (decrease by one) the byte at the pointer.
00101110 0x2E . Output the value of the byte at the pointer.
00101011 0x2B + Increment (increase by one) the byte at the pointer.
00111100 0x3C < Decrement the pointer (to point to the next cell to the left).
01011101 0x5D ] Jump back after the corresp [ if data at pointer is nonzero.
00111110 0x3E > Increment the pointer (to point to the next cell to the right).
01011011 0x5B [ Jump forward after the corresp ] if data at pointer is zero.

And, lucky me, there is actually one opcode that requires more than 32 bytes to implement, but it's the last one (jump forward [). As there is more room after, everything is fine.

Other trick: I don't know how a typical brainfuck interpreter works, but, to make things much smaller, I did not actually implement ] as "Jump back after the corresponding [ if data at pointer is nonzero". Instead, I always go back to the corresponding [, and, from here, re-apply the typical [ implementation (which then, eventually, goes forward after the ] again if needed). For this, each time I encouter a [, I put the current "brainfuck instruction pointer" on the stack before executing the inner instructions, and when I encounter a ], I pop back the instruction pointer. Pretty much as if it was a call to a function. You could therefore theoretically overflow the stack by making many many imbricated loops, but not with the current 512-bytes limitation of the brainfuck code, anyway.

1. Including the zero bytes that were part of the code itself, but not those that were part of some padding


Convert a pawn promotion from algebraic to ICCF numeric notation Input

A single string, which contains no whitespace, as a command-line argument.

Output

If the string is not a valid algebraic notation pawn promotion, produce no output and exit. If the string is a valid pawn promotion, convert it to ICCF numeric notation and print the result, followed by a newline.

A valid algebraic notation pawn promotion consists of:

A letter from a to h indicating the pawn's departure column (known as a "file" in chess);
Optionally, "x" followed by the file of the pawn's arrival square if it has captured a piece in promoting;
"1" or "8" depending on which side promoted; and
"=" followed by one of "Q", "R", "B", "N" to indicate the chosen piece;
Optionally, "+" to indicate the move was a check or "#" to indicate the move was a checkmate.

An valid ICCF numeric notation pawn promotion consists of:

Two digits indicating the coordinates of the square from which the pawn departed (the files are numbered and not lettered as in algebraic notation);
One digit indicating the file on which the pawn arrived, in case it has captured a piece while promoting (this does not officially comply with the standard, but I prefer keeping all moves as 4 digits for simplicity); and
One digit to indicate the chosen piece: 1 for queen, 2 for rook, 3 for bishop, 4 for knight.

Examples

e1=Q   => 5251
cxd8=B => 3743
axh8=R => no output (a-pawns cannot capture on h-file)
h8=N+  => 8784


Cyclotomic polynomial Background (skip to definitions)

Euler proved a beautiful theorem about the complex numbers: eix = cos(x) + i sin(x).

This makes de Moivre's theorem easy to prove:

(eix)n = ei(nx)

(cos(x) + i sin(x))n = cos(nx) + i sin(nx)

We can plot complex numbers using the two-dimensional Euclidean plane, with the horizontal axis representing the real part and the vertical axis representing the imaginary part. This way, (3,4) would correspond to the complex number 3+4i.

If you are familiar with polar coordinates, (3,4) would be (5,arctan(4/3)) in polar coordinates. The first number, r, is the distance of the point from the origin; the second number, θ, is the angle measured from the positive x-axis to the point, counter-clockwise. As a result, 3 = r cosθ and 4 = r sinθ. Therefore, we can write 3+4i as r cosθ + r i sinθ = r(cosθ + i sinθ) = reiθ.

Let us solve the complex equation zn = 1, where n is a positive integer.

We let z = reiθ. Then, zn = rneinθ. The distance of zn from the origin is rn, and the angle is nθ. However, we know that the distance of 1 from the origin is 1, and the angle is 0. Therefore, rn=1 and nθ=0. However, if you rotate by 2π more, you still end up at the same point, because 2π is just a full circle. Therefore, r=1 and nθ = 2kπ, giving us z=e2ikπ/n.

We restate our discovery: the solutions to zn=1 are z=e2ikπ/n.

A polynomial can be expressed in terms of its roots. For example, the roots of x2-3x+2 are 1 and 2, so x2-3x+2 = (x-1)(x-2). Similarly, from our discovery above:

However, that product certainly contained roots of other n. For example, take n=8. The roots of z4=1 would also be included inside the roots of z8=1, since z4=1 implies z8 = (z4)2 = 12 = 1. Take n=6 as an example. If z2=1, then we would also have z6=1. Likewise, if z3=1, then z6=1.

If we want to extract the roots unique to zn=1, we would need k and n to share no common divisor except 1. Or else, if they share a common divisor d where d>1, then z would be the (k/d)-th root of zn/d=1. Using the technique above to write the polynomial in terms of its roots, we obtain the polynomial:

Note that this polynomial is done by removing the roots of zn/d=1 with d being a divisor of n. We claim that the polynomial above has integer coefficients. Consider the LCM of the polynomials in the form of zn/d-1 where d>1 and d divides n. The roots of the LCM are exactly the roots we wish to remove. Since each component has integer coefficients, the LCM also has integer coefficients. Since the LCM divides zn-1, the quotient must be a polynomial with integer coefficient, and the quotient is the polynomial above.

The roots of zn=1 all have radius 1, so they form a circle. The polynomial represents the points of the circle unique to n, so in a sense the polynomials form a partition of the circle. Therefore, the polynomial above is the n-th cyclotomic polynomial. (cyclo- = circle; tom- = to cut)

Definition 1

The n-th cyclotomic polynomial, denoted , is the unique polynomial with integer coefficients that divide xn-1 but not xk-1 for k<n.

Definition 2

The cyclotomic polynomials are a set of polynomials, one for each positive integer, such that:

where k | n means k divides n.

Definition 3

The n-th cyclotomic polynomial is the polynomial xn-1 divided by the LCM of the polynomials in the form xk-1 where k divides n and k<n.

Examples

Φ1(x) = x - 1
Φ2(x) = x + 1
Φ3(x) = x2 + x + 1
Φ30(x) = x8 + x7 - x5 - x4 - x3 + x + 1
Φ105(x) = x48 + x47 + x46 - x43 - x42 - 2x41 - x40 - x39 + x36 + x35 + x34 + x33 + x32 + x31 - x28 - x26 - x24 - x22 - x20 + x17 + x16 + x15 + x14 + x13 + x12 - x9 - x8 - 2x7 - x6 - x5 + x2 + x + 1

Task

Given a positive integer n, return the n-th cyclotomic polynomial as defined above, in a reasonable format (i.e. e.g. list of coefficients is allowed).

Rules

You may return floating point/complex numbers as long as they round to the correct value.

Scoring

This is code-golf. Shortest answer in bytes wins.

References

Wolfram MathWorld
Wikipedia

Haskell, 120 bytes

import Data.Complex
p%a=zipWith(\x y->x-a*y)(p++[0])$0:p
f n=foldl(%)[1][cis(2*pi/fromInteger n)^^k|k<-[1..n],gcd n k<2]

Try it online!

Gives a list of complex floats that has entries like 1.0000000000000078 :+ 3.314015728506092e-14 due to float inacurracy. A direct method of multiplying out to recover the polynomial from its roots.

The fromInteger is a big concession to Haskell's type system. There's got to be a better way. Suggestions are welcome. Dealing with roots of unity symbolically might also work.

Haskell, 127 bytes

(h:t)%q|all(==0)t=[]|1>0=h:zipWith(\x y->x-h*y)t q%q
f n=foldl(%)(1:(0<$[2..n])++[-1])[tail$f k++[0,0..]|k<-[1..n-1],mod n k<1]

Try it online!

No imports.

Uses the formula

Computes Φ_n(x) by dividing the LHS by each of the other terms in the RHS.

The operator % does division on polynomials, relying on the remainder being zero. The divisor is assumed to be monic, and is given without the leading 1, and also with infinite trailing zeroes to avoid truncating when doing zipWith.


Print largest integer you can with the fewest characters Find a way to output a large integer with few characters. Solutions will be scored based on the magnitude of the number and shortness of code.

EDIT: Let's impose a time limit of a minute on sensible hardware, where sensible is a PC you can buy off the shelves.

JavaScript (10)

alert(1/0)

Prints "Infinity", did I win? :)