text:
What's my IP Address?
I'm surprised this hasn't come up in a challenge yet.
Output the IP address of the machine you're running on. You are required to output both the local and external IP addresses.
Local IP address, ie along the default format of 192.168.x.x
Public IP address can be verified by using google https://www.google.co.uk/search?source=hp&q=whats+my+ip
Output can be in any format. IPv4 or IPv6 or any mix of each is allowed, however they must be the only output. Code can be a full program or a function.
code-golf rules apply so shortest code wins.
Standard Loopholes are forbidden.
EDIT:
As per @Peter Taylor's comment, in the case where multiple of either type of address are present, you can choose to either output the first one, or as many as you can access. So long as at least one local and one public are present.

I think the 0/1 thing adds in unnecessary fluff to the challenge.

otherwise i thought it'd be too simple...

I agree there isn't much interest left in golfing an if(x){X}else{Y}, might as well ask to output both informations without input. As always, using the sandbox is advised.

@Xynos It's not recommended to add fluff just to make the challenge harder. The difficulty of a challenge should come from the challenge itself, e.g. the 0/1 format isn't necessary and it really doesn't give a lot of golfing opportunities.

I'll change the challenge to output both as per @Aarons suggestion then :)

What is any format? Can the output contain garbage (like HTML tags etc.)? Can I output one in IPv6 and the other IPv4?

Ill accept one in either format v4 or v6 but other garbage is not allowed

This is underspecified. In particular, it doesn't clearly address cases where there are multiple local IP addresses and/or multiple public IP addresses. Furthermore, there's no reliable way of telling whether I have multiple public IP addresses, and if so what they are.

What if the host doesn't have any RFC 1918 addresses?  It looks like there's no reliable answer to this, except on machines that have at least one private network.

Machines don't have IP addresses. Network interfaces do. Fail.

... and even one network interface can have multiple IP addresses.

The external IP address part is solved with a standard loophole by most answers.

What if we have multiple local Ip addresses? Output any one of them? Output all of them? Output a very specific one?

Actually, I don't see how you could solve half of this without fetching from an external source, which is one of the standard loopholes you have expressly forbidden.

@TobySpeight, if you're not behind NAT, then your local and external addresses are the same.  This challenge is basically "output the address according to your network interface, and your address according to a remote server".

Surely it's 127.0.0.1...

Currently my answer is the accepted one even though there are shorter solutions, you should update the accepted answer..

Bash + curl + iproute2, 54 50 49 48 33 bytes
ip r g 1|awk '$0=$7'
curl eth0.me

Thanks @DomHastings for golfing off 1 byte!
Thanks @Sisyphus for coming up with a shorter URL!
Thanks @zeppelin for golfing off 9 bytes!

@DomHastings Your last golf attempts returns some garbage along with the ip address, at least on Ubuntu 16.04.3 LTS

@Ferrybig Yeah, the 1/0 part outputs an error to STDERR, but that is ignored by default, if you get different output for ip route though, that could just be the version I was running on my machine. Shame!

The first line prints 1000 for me...
ip route get 1 output: https://ptpb.pw/pixx

When I run that code I get this output: RTNETLINK answers: Network is unreachable

You can use ip r g  1 to save some bytes (at least with a Linux version of ip).

You can also optimize your AWK expression a bit: awk 'NR<2&&$0=$7'

@kasperd In that case probably all of the answers here fail.

If you mention curl in the header, you should mention ip as well. Also, what are the thingies over the numbers supposed to look like? I get dotted rectangles on my desktop, and barely noticeable tildes (crossed out 49 looks like regular 49) on my phone. A regular <s> would be more portable.

This bash answer is only 24 bytes.

@DanDascalescu: But it doesn't work.. Though this answer is shorter and works!

Bash 37 31 27 bytes
This is inspired by the answer by Bruce Forte. That answer only works with IPv4 which means it doesn't work for me. I have rewritten it into a version that (only) works with IPv6:
ip r g b::|awk '$0=$9" "$9'

This is tested on Ubuntu 14.04.5 connected through PPPoE and since IPv6 is designed to be used without any NAT it will output the same IP address twice.
-6 bytes thanks to zeppelin,
-2 bytes thanks to Ferrybig,
-2 bytes thanks to Markasoftware.

On my Ubuntu 16.04.3 LTS, I had to change '{print$11,$11}' to '{print$9,$9}' to make the command work, your command returned 1024 2 times, Your command works on my Ubuntu 16.04.2 machine

@Ferrybig Probably depends on network configuration then. I tested this on a network where addresses are auto-configured from router advertisements.

For machines where the ip address is manually configured (static), ip route doesn't output the proto ra part, you could use this as a feature to golf your answer further

@Ferrybig At the moment I am pondering whether I can find a way to make it work in both cases without the size blowing up. Btw. on my 16.04.3 machine which received its configuration using router advertisements it says proto static not proto ra, though that difference doesn't matter to this code.

To golf it a bit, use awk '$0=$9" "$9' instead of {print$11,$11}. Many systems (including my Arch one) use the 9th word, so it's shorter than 11, and also using this syntax is smaller than print$9,$9

@Markasoftware Just tested my Pi and found there I had to use $7. So I have seen 7, 9, and 11 across the various devices on my network.

AutoIt, 56 53 bytes
#include<Inet.au3>
ConsoleWrite(@IPAddress1&_GetIP())

@IPAddress1 is a macro that returns

IP address of first network adapter

_GetIP() returns

the public IP address.

-3 bytes thanks to @mınxomaτ

Neat, a fellow AutoIt (not IT) -er. You can delete the spaces in this code.

@mınxomaτ Thanks for the correction :)

Mathematica, 17 bytes
Mathematica has a builtin for everything
$MachineAddresses

As described in the documentation, this builtin command lists all IP addresses (both local and external) associated with your device.

The documentation doesn't say anything about external addresses.

If this command also lists the ipv6 address, then you can say the ipv6 address is the expected result

This produces a list of several IP addresses for me, but none of them seem to be my external address; I may not be interpreting things correctly, though. I can get my external IP address from something like WolframAlpha["ip address", {{"IPAddress:InternetData", 1}, "ComputableData"}][[1,2]] but I don't know how to get at that more directly.

@MarkS. That is odd; I get my external IP address when I run the command (the last entry seems to be it). This command won't work on Wolfram Sandbox, though. Perhaps this is a bug; what OS and Mathematica version are you using?

@JungHwanMin 11.1.1.0 Student Edition gives me 6 things that I assume are IPv6, then 192.168.0.104, and three addresses beginning with 169.254. But my external address begins with 69.

C#, 196 194 188 163 bytes
namespace System.Net.Sockets{using Linq;_=>Dns.GetHostEntry("").AddressList.First(i=>(int)i.AddressFamily==2)+" "+new WebClient().DownloadString("http://eth0.me")}

Saved 2 bytes thanks to @Xynos.
Saved 25 bytes thanks to @Nick.
Full/Formatted Version:
namespace System.Net.Sockets
{
    using Linq;

    class P
    {
        static void Main()
        {
            Func<object, string> f = _ =>
                Dns.GetHostEntry(Dns.GetHostName())
                    .AddressList
                    .First(i => (int)i.AddressFamily == 2) + " " + new WebClient().DownloadString("http://eth0.me");

            Console.WriteLine(f(null));

            Console.ReadLine();
        }
    }
}

cant you save two bytes by removing the whitespace around the == ?

@Xynos Of course, didn't realise I hadn't removed it.

The golfed version does not compile and is not a standalone function.  It doesn't seem fair to mix a standalone function with the shortcut of using the Sockets namespace, so I'd suggest picking one option and going with it.  That said, you can save some bytes by casting i.AddressFamily to int instead of casting 2 to AddressFamily, and you can replace Dns.GetHostName() with the empty string.

@Nick I will try that when I get a chance and the namespace trick is fairly common for C#. If you think it shouldn't be allowed you can post on meta about it but at the moment it is fair game and a neat trick in shortening usings.

PowerShell v4+, 40 36 bytes
NetIPAddress|% IPA*
iwr eth0.me|% C*

(Only works on Server 2012 R2 or above, or Windows 8.1 or above. Doesn't work on TIO.)
Does exactly what it says on the tin. Gets the local network IP addresses and selects just the IPAddress portion thereof (e.g., filters out the subnet mask, the gateway, etc.).
The second is a Invoke-WebRequest to http://eth0.me which simply gets the Content thereof; i.e., just the public IP address.

Ungolfed version:
(Get-NetIPAddress).IPAddress
(Invoke-WebRequest eth0.me).content

An anonymous user suggests removing Get-

@StepHen Indeed. Works great.

Go, MacOS only, 10 bytes
In macOS this killswitch could be used, it can print current private active IP and public IP:
$ killswitch
Interface  MAC address         IP
en1        bc:34:36:d2:81:ba   192.168.2.10

Public IP address: 179.43.176.99

No VPN interface found, verify VPN is connected

This is not a built-in tool but tries to simplify the process of finding the proper IP's.
The output could get by using commands like:
$ route get 0.0.0.0

$ ifconfig | pcregrep -M -o '^[^\t:]+:([^\n]|\n\t)*status: active'

$ networksetup -listnetworkserviceorder

$ scutil --dns

Public IP:
$ dig o-o.myaddr.l.google.com @ns.google.com txt +short

Hi! Welcome to PPCG! This question is tagged [tag:code-golf]. Could you provide golfed code with a language and a byte count?

#Unix Shell + stunclient, 40 bytes
stunclient stun.vo.lu|cut -d: -f2|sed 1d

Makes use of a STUN protocol:

Session Traversal Utilities for NAT (STUN) is a protocol that serves
as a tool for other protocols in dealing with Network Address
Translator (NAT) traversal.  It can be used by an endpoint to
determine the IP address and port allocated to it by a NAT

The STUN server name is from the Public STUN server list.
The output format is:
 LOCAL IPV4 ADDRESS
 PUBLIC IPV4 ADDRESS

Note that both lines will be indented with a single space, but I believe this does not break the output rules as written.
Sample output:
  192.168.1.100
  209.85.233.147

curl (bash one-liner): 27 bytes
curl -w%{local_ip} eth0.me

The result is printed on stdout and looks like this:
1.2.3.4
192.168.0.10
# no trailing newline, use "curl -w%{local_ip}\\n eth0.me" for it

curl should be at least of version 7.29.0 (from Feb 6, 2013).
The answer is based on https://codegolf.stackexchange.com/a/139538/66016.

Python 3, 124 133 bytes
from urllib2 import urlopen
import socket
a=urlopen('http://eth0.me').read()
b=socket.gethostbyname(socket.gethostname())
print a,b

Don't you also need to print a,b? Interestingly, this does output two IPs on my system (Win7), but neither one of them is my actual local IP address. b is actually the IP of a virtual adapter and not my Local Area Connection.

Arguably though, that is still a local Ip address. I left a comment on the Question to ask for clarification on that.

@Octopus you're right about printing, updated

In a suggested edit, @David suggested this: 113 bytes (Review here)

You can print without () in Python 3??

PowerShell v3+ (alternative answer for windows 7+)
((ipconfig) -match "v4").split(":")[1]
Invoke-RestMethod eth0.me

Welcome to PPCG!

You can remove the spaces surrounding -match to save a couple bytes.

Bash + Awk + Curl, 43 bytes
using only built in tools for Mac and Linux
ifconfig|awk '/bro/{print $2}';curl eth0.me

*bash you mean .

bash + awk +  curl

i edited the question to say bash since it works on my linux laptop not just macos

thx, I improved since bash is a shell per se (should work on tcsh, sh and any other shell), you need to have ifconfig, awk and curl also

This isn't "MacOS/Linux", it's Bash. Just mark it as such.

Your code produce literally no output when I run it on my machine.

grep "bro"|awk '{print $2}' → awk '/bro/{print$2}'

This assumes that the interface is eth0, which is not always the case.

@manatwork thx, nice job!

@Liam eth0.me is a url which show yours external IP, has nothing to do with the interface name

Oh good to know, I apologize

Only shows my external IP on Ubuntu.

Node.js (JavaScript) 224 223 194 175 173 130 bytes
r=require,l=console.log,r('dns').lookup(r('os').hostname(),(a,b)=>l(b));r('http').get('http://eth0.me',a=>a.on('data',c=>l(c+"")))

Ungolfed version:
require('dns').lookup(require('os').hostname(), (err, loc, fam) => console.log(loc));
require('http').get('http://eth0.me', res => {
    res.on('data', chunk => console.log(chunk + ""));
});

Saved 1 byte (due to unnecessary semicolon).
Saved 29 bytes thanks to @AndrewLi (used arrow functions for shorter code).
Saved 19 bytes thanks to @MiniGod (used .get() instead of .request() - .end(); removed).
Saved 2 bytes thanks to @Zacharý (parentheses not needed around a lone parameter of an arrow function).
Saved 43 bytes thanks to @Birjolaxew (stored require and console.log in single-letter variables, passed url directly to require('http').get, logged output directly from data event).

Can't you use arrow functions for shorter code?

@AndrewLi Great suggestion, thanks. :)

You can use .get() instead of .request(). Then you also don't need the .end();.

You can also chain the .on() calls.

You don't need parens around a lone parameter of an arrow function. ((a)=> => a=>), IIRC.

MiniGod and @Zacharý, updated, thanks :)

An FYI: The Node REPL automatically imports os, http and dns. I'm not sure Node.js also includes the REPL in the scope of PPCG, but that could get rid of your require calls.

@AndrewLi Hmm, the problem is that when the code is run in the REPL, it prints out extra info (e.g. the request information), which is prohibited in the question. I could add extra code to hide this output, but it might counteract the reduction of bytes which result from leaving out the require calls, so I'll leave it for now. Thanks for the suggestion anyway.

You can save quite a few bytes by storing require and console.log in single-letter variables. You can also pass the string directly to require('http').get (if you prepend the protocol), saving another few bytes. You could also log the output in the data event, but I'm not sure if that's consistent. Shortest variant I could come up with

@Birjolaxew That's great, thanks :) Good point about the data event - it seems to work for now, but if it doesn't in the future, I'll revert it.

Much shorter version, if it's OK to use external "What is my IP address" services.

Python 2.7.13 128 bytes
print __import__("urllib").urlopen("http://eth0.me").read(),__import__("socket").gethostbyname(__import__("socket").getfqdn())

R, 142, 140, 137 bytes
library(magrittr);system("ipconfig",int=T)%>%regmatches(.,regexpr("v4.+",.))%>%{a=nchar(.);substr(.,a-14,a)};readLines("http://eth0.me")

Tested on win10 and R (3.4.1).
Thanks for @Bruce-Forte for short URL.
Ungolfed version:
library(magrittr)
system("ipconfig",int=T) %>%
     regmatches(.,regexpr("v4.+",.)) %>%
      {a <- nchar(.)
       substr(., a - 14, a)}
readLines("http://eth0.me")

Down to 120 bytes Try it online!

@BLT nice solution. You can save 3 bytes, by replacing a <- nchar(x) with a=nchar(x)

@AndruisZ thanks, but it's really your solution -- I just de-magrittr'd it.

Bash + Curl, 24 bytes
hostname -i;curl eth0.me

This doesn't work.. From the man page: "This option enumerates all configured addresses on all network interfaces. [...] Do not make any assumptions about the order of the output."

Doesn't -I (capital) have a different use than -i (lowercase). The bit you quoted was from the -I section.

True, sorry about that. But even worse it says "Avoid using this option", either way this doesn't work (at least on my machines)..

Right, admittedly I did not read the full documentation before posting. Oddly enough it seems to work fine on a few of my machines. But this inconsistency would make this solution unreliable at best.

Windows' Batch File, 116 bytes
@for /f "tokens=1-2 delims=:" %%a in ('ipconfig^|find "v4"')do @echo%%b
@powershell -Command "(iwr eth0.me).content"

The first line iterates through the results of running ipconfig and gets your local IPv4 address.
For the public IP part, I had to steal a bit from the marvelous Powershell answer because, as far as I know, there is no way to get the machine's public IP using solely batch scripting.
We start with an @ sign, to suppress echoing the prompt (C:\...\path>), then run the Powershell command Invoke-WebRequest (with its alias, iwr) and extract the content part of that.
I experimented with not using (...).content and, instead, only running the command and extracting the actual information from the complete output, using batch. But that proved to be way longer than this solution, so I kept it.
Tested on Windows 10.0.15063.

VBA, 58 Bytes
Whoops, does not handle local address - fix in progress

Note:
  Uses reference to
Microsoft Internet Controls

Anonymous VBE immediate window function that takes no input and outputs the user's IP address via an Internet Explorer window
Set i=New InternetExplorer:i.Visible=1:i.Navigate"eth0.me"

MS-SQL, 59 bytes
SELECT TOP 1 local_net_address
FROM sys.dm_exec_connections

Returns the client-facing IP address of the SQL instance executing the query.

Bash — 29 bytes (linux)
curl ipinfo.io/ip
hostname -i

Python 3, 97 bytes
from socket import*
from requests import*
gethostbyname(gethostname()),get('http://eth0.me').text

returns tuple with ('LOCAL_IP', 'PUBLIC_IP'), as apparently
x = 2,3
type(x)
>>> tuple

Python 3, 103 bytes
from socket import*
from requests import*
gethostbyname(gethostname()),get('http://api.ipify.org').text

ditto, read below.

Python 3, 107 bytes
First solution
from socket import*
from requests import*
gethostbyname(gethostname())+" "+get('http://api.ipify.org').text

The +" "+ part is for joining strings together.
If you leave just the + sign, 103 bytes are possible, but would yield the strings without spaces which could lead to results like this "5.5.5.111222.222.222.222" and they should still be readable, as there are only 3 digits at max in every ip part.
But there are edge cases like "5.5.5.11111.222.222.222" where it would be impossible to distinguish the local vs public part.
Other possible savings are in the public ip grabber tool. I used this site, as it was the first thing I found on the Internet and it returns html with just text in it, which is super nice. I saw other people using http://eth0.me, but it doesn't load for me on my machine and my antivirus has it blacklisted, thus Python raises a ConnectionError. It loads through Tor though, so I don't know whether I should use it.
Python 3, 101 bytes
from socket import*
from requests import*
gethostbyname(gethostname())+" "+get('http://eth0.me').text


text:
It's a Bit of a Stretch․․․
Input:
We take two inputs:

An input b with two distinct values: Left and Right.†
And a positive integer n.

Output:
Based on the Left/Right input, we output either of the following two sequences in the range of 1-n (in the sequences below the first 125 items are displayed):
Left:
1, 6, 7, 56, 57, 62, 63, 960, 961, 966, 967, 1016, 1017, 1022, 1023, 31744, 31745, 31750, 31751, 31800, 31801, 31806, 31807, 32704, 32705, 32710, 32711, 32760, 32761, 32766, 32767, 2064384, 2064385, 2064390, 2064391, 2064440, 2064441, 2064446, 2064447, 2065344, 2065345, 2065350, 2065351, 2065400, 2065401, 2065406, 2065407, 2096128, 2096129, 2096134, 2096135, 2096184, 2096185, 2096190, 2096191, 2097088, 2097089, 2097094, 2097095, 2097144, 2097145, 2097150, 2097151, 266338304, 266338305, 266338310, 266338311, 266338360, 266338361, 266338366, 266338367, 266339264, 266339265, 266339270, 266339271, 266339320, 266339321, 266339326, 266339327, 266370048, 266370049, 266370054, 266370055, 266370104, 266370105, 266370110, 266370111, 266371008, 266371009, 266371014, 266371015, 266371064, 266371065, 266371070, 266371071, 268402688, 268402689, 268402694, 268402695, 268402744, 268402745, 268402750, 268402751, 268403648, 268403649, 268403654, 268403655, 268403704, 268403705, 268403710, 268403711, 268434432, 268434433, 268434438, 268434439, 268434488, 268434489, 268434494, 268434495, 268435392, 268435393, 268435398, 268435399, 268435448, 268435449

Right:
1, 4, 7, 32, 39, 56, 63, 512, 527, 624, 639, 896, 911, 1008, 1023, 16384, 16415, 16864, 16895, 19968, 19999, 20448, 20479, 28672, 28703, 29152, 29183, 32256, 32287, 32736, 32767, 1048576, 1048639, 1050560, 1050623, 1079296, 1079359, 1081280, 1081343, 1277952, 1278015, 1279936, 1279999, 1308672, 1308735, 1310656, 1310719, 1835008, 1835071, 1836992, 1837055, 1865728, 1865791, 1867712, 1867775, 2064384, 2064447, 2066368, 2066431, 2095104, 2095167, 2097088, 2097151, 134217728, 134217855, 134225792, 134225919, 134471680, 134471807, 134479744, 134479871, 138149888, 138150015, 138157952, 138158079, 138403840, 138403967, 138411904, 138412031, 163577856, 163577983, 163585920, 163586047, 163831808, 163831935, 163839872, 163839999, 167510016, 167510143, 167518080, 167518207, 167763968, 167764095, 167772032, 167772159, 234881024, 234881151, 234889088, 234889215, 235134976, 235135103, 235143040, 235143167, 238813184, 238813311, 238821248, 238821375, 239067136, 239067263, 239075200, 239075327, 264241152, 264241279, 264249216, 264249343, 264495104, 264495231, 264503168, 264503295, 268173312, 268173439, 268181376, 268181503, 268427264, 268427391

How are these sequences generated you ask?
A default sequence from 1 through n=10 would be:
As integer:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10

As binary:
1 10 11 100 101 110 111 1000 1001 1010

When we stretch left, the binary will become this:
1, 110, 111, 111000, 111001, 111110, 111111, 1111000000, 1111000001, 1111000110

Why? The last bit is used once; the single-last is used twice; the second-last is used three times; etc.
So `1010` will become (spaces added as clarification): `1111 000 11 0`

And these new left-stretched binary strings are converted back to integers:
1, 6, 7, 56, 57, 62, 63, 960, 961, 966

As for stretched right, the first bit is used once; second twice; third three times; etc. Like this:
As binary:
1, 100, 111, 100000, 100111, 111000, 111111, 1000000000, 1000001111, 1001110000

As integer:
1, 4, 7, 32, 39, 56, 63, 512, 527, 624

Challenge rules:

† You can take any two distinct values, but state which one you use. So it can be 1/0, true/false, null/undefined, "left"/"right", etc.
n is always larger than 0.
You should support a maximum output of at least your language's default integer (which is 32-bit for most languages).
Output format is flexible. Can be printed or returned as array/list. Can be with a space, comma, pipe, and alike as delimiter. Your call. (Again, please state what you've used.)

General rules:

This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
Default Loopholes are forbidden.
If possible, please add a link with a test for your code.
Also, please add an explanation if necessary.

Would you consider accepting bitwise-based answers that can only support n < 128, so that the results fit in 32-bit integers?

@Arnauld Been doubting about it, but since you asked, why not. Will change the rules for 1000 max to what fits for your language's integer.

@KevinCruijssen Would still recommend limiting that to at least 16 bits - there's at least one language out there that supports only a single bit as a data type.

Jelly, 9 bytes
BmxJ$mḄð€

Try it online!
-1 for left, 1 for right.

Python 2, 102 96 bytes
lambda d,n:[int(''.join(c*-~i for i,c in enumerate(bin(x+1)[2:][::d]))[::d],2)for x in range(n)]

-1 for left, 1 for right
Try it online!

05AB1E, 14 13 bytes
Saved 1 byte thanks to Erik the Outgolfer
LbεIiRƶRëƶ}JC

1 for left.
0 (or anything else) for right.
Try it online!
Explanation
L                # push range [1 ... first_input]
 b               # convert to binary
  ε              # apply to each
   Ii            # if second_input is true
     RƶR         # reverse, multiply each element with its 1-based index and reverse again
        ëƶ       # else, multiply each element with its 1-based index
          }      # end if
           J     # join
            C    # convert to base-10

You can use ε for -1: LbεIiRƶRëƶ}JC

@EriktheOutgolfer: Nice idea using ë. Gets around the issue of if in an apply in this case :)

Japt, 19 18 17 bytes
0 for "left", 1 for "right". (It can actually take any falsey or truthy values in place of those 2.)
õÈ¤ËpV©EÄªEnFlÃn2

Test it

Explanation
Implicit input of integers U & V.
õ

Create an array of integers from 1 to U, inclusive.
È

Pass each through a function.
¤

Convert the current integer to a binary string
Ë           Ã

Map over the string, passing each character through a function, where E is the current index and F is the full string.
p

Repeat the current character
V©  ª

© is logical AND (&&) and ª is logical OR ||, so here we're checking if V is truthy (non-zero) or not.
YÄ

If V is truthy then X gets repeated Y+1 times.
YnZl

If V is falsey then X gets repeated Y subtracted from (n) the length (l) of Z times.
n2

Convert back to a base 10 integer.
Implicitly output resulting array.

I got down to 16 before realizing it was "first n items" rather than "nth item", so this isn't that bad :P

@ETHproductions: you weren't the only one to make that mistake ;)

Husk, 13 bytes
mȯḋṠṘo?ḣṫ⁰Lḋḣ

That's a lot of dotted letters...
Takes first b (0 for left and 1 for right), then n.
Try it online!
Explanation
mȯḋṠṘo?ḣṫ⁰Lḋḣ  Inputs b=1 and n=5 (implicit).
            ḣ  Range to n: [1,2,3,4,5]
mȯ             Map function over the range:
                 Argument: number k=5
           ḋ     Binary digits: [1,0,1]
   ṠṘ            Repeat each digit with respect to the list
     o    L      obtained by applying to the length (3) the function
      ?  ⁰       if b is truthy
       ḣ         then increasing range: [1,2,3]
        ṫ        else decreasing range: [3,2,1].
                 We get [1,0,0,1,1,1].
  ḋ              Convert back to integer: 39
               Final result [1,4,7,32,39], implicitly print.

You could probably choose to take as b directly ḣ or ṫ, saving you three bytes :)

@Leo Hmm, that's kind of a slippery slope. I could also take one of two versions of the whole program as b and have my solution be just I...

Gaia, 15 bytes
⟪¤bw¦¤;ċ%×†_b⟫¦

Uses -1 for left and 1 for right.
Try it online!
Explanation
⟪¤bw¦¤;ċ%×†_b⟫¦  Map this block over the range 1..n, with direction as an extra parameter:
 ¤                Swap, bring current number to the top
  b               List of binary digits
   w¦             Wrap each in a list
     ¤            Bring direction to the top
      ;ċ          Push the range 1..len(binary digts)
        %         Select every direction-th element of it (-1 reverses, 1 does nothing)
         ×†       Element-wise repetition
           _      Flatten
            b     Convert from binary to decimal

Proton, 79 bytes
n=>d=>[int(''.join(b[x]*[l-x,x-1][d]for x:2..(l=len(b=bin(i)))),2)for i:1..n+1]

0 is left, 1 is right.
Try it online!
Ungolfed
f=n=>d=>                        # Curried function
[                               # Collect the results in a list
 int(                           # Convert from a binary string to an int:
  ''.join(                       # Join together
   b[x]                           # Each character of the binary string of n
   *[l-x,x-1][d]                  # Repeated by its index or its index from the end, depending on d
   for x:2..(l=len(b=bin(i))))
 ,2)
 for i:1..n+1                   # Do this for everything from 1 to n inclusive
]

C# (.NET Core), 192 187 + 23 bytes
-5 bytes thanks to TheLethalCoder
b=>n=>new int[n].Select((_,a)=>{var g=Convert.ToString(a+1,2);return(long)g.Reverse().SelectMany((x,i)=>Enumerable.Repeat(x,b?i+1:g.Length-i)).Select((x,i)=>x>48?Math.Pow(2,i):0).Sum();})

Byte count also includes:
namespace System.Linq{}

Try it online!
Input: left is true, right is false
Explanation:
b => n =>                                   // Take two inputs (bool and int)
    new int[n].Select((_, a) => {           // Create new collection the size of n
        var g = Convert.ToString(a + 1, 2); // Take every number in sequence 1..n and convert to base 2 (in a string)
        return (long)g.Reverse()            // Reverse the bits
               .SelectMany((x, i) =>        // Replace every bit with a collection of its repeats, then flatten the result
                   Enumerable.Repeat(x, b ? i + 1 : g.Length - i))
               .Select((x, i) => x > 48 ? Math.Pow(2, i) : 0)
               .Sum();                      // Replace every bit with a corresponding power of 2, then sum
    })

https://tio.run/##bVHva9swEP3uv@KWD41EXZGUfRh17TJKO8YSKMugH0oZinuxBYqUSXJ@UPK3Zye7TWO2w5jT3dO7e0@lvyitw0PjlalgtvMBl@LWao1lUNZ48Q0NOlVmiZFL9CtZ4jtqosyf5DUBilJL7@Frm3eVGD7IoEpYW/UCU6kM48fWByjGfWPK67m1Ou1SZUIK3@9Ms0Qn5xqvtTVVURSwgPwwzwtDH26AYE/mWcwwLsvY71TyvHhdSwdVfmvNGl0Qv@wsOJLGZHrJM4ehcYZFOl6Jn0gQj4y/UUyl2TG2TRXRfAwn2AploPr8Rp2PryoxQVOF@kJxfpzdXdoWn7/cTGWoxYPdsEuqXY0I0ywZz/b8cCo5S3oO@HZJUrRqQtbrbGqlERhrW5ADCfO23Uq@0AvQ9hw@5WAareHsrGOIhcGA93j6jseIRvmVVpG1vSZm8cSG6TCFIQy5eKzRIdtCXsD2jZMMnSgfSNA/fAsWn1A8yOhpS/w0euacNg@94piKRxpxb92dLOtuyru4R6dCHHwOAxjw/8zqATsb@qB9399T137g7hS9T7r//hBcgzAeJQupfUz@Ag

185 + 23 ^ (was too long in one comment)

@TheLethalCoder Thank you! Unfortunately though, it's 187 since we need to add 1 to the index since it starts at 0, and the sequence starts at 1.

Isn't using System.Linq; shorter than namespace System.Linq{}, or am I missing something here? Long time ago I programmed in .NET tbh..

@KevinCruijssen this uses Math and Convert both of which are in the System namespace, so going for namespace System.Linq is the shortest - it allows for using both System and System.Linq classes.

Is the Reverse() necessary? If you remove it can't you just flip the ternary?

@TheLethalCoder then the Math.Pow(2,i) stops working correctly, and to work again you would either need to get the length after SelectMany or add another ternary next to i, both of which are longer. Unless I am missing another possibility.

Ah I missed that part then!

JavaScript (ES6), 113 bytes
Oh, this is just far too long! This is what happens when you spend the day writing "real" JavaScript, kiddies; you forget how to golf properly!
Uses any truthy or falsey values for b, with false being "left" and true being "right".
n=>b=>[...Array(n)].map(_=>eval("0b"+[...s=(++e).toString(2)].map((x,y)=>x.repeat(b?++y:s.length-y)).join``),e=0)

Try it

o.innerText=(f=
n=>b=>[...Array(n)].map(_=>eval("0b"+[...s=(++e).toString(2)].map((x,y)=>x.repeat(b?++y:s.length-y)).join``),e=0)
)(i.value=10)(j.value=1);oninput=_=>o.innerText=f(+i.value)(+j.value)
label,input{font-family:sans-serif;font-size:14px;height:20px;line-height:20px;vertical-align:middle}input{margin:0 5px 0 0;width:100px;}
<label for=i>Size: </label><input id=i type=number><label for=j>Direction: </label><input id=j min=0 max=1 type=number><pre id=o>

JavaScript (ES6), 131 bytes
This is significantly longer than Shaggy's answer, but I wanted to try a purely bitwise approach.
Due to the 32-bit limit of JS bitwise operations, this works only for n < 128.
Takes input in currying syntax (n)(r), where r is falsy for left / truthy for right.
n=>r=>[...Array(n)].map((_,n)=>(z=n=>31-Math.clz32(n),g=n=>n&&(x=z(b=n&-n),r?2<<z(n)-x:b*2)-1<<x*(r?2*z(n)+3-x:x+1)/2|g(n^b))(n+1))

Formatted and commented
n => r => [...Array(n)]       // given n and r
  .map((_, n) => (            // for each n in [0 .. n - 1]
    z = n =>                  //   z = helper function returning the
      31 - Math.clz32(n),     //       0-based position of the highest bit set
    g = n =>                  //   g = recursive function:
      n && (                  //     if n is not equal to 0:
        x = z(b = n & -n),    //       b = bitmask of lowest bit set / x = position of b
        r ?                   //       if direction = right:
          2 << z(n) - x       //         use 2 << z(n) - x
        :                     //       else:
          b * 2               //         use b * 2
      ) - 1                   //       get bitmask by subtracting 1
      << x * (                //       left-shift it by x multiplied by:
        r ?                   //         if direction = right:
          2 * z(n) + 3 - x    //           2 * z(n) + 3 - x
        :                     //         else:
          x + 1               //           x + 1
      ) / 2                   //       and divided by 2
      | g(n ^ b)              //     recursive call with n XOR b
    )(n + 1)                  //   initial call to g() with n + 1
  )                           // end of map()

Demo

let f =

n=>r=>[...Array(n)].map((_,n)=>(z=n=>31-Math.clz32(n),g=n=>n&&(x=z(b=n&-n),r?2<<z(n)-x:b*2)-1<<x*(r?2*z(n)+3-x:x+1)/2|g(n^b))(n+1))

console.log(JSON.stringify(f(10)(false)))
console.log(JSON.stringify(f(10)(true)))

OK, I feel a little better about the length of mine now, seeing as you went for a longer solution, rather than a shorter one.

"(pending on OP's approval)." Approved :) +1 from me.

Dyalog APL, 23 bytes
{2⊥b/⍨⌽⍣⍺⍳≢b←2⊥⍣¯1⊢⍵}¨⍳

left is 1 right is 0 (passed in as left argument of function)
⍳ is index generator
{...}¨ apply function in braces to each item on the right
b←2⊥⍣¯1⊢⍵ b is ⍵ encoded as binary (using the inverse of decode to get the minimum number of bits required to represent ⍵ in base 2)
⍳≢b generate indexes for vector b (≢b is length of b)
⌽⍣⍺ reverse ⍺ times (used conditionally here for left or right stretch)
b/⍨ b replicated by (replicates the bits as per the (reverse)index)
2⊥ decode from base 2
TryAPL online

Jelly, 11 bytes
B€xJṚ⁹¡$$€Ḅ

Try it online!
Argument #1: n
Argument #2: 1 for left, 0 for right.

Retina, 111 bytes
\d+
$*
1
$`1¶
+`(1+)\1
${1}0
01
1
.
$.%`$*R$&$.%'$*L
+s`(R?)(\d)(L?)(.*¶\1\3)$
$2$2$4
¶*[RL]

1
01
+`10
011
%`1

Try it online! Takes the number and either L or R as a suffix (or on a separate line). Explanation:
\d+
$*
1
$`1¶

Convert from decimal to unary and count from 1 to n.
+`(1+)\1
${1}0
01
1

Convert from unary to binary.
.
$.%`$*R$&$.%'$*L

Wrap each bit in R and L characters according to its position in the line.
+s`(R?)(\d)(L?)(.*¶\1\3)$
$2$2$4

Replace the relevant R or L characters with the appropriate adjacent digit.
¶*[RL]

1
01
+`10
011
%`1

Remove left-over characters and convert from binary to decimal.

Hi, you have to output all numbers from 1 to n. Not just the n'th number.

@KevinCruijssen Bah, there goes my sub-100 byte count...

Ruby, 98 bytes
->n,r{t=->a{r ?a:a.reverse};(1..n).map{|k|i=0;t[t[k.to_s(2).chars].map{|d|d*(i+=1)}].join.to_i 2}}

Is the space at the ternary a{r ?a:a.reverse} necessary?

Yes. Ruby methods can end with ?, r? would have been interpreted as a method name.

Ah ok, thanks for the explanation. Never programmed in Ruby, but it looked like a regular ternary-if I use in Java (or C#), hence my comment.

Java 8, 136 bytes
Lambda (curried) from Boolean to a consumer of Integer. The boolean parameter indicates whether to stretch left (values true, false). Output is printed to standard out, separated by newlines, with a trailing newline.
l->n->{for(int i=0,o,c,d,s=0;i++<n;System.out.println(o)){while(i>>s>0)s++;for(o=c=0;c++<s;)for(d=0;d++<(l?s-c+1:c);o|=i>>s-c&1)o<<=1;}}

Ungolfed lambda
l ->
    n -> {
        for (
            int i = 0, o, c, d, s = 0;
            i++ < n;
            System.out.println(o)
        ) {
            while (i >> s > 0)
                s++;
            for (o = c = 0; c++ < s; )
                for (
                    d = 0;
                    d++ < (l ? s - c + 1 : c);
                    o |= i >> s - c & 1
                )
                    o <<= 1;
        }
    }

Try It Online
Limits
Because they're accumulated in ints, outputs are limited to 31 bits. As a result, inputs are limited to 7 bits, so the maximum input the program supports is 127.
Explanation
This solution builds up each stretched number using bitwise operations. The outer loop iterates i over the numbers to be stretched, from 1 to n, and prints the stretched value after each iteration.
The inner while loop increments s to the number of bits in i, and the subsequent for iterates c over each bit position. Within that loop, d counts up to the number of times to repeat the current bit, which depends on input l. At each step, o is shifted left and the appropriate bit of i is masked off and OR'd in.

JavaScript (ES6), 130 127 bytes
3 bytes, thanks Kevin
I sure don't know enough ES6 for this site, but I tried! Loop through each number, and loop through each binary representation for that number, repeating each character however many times needed.
d=>n=>{i=0;while(i++<n){b=i.toString(2),s="",k=-1,l=b.length;while(++k<l)s+=b[k].repeat(d?k+1:l-k);console.log(parseInt(s,2))}}

f=d=>n=>{i=0;while(i++<n){b=i.toString(2),s="",k=-1,l=b.length;while(++k<l)s+=b[k].repeat(d?k+1:l-k);console.log(parseInt(s,2))}}
f(1)(10)
f(0)(10)

+1 from me. :) I think you can save a byte by using a currying input (d=>n=>), like the other two JS ES6 answers did. Also, I think you can save another 2 bytes by changing k=-1,l=b.length;while(++k<l)s+=b[k].repeat(d?k+1:l-k); to k=0,l=b.length;while(k<l)s+=b[k++].repeat(d?k:l+~k); (starting k=0 instead of -1, and the l-k-1 which is then required is shortened to l+~k). Also, are the parenthesis around the (i).toString(2) required?

The +~k seems like it should work, but I can't figure it out, keeps getting mad.  Thanks for the other tips!

Ah oops, l+~k is incorrect, since it isn't l-k-1 but l-k+1.. My bad. You can still golf one byte by starting k on zero though: k=0,l=b.length;while(k<l)s+=b[k++].repeat(d?k:l-k+1);.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Codegolf the sequence of distance-3 Hamming Codewords (A075926)
Codegolf the hamming code (with distance equals 3)!
The sequence looks like this: 0, 7, 25, 30, 42, 45, 51, 52, 75, 76, 82, 85, 97, 102, 120, 127, 385, 390, 408, 415, 427, 428, 434, 437, 458, 461, 467, 468, 480, 487, 505, 510, 642, 645, 667, 668, 680...
Task
Given n output the first n items in OEIS sequence A075926. Your program should work for any integer n where 0 <= n < 2^15. This sequence is known as the sequence of hamming codewords with distance being 3.
Rules:

Post both an ungolfed version of your code (or an explatation), and the golfed version, so that other people can understand how it works
If your program is written in a language with a compiler, specify which compiler and the compiler settings you used. Non-standard language features are allowed as long as it compiles with the compiler you specified, and the compiler was created prior to this question

Sequence Definition:
Given a distance 3 hamming codeword k, the variants of k are k itself, and any nonnegative integer that can be produced by flipping one of k's bits. The nth hamming codeword is the smallest nonnegative integer that doesn't share a variant with any preceeding distance 3 hamming codeword. Here are the first twenty d-3 hamming codewords in binary:

0,
  111,
  11001,
  11110,
  101010,
  101101,
  110011,
  110100,
  1001011,
  1001100,
  1010010,
  1010101,
  1100001,
  1100110,
  1111000,
  1111111,
  110000001,
  110000110,
  110011000,
  110011111,
  110101011

Ungolfed C++ code to produce sequence:
//Flips the nth bit
size_t flipN(size_t val, int bit) {
    return val ^ (1ull << bit);
}
void Hamming(size_t n) {
    int bits_to_use = 20;
    //This vector keeps track of which numbers are crossed off
    //As either hamming codewords or their variants.
    std::vector<bool> vect(1ull << bits_to_use, false);
    size_t pos = 0;
    size_t val = 0;
    while(val <= n) {
        //Checks to see that pos hasn't been crossed off
        if(vect[pos]) goto loopend;
        for(int i=0; i < bits_to_use; ++i)
        {
            if(vect[flipN(pos, i)]) goto loopend;
            //Checks to see that none of the variants
            //of pos have been crossed off
        }
        //If both those conditions are satisfied, output pos
        //As the next hamming codeword
        cout << pos << endl;
        //Here we cross off all the variants
        vect[pos] = true;
        for(int i=0; i < bits_to_use; ++i)
        {
            vect[flipN(pos, i)] = true;
        }
        ++val;
        loopend:
        ++pos;
    }
}

Related

No; they're very different sequences. The Hamming Numbers question is for https://oeis.org/A051037

I edited your post to clarify the task and I removed some rules that are already defaults (see meta). Rollback if you would like to.

Am I the only on that doesn't understand the task? :P

Given a number n, output the first n numbers of integer sequence A051037. It's a pretty standard problem to output an integer sequence; this particular integer sequence just requires an interesting algorithm.

Some Test cases would be helpful (although we have OEIS)

@JorgePerez You should be able to explain this algorithm and give examples

The sequence is defined neither here nor on the OEIS page.

"Post both an ungolfed version of your code, and the golfed version, so that other people can understand how it works" What does ungolfed Pyth or Jelly look like? I suggest you ask for an explanation instead. :)

Python 2, 98 97 bytes
-1 byte thanks to Mr. Xcoder

x=input()
l=[]
i=0
while len(l)<x:s=any(bin(i^n).count('1')<3for n in l);i+=s;l+=[i]*-~-s
print l

Try it online!
Straightforward implementation, using xor to calculate the hamming distance.
The inner loop is equivalent to :
if any(bin(i^n).count('1')<3 for n in l):
   i+=1
else:
   l.append(i)

(1-s) is -~-s (97 bytes)

Pyth, 34 21 19 bytes
Special Thanks to @LeakyNun for golfing off half of my solution!
u+Gf.Am<2sjxdT2G0QY

Try it here or Check out the test Suite.

Alternative, 19-byte solutions (Try one here):
u+Gf-Zm<2sjxdT2GZQY
u+Gf-0m<2sjxdT2G0QY
u+Gf.Am<2sjxdT2GZQY

21 bytes

19 bytes

@LeakyNun Thanks again, editing

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
The Third String
Given two strings, output a third string that is not equal to either of the two inputs, but has the same length (in characters) as either of the inputs. There is guaranteed to be at least one valid output.
Test Cases
Test cases are quoted to show they are strings. Outputs are one of many possible.
input, input -> output

"test", "test" -> "tttt"
"do", "don't" -> "dnut_"
"ye s", "yes" -> "fals"
"yes", "yes" -> "noo"
"maybe", "mayue" -> "false"
"false", "false" -> "truee"
"false", "true" -> "fatr"
"1", "" -> "0"
"", "t" -> "s"
"", "abcabc" -> "testst"
"abcdefghijklmnopqrstuvwxyz", "aaaaaaaaaaaaaaaaaaaaaaaaaa" -> "zbcdefghijklmnopqrstuvwxya"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" -> "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"

Rules

You may chose your input domain, but it must be composed of at least printable ASCII, and your output domain must be the same as your input domain.
The input lengths may be the same or different.
The output must be valid with probability 1; that is, you may generate random strings until one is valid (and theoretically you might infinite loop), but you can't just output a random string and hope it's valid. Note that this means you output does not need to be deterministic.
Automatic trailing newlines allowed, but they do not count towards the length of the output.
Due to questions regarding Memory Errors, it must work within 60 seconds up to input lengths of 6. An answer that works for that and theoretically works for longer strings is OK, but something that Memory Errors on modern computer for input length 4 is not valid.

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

Related, Sandbox

Can my code fail for MaxChar in input, but be able to output it?

@H.PWiz no. if it can be outputted, it has to be able to be inputted, otherwise you could just do MaxChar.repeat(s1.length)

That makes sense

This seems like another of an interesting new category of questions on this site that are easy for humans and hard for computers. Because computers aren't good at divergent thinking! It reminds me of the Spongebob episode where he's up all night trying to write an essay on what NOT to do at a stoplight.

Test case: abcdefghijklmnopqrstuvwxyz and aaaaaaaaaaaaaaaaaaaaaaaaaa. Mine failed for it

I understand the output domain can be a subset of the input domain, yes?

@LuisMendo yes.

Will the two inputs ever both be an empty string?

@kamoroso94 no, because there is guaranteed to be a valid output.

Nice question! I like it.

For "1", "" may we output ""?

@Quelklef No, that's not different from both inputs.

@ØrjanJohansen Of course. Thanks.

I suggest "", "1" should be added as a test case, since I just realized my answer fails for this even though it works for all the provided test cases

I'm pretty sure the point of @Slowloris 's request was to have the empty string as the first one.

Suggested test case: both input strings are longer than 256 characters.

@DLosc added, thanks

Haskell, 43 bytes
x!y=[s|s<-(<$max x y)<$>"abc",s/=x,s/=y]!!0

Takes the max (lexicographically later) string, which we know is nonempty; replaces all characters with one of "a", "b", and "c" using <$; and returns the first that is neither of the inputs. I think this is similar to Neil's Charcoal answer and/or geokavel's CJam answer.
(I've lurked for a while but this is my first time answering on this site; hi!)

Brainfuck, 97 bytes
+>+[-,[>>,]<<[<<]>]>>[>]<<<[<]>[<+>>[-<+<+>>][>]<[->+<]<[-]>>>++<[<]>[.>>]>[>>]]>[+[>]+[<]>[.>>]]

Run code online (note that "dynamic memory" must be selected in the bottom-right)
Awesome challenge! I thought it would be trivial but it ended up being really difficult. I keep coming back to it because I feel like there should be some elegant 20-or-so-byte BF solution. At this point, I'm pretty happy I (seemingly) got it to work at all in BF.
Input is taken as str1 + \0 + str2, where strings are consecutive non-zero 1-byte characters.
Returns (first str1 + first str2) or (first str1 + 1) or 2. This algorithm was thought up by the brilliant @ØrjanJohansen, (presumably) based on my (broken) original one.
Commented:
# Let (Kn) be the nth character of K
# Let (^) designate the pointer
# Let F be the first string inputted
# Let S be the second string inputted

+>+[-  # Twice do
,[>>,]  # Input string (characters separated by 1)
<<[<<]>  # Go to left of beginning of string
]>  # End on first character of second string
# If second string is null we will end one too far to the left
>[>]<<<[<]>  # If first string is null we will end there too
# We will use this to do flow control

[  # Only run if both strings were non null

# Tape:    S0 ' F0 ' S1 ' F1 ' S2 ' F2 ' etc
#          ^

<+>>  # Let F0* = F0 (plus) 1  (is 1 as of now; F0 will be added later)
[-<+<+>>] # Let A = S0 (plus) F0
# A may or may not be zero
# F0* may or may not be zero
# Tape:    F0* ' A ' 0  ' S1 ' F1 ' etc
#                ^

[>]<[->+<]  # Let B = A or F0*
# B may or may not be zero
<[-]>>  # Clear F0*
# Tape:     0 ' B ' 0 ' S1 ' F1 ' etc    (if A was zero)
#               ^
# OR        0 ' 0 ' B ' s1 ' F1 ' etc    (if A was nonzero)
#                   ^

# Let C = B or 2
# C will be guaranteed nonzero and unique from S0 and F0
>++<[<]>  # Create C
[.>>]  # Print (using S or F; does not matter)

>[>>]  # End on a zero cells with zero cells all to the right
# This is necessary for the coming functionality
# also as to not loop
]  # End non null block

# Now we consider if one of the strings was null
# Tape:    0 ' E0 ' 0 ' E1 ' etc    (if one string was null)
#          ^
# Tape:    0 '  0 ' 0 '  0 ' etc    (if neither string was null)
#          ^
# Where E is F or S (we don't care)

>[  # Execute only if one string was null

+  # Let A = E0 (plus) 1
# A may or many not be zero
# Tape: 0 ' A ' 0 ' E1 ' etc
#           ^

[>]+[<]>  # Let B = A or 1
# B is guaranteed nonzero and != E0
# Tape: 0 ' B ' ? ' E1 ' 0 ' E2 ' etc
#           ^

[.>>]  # Print

# End on zero cell as not to loop
]  # End null block

Your "fact" is wrong, e.g. a=2, b=1. You need to add instead of subtracting.

I think you can fix the S empty problem by adding > at the start and later doing [<]> on the leftmost byte of S - if that's nonzero it does nothing, otherwise it switches the strings.

@ØrjanJohansen Oh you're right, it can equal b. But not a.

@ØrjanJohansen Ah, that appears to work! Good thinking!

@ØrjanJohansen Follow up about the fact: Since it's != a only, if I print S/0, S/1, ... instead of S/0, F/1, ... it should work.

It could still break if S and F are equal after the first character.

Let us continue this discussion in chat.

Jelly, 8 bytes
żḟ@€ØAZḢ

Try it online!
How?
żḟ@€ØAZḢ - Link: list of characters, a; list of characters, b
ż        - zip a and b
    ØA   - uppercase alphabet
 ḟ@€     - filter discard for €ach (swap @rguments)
      Z  - transpose the result
       Ḣ - head

It returns B TIO

The algorithm shouldn't anyway, not sure what you did.

nevermind my brain apparently playing tricks since I don't see any X or Ẋ in there...

Python 3, 62 47 57 54 51 bytes
Edit: - 5 bytes thanks to @Mr.Xcoder
Edit: +10 bytes to fix a bug
Edit: -3 bytes thanks to @betaveros
Edit: -3 bytes by using max instead of pop
lambda x,y:max({*"abc"}-{x[:1],y[:1]})+max(x,y)[1:]

Try it online!

{"a","b","c"} ==> {*"abc"} (57 bytes)

(x[1:]or y[1:]) ==> max(x,y)[1:]?

Or just (x or y)[1:], I think you only need to avoid the empty string.

Incidentally, it's a shame Python 2 doesn't have starred set literals, because I really wanted to golf {*"abc"} into {*`id`}...

Save 1 with *len(x or y) instead of +max(x,y)[1:].

Mathematica, 111 bytes
(c=Characters;a=#2;While[f=Alphabet[]~RandomChoice~Length@#;f==#||f==c@a]&[#&@@c@{##}~MaximalBy~Length];""<>f)&

try it online (paste code with ctrl+v, place input at the end and hit shift+enter)
input

["test","me"]

thanx @Not a tree for checking and golfing -21 bytes

How do I test this online again?

added link+info

@Jenny_mathy Seems to fail if the first string is the empty string

@HalvardHummel fixed!

why the downvote???

I downvoted because there's still a lot of easy golfing that can be done to this: try (While[f=Alphabet[]~RandomChoice~Length@#;f==#]&[#&@@Characters@{##}~MaximalBy~Length];""<>f)&. But after looking at it some more, I think it's invalid — if the two strings are equal in length there's a small chance of returning one of them, since you only check if the random string is equal to one of the two.

@Notatree fixed. If you think that "easy golfing" is a reason for downvoting then you are welcome to do so

…I suppose that was quite harsh of me. I'm sorry. Downvote reversed.

you don't have to upvote either... anyways I'll try to implement your version.thanx

Charcoal, 22 bytes
ＦＥα×ι⌈⟦ＬθＬη⟧¿¬№⟦θη⟧ιＰι

Try it online! Link is to verbose version of code. Generates all strings of uppercase characters repeated to the length of the longer input and overprints all those that don't appear in the input. In other words, the output is normally ZZZ... unless that is one of the inputs, in which case it's YYY... unless that is the other input, in which case it's XXX....

Zsh, 51 47 37 36 bytes
-4 bytes by using builtin array argv, -10 bytes by using prefix removal and RC_EXPAND_PARAM, -1 byte by inlining the brace expansion.
<<<${${${:-{1..3}${^@#?}}:|argv}[1]}

Try it online!
First, this was an awesome challenge, I went through a ton of ideas before landing on this one.
<<<${${${:-{1..3}${^@#?}}:|argv}[1]}
       ${:-             }            # empty fallback
                 ${ @#?}             # remove first character from each parameter
                 ${^@  }             # enable brace expansion (set -P)
           {1..3}${^@#?}             # expand to 1foo 2foo 3foo 1bar 2bar 3bar
     ${                  :|argv}     # Set difference with 'argv'
   ${                           [1]} # The first found element
<<<                                  # print to stdout

@ and * are not identifiers, so ${  :|@} and ${  :|*} don't work, hence the use of ${  :|argv}

This method will work up to 93 inputs and find a 94th which is unique. Simply replace the {1..3} with the maximum possible range {~..!}.

Zsh, 48 47 bytes*
for ((;$#i<${#${1:-$2}}||$@[(I)$i];i++)):
<<<$i

Try it online!
Completely new method courtesy of JoKing's Perl 6 submission, but doesn't work on large strings (n>20) due to integer size restrictions. $@[(I)$i] is reverse array lookup to largest index, it will output zero (falsy in arithmetic expansion) if $i is not found in the command line parameters.

Perl 6, 38 30 bytes
{(1 x.max.comb...*∉$_).tail}

Try it online!
Anonymous codeblock that takes input as a list of two strings, and returns the first number from 1111... with a non-empty amount of 1s that isn't in the input.
Explanation:
{                          }   # Anonymous code block
  1 x.max.comb                 # String multiply 1 by the size of the non-empty string
              ...              # Create a sequence increasing by 1
                 *∉$_          # Until the number is not in the input
 (                   ).tail    # And take the last number

Is the incrementor a bigint type, or will this overflow for sufficiently large strings?

@GammaFunction In Perl 6, the default number type is Int, which has infinite precision

Oh, nice. I was going to adapt this to Zsh, but it uses long long unfortunately.

You can trim 6 bytes by just taking the first of 00..,111..,22.. instead of counting and sequences: https://tio.run/##K0gtyjH7n1upoJamYKvwvzots6i4REHrUUenSryORpyxQkSFtl5uYoVecn5ukmbt/@LESoU0jWglQwMDJR0gaagUq2nNBRO1BIpZAmWQxZR0FJRKUotLUATBAkAJFEFDIAAaYGAANeE/AA

@PhilH Good idea! I've shortened it a bit more by keeping with the sequence idea

Java (OpenJDK 8), 100 73 bytes
-27 bytes thanks to @Nevay's magical touch! :)
a->b->{b=b.length<1?a:b;if(a.length<1||(b[0]^=2)==a[0])b[0]^=1;return b;}

Try it online!
Input domain = Printable ASCII + codepoint 127.

73 bytes

Ruby, 53 bytes
->a,b{([?a,?b,?c].map{|e|e*[a,b].max.size}-[a,b])[0]}

Try it online!
Basically generates the strings a...a, b...b, and c...c and selects the first not in the input.

Fails if the first input is the empty string.

@SilvioMayolo fixed

42 bytes

ES6, 54 bytes
a=>b=>(a[0]+b[0]|0?'a':9-(a[0]^b[0]))+(a||b).substr(1)

Welcome to PPCG :)

Pyth, 7 8 bytes
hC-LG.T

1 byte thanks to Jakube
Test suite
We use .T, length preserving transpose, rather than C, truncating transpose, so that it works on inputs where one string is empty.
Given two strings as a tuple, we transpose them (.T), then map the resulting pair of characters or single character by subtracting the character(s) from the lowerase alphabet with -LG, then transpose the resulting list of strings of unused characters with C, then return the first such string with h. This consists of the first letter alphabetically that is not in either string, for each position.

MATL, 12 bytes
c"1Y2@X-1)&h

Input is a cell array of strings containing printable ASCII chars. The output is formed from the letters 'ABC', and so belongs to the input domain.
Try it online!
Explanation
The output is as long as the longest input string. Its n-th character is the first letter from 'ABC' that is different from the n-th character of both input strings.
c        % Concatenate the two strings vertically. If one is shorter it is
         % right-padded with spaces. Gives a 2-row character matrix
"        % For each column
  1Y2    %   Push the string 'ABC...Z' (the upper-case letters)
  @      %   Push current column
  X-     %   Set difference
  1)     %   Get first character
  &h     %   Horizontally concatenate the results so far
         % End (implicit). Display stack (implicit)

05AB1E, 8 7 bytes
øvAyм¬?

Uses the 05AB1E encoding. Try it online!

Does this work when one input is the empty string?

Doesn't work if the first string is empty. TIO

Haskell, 56 52 48 bytes
x#y|_:t<-max x y=[c:t|c<-"abc",c:t/=x,c:t/=y]!!0

Try it online!
Replace the first char of the maximum of the two input strings with a, band c and pick the first one that is different from both input strings.

APL (Dyalog Unicode), 11 bytesSBCS
Full program, takes input as a 2-element nested list.

⊃¨⎕A∘~¨,⌿↑⎕

Try it online!

Perl 5, 82 79 bytes
sub{$_=$_[0];$_=$_[1]||$_ if/^(xz*)?$/;s/[^z]/z/||s/./y/;$_ eq$_[1]&&s/./x/;$_}

Takes input as two separate arguments and returns the third string.
The subroutine attempts to produce a string very similar to the first string but with the first non-z character replaced with a z. Then it deals with corner cases by replacing the first character with y or x, as needed, if it finds that one of the inputs was in fact a sequence of all z's.

R, 89 67 bytes
@Giuseppe saved 9 bytes, @user2390246 saved 13 bytes
function
function(x,y)sub("^.",letters[!letters%in%substr(c(x,y),1,1)][1],x)

demo
# define function
f <- function(x,y)sub("^.",letters[!letters%in%substr(c(x,y),1,1)][1],x)

# test cases
f("test","test")
[1] "aest"
f("do","don't")
[1] "ao"
f("ye s","yes")
[1] "ae s"
f("maybe","mayue")
[1] "aaybe"
f("false","false")
[1] "aalse"
f("false","true")
[1] "aalse"
f("1","")
[1] "a"
f("art","bug")
[1] "crt"

You can put x and y within the same substr command. Also, curly braces and return are unnecessary: function(x,y)sub("^.",letters[!letters%in%substr(c(x,y),1,1)][1],x)

You can get rid of return since this is a function, and the braces since it's a one liner.

Shoot, I just realized that f("","1") yields "", which is equal to the first input... maybe this should be added as another test case

Perl 5, 68 bytes
sub{$_="a"x length $_[0]||$_[1];$_++while $_ eq$_[0]||$_ eq$_[1];$_}

Explanation:

starts with (string of letter "a" as long as first string) or second string if that is false i.e. zero-length
keeps incrementing that until it's different from both first and second

Starting from "a"s was to avoid incrementing to point where Perl lengthens the string; with only two strings to avoid being same as, it couldn't overflow.
Execute with:
perl -e '$s = ' -E 'sub{$_="a"x length $_[0]||$_[1];$_++while $_ eq$_[0]||$_ eq$_[1];$_}' -E ';say $s->("z", "true")'

I think this will fail if the first string is empty.

Quite right! Fixed.

C (gcc), 70 65 73 67 61 bytes
The function needs the provided strings to be mutable (i.e. either arrays or dynamically allocated).
f(a,b)char*a,*b;{a=*a?a:b;*a=*a>70?33:99;*a+=*a==*b;puts(a);}

Try it online!
Works for the standard ASCII range
Explanation:
a=*a?a:b           // If a is empty, point to b instead
*a=*a>70?33:99     // Choose a different value for the 1st character of a,
                   // while giving enough space to increment it without
                   // going back to its previous value
*a+=*a==*b         // Increment the 1st character of a if the arbitrary
                   // chosen value is equal to the value of the 1st
                   // character of b
puts(a)            // Outputs a

I'm not sure this can be given a consistent input domain satisfying the rules. What if *a==255 and *b==0?

You're right. Fixed, at the cost of 8 bytes.

There. I couldn't let this solution have the same bytecount than the Java one! :-)

If you don't restrict to printable ASCII then you could use single-digit numbers.

Unless I misunderstood, that would be against this challenge rules.

Hm I don't understand it that way, see Luis Mendo's question comment. You must be able to input any character you output, but not vice versa.

Of course, but there is also the first rule: You may chose your input domain, but it must be composed of at least printable ASCII. And I don't see characters 0 to 6 (included) as printable ASCII characters, leaving us with only 3 "printable" characters (this is debatable for chars 7 & 8). And I need at least 4 consecutive chars to force a different one for one of the provided strings.

The first rule means that you have to accept all printable ASCII characters. You can accept whatever other characters you want, otherwise there would be nothing to choose.

Pyth, 23 22 bytes
+.)-.{<G3.{,<Q1<KE1t|K

Try it here!
Pyth, 22 bytes
+eS-.{<G3.{,<Q1<KE1t|K

Test Suite!

Explanation
+.)-.{<G3.{,<Q1<KE1t|K  - Full program.
      <G3               - Yields the String "abc"; Alphabet[:3].
    .{                  - Set formed by the above.
         .{,<Q1<KE1     - Set formed by input_1[:1] and input_2[:1]
   -                    - Set subtraction.
 .)                     - Pop the last element.
+                       - Append.
                   t|K  - input_1[1:] or input_2[1:], relying on the result of Logical OR.

Ruby, 56 bytes
->a,b{a,b=b,a if a<b;a[0]=([?a,?b,?c]-[a[0],b[0]])[0];a}

Java 8, 119 bytes
Lambda (curried) from String to lambda from String to String. Assign to Function<String, Function<String, String>>.
s->t->{String r=s.length()>t.length()?s:t;while((s+t).contains(r))r=r.substring(1)+(char)(Math.random()*128);return r;}

Try It Online
Ungolfed lambda
s ->
    t -> {
        String r = s.length() > t.length() ? s : t;
        while ((s + t).contains(r))
            r = r.substring(1) + (char) (Math.random() * 128);
        return r;
    }

This solution rotates random ASCII characters into the longer string until the required conditions are satisfied. Inputs are UTF-8 and outputs are ASCII.
I don't know the gritty details of Unicode, but it seems plausible to me that this solution could fail when an appended char joins the preceding code point to form a single code unit. If someone who knows more about this can verify this, I'll change the input domain to ASCII.
Java 8, 126 bytes
Same type as above.
s->t->{String r;for(byte[]o=(s.length()>t.length()?s:t).getBytes();(s+t).contains(r=new String(o));o[0]%=128)o[0]++;return r;}

Try It Online
Ungolfed lambda
s ->
    t -> {
        String r;
        for (
            byte[] o = (s.length() > t.length() ? s : t).getBytes();
            (s + t).contains(r = new String(o));
            o[0] %= 128
        )
            o[0]++;
        return r;
    }

This increments the first byte of the longer string, wrapping within ASCII, until the required conditions are met. Inputs and outputs are ASCII strings.

Given the output of your third test case, it outputs a string of length three: Try it online!

Ah, crap. Now I'm going to have to learn how Unicode works in order to fix this without exploding the byte count...

Bash, 115 .. 77 bytes
Replaces first char of the first (non-empty) input string with 1,2,3 until no match is found to either input. Try it Online!
-9, -12, -9, -8 bytes all thanks to GammaFunction
x="${1:-$2}"
for s in {1..3}"${x:1}"
{ [[ $s = @($1|$2) ]]||break;}
echo "$s"

(quite an improvement over the original...)

Nice method! You can use = and || in the last line, and use ${x:-empty_fallback} to remove the starting ternary. Also, you do need quotes on the ending echo for the case of trailing spaces. Obligatory TIO

Thanks! Couldn't figure out how to use "empty fallback" though

Here's the TIO link, 94 bytes

I like what you're going for with the shift, I got it to tie my method in two different methods.

Whoops, I found another change: @($1|$2) pattern matching

Thanks for the ideas, I never knew about fallback and @-pattern-matching

Umm, I.. uh... did some more things

Brachylog, 10 bytes
∋l~lℕṫ.&≡ⁿ

Try it online!
Explanation
There may be a better way to do this, but I've been fighting Brachylog strings for a while now and this solution works.
∋           For some element of the input list
 l          get its length
  ~l        That is also the length of
    ℕ       some positive integer
     ṫ      Converting that integer to a string
      .     is the output
       &    Also:
         ⁿ  It is not true, for any X in the input list
        ≡   that the output equals X

Outputs strings like "100". If "100" is already in the input list, goes to "101", etc.

C# (Mono), 94 bytes
s=>t=>{var r=s!=""?s:t;while(r==s|r==t)r=r.Substring(1).Insert(0,(char)(r[0]+1)+"");return r;}

Try it online!

92 bytes

Perl 5, 79 + 1 (-p) = 80 bytes
$"=<>;chop;$_=length($,=$_)>length$"?$_:$";s/./chr$&+65+$i++/e while/^($"|$,)$/

Try it online!

Fails if the two strings are of different length

I noticed that.  Just revised it.

Japt, 17 bytes
;B¬£ñl g1 çXÃkU v

Repeats the letters A-Z to the length of the longer input, removes the values in the input, and get the first item in the array.
Try it online!
Old solution, 18 bytes
;@!UøX}a@ñl g1 çBö

Try it online!
Chooses a random character from the alphabet and repeats it to the length of the longer input string, until it is not present in the input.

Failed for ["abcdefghijklmnopqrstuvwxyz", "AAAAAAAAAAAAAAAAAAAAAAAAAA"]. When running it multiple times, it returned "AAAAAAAAAAAAAAAAAAAAAAAAAA" (just like my Pyth answer did, until I fixed that)

It fails for ["D", ""]. if you run it several times you'll get "D"

Thanks, I figured there were some cases I hadn't tested. Fixed for only +1 byte.

Ì should work in place of g1  for a 2 byte saving (in a 2 element array g1=gJ) but there appears to be a bug with Ì when using ;.

@Shaggy Yeah, I think that's cause J is no longer -1 because of the ; changing it to ,. That's why I used 1 in the first place.

Ah, of course, hadn't thought of that being the problem.

CJam, 31 30 23 bytes
q~:A:e>,3,sf*{A\f=:+!}=

Takes printable ASCII as input. Outputs either a string of 0's, 1's, or 2's that is the same length as one of the input strings. The logic is that one of those can't be either of the input strings!
Try it Online
q~:A    e# Store input array as var 'A'
:e>,    e# Take the length of the lexicographically greater string in the input array
3,s     e# Generate "012"
f*      e# Repeat each number as many times as the longer string length, yielding something like ["000","111","222"]
{       e# Search array of number strings for first that returns true for this function
A\f=    e# Map each string in the input array to whether it equals the current number string (0,1)
:+!     e# Add up the array of bits and take the logical not. This returns true iff both array values were not equal to the current number string.
}=      e# Return the first number string that returns true.

Anyone have any ideas on how to return true only if both bits in the array are false (NOR)? Currently, I'm doing :+!.

Python 3, 74 73 bytes
-1 byte thanks to Step Hen
def f(x,y,i=1):
 while i*10<10**len(x or y)or str(i)in x+y:i*=2
 print(i)

Prints lowest integer with the same length as the first of the inputs that has nonzero length.

Save a byte with i as a default function parameter: def f(x,y,i=1):. I think you can save another byte with while10*i but I'm not sure.

You can replace  while i*10<10**len(x or y)or str(i)in x+y with while i<10**~-len(x or y)or str(i)in x+y  (72 bytes)

And you can also use recursion to save bytes: f=lambda x,y,i=1:(i<10**~-len(x or y)or str(i)in x+y)and f(x,y,i*2)or i (71 bytes)

Python 2, 77 bytes
a=input()
b=ord(a[0][0])+1
if b==ord(a[1][0]):b+=1
print unichr(b)+a[0][1:-1]

I think it has some potential. The idea is that it adds 1 to the 1st char in the 1st string, then checks if the other input's 1st char is the same.
**Note, ^ doesn't handle 0 length strings, so it doesn't really work at this length.
Here's a super long solution that works with 0 length
146 Bytes
a=input()
def c(i):print unichr(ord(a[i][0])+1)+a[i][1:];exit();
for x in range(2):if len(a[x-1])<1:c(x)
if a[0]==a[1]:c(1)
print a[1][0]+a[0][1:]

Any improvements would be appreciated!

Python 3, 67 bytes
lambda a,b:[k for k in"abc"if k not in b[:1]+a[:1]][0]+(a or b)[1:]

Try it online!
Picks the first character of "a", "b", and "c" which neither string begins with - all three characters can't be the first character of one of two strings. The first character of a is then replaced with that character, unless a is empty, in which case the first character in b is replaced instead.

Pip, 16 bytes
T#iN#*g&iNIg++ii

Try it online!
Increments the number i until i has the same length as one of the inputs and does not equal either of the inputs, and then prints i. Takes about 30 seconds on TIO to output 100000 for length-six input.

Pip, 16 bytes
YMXgRXX9WyNg--yy

Try it online!
Different approach from my first submission (and much faster):
   g              List of command-line args     ["abc" "9999"]
    R             Replace
     XX           any character (regex `.`)
       9          with 9                        ["999" "9999"]
 MX               Get the max                   9999
Y                 Yank it into y variable
        W         Loop while
         yNg      y is in the cmdline args:
            --y    Decrement y
               y  Output y                      9998

JavaScript (Node.js), 39 bytes
a=>b=>(a[0]&1^b[0]&2^7)+(a||b).slice(1)

Try it online!
Obvious source the 3rd byte

Haskell, 41 bytes
n[]_=[]
n _[]=[]
n(i:c)(h:t)=succ i:n c t

The empty string isn't a valid output if one of the inputs is an empty string...

It fails if the string starts with '\1114111'.

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Diagonal Alphabet To the Input
Inspired by this post. For those marking this question as a duplicate I urge you to actually read the question to see that mine is a modification of the one linked. The one linked does not ask for an input and is to just print the alphabet diagonally.
The Challenge
Given an input between 1-26 inclusively, print the alphabet diagonally, but begin printing vertically at the index of the given input.
Examples
Given the input:
16

Your program should output:
a
 b
  c
   d
    e
     f
      g
       h
        i
         j
          k
           l
            m
             n
              o
               p
               q
               r
               s
               t
               u
               v
               w
               x
               y
               z

Input:
4

Output:
a
 b
  c
   d
   e
   f
   g
   h
   i
   j
   k
   l
   m
   n
   o
   p
   q
   r
   s
   t
   v
   w
   x
   y
   z

Input:
1

Output:
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z

Input:
26

Output:
a
 b
  c
   d
    e
     f
      g
       h
        i
         j
          k
           l
            m
             n
              o
               p
                q
                 r
                  s
                   t
                    u
                     v
                      w
                       x
                        y
                         z

Scoring
This is code-golf, so the shortest answer in each language wins.
Good luck!

May we choose to use either 0- or 1-indexing?

Is a consistent leading space acceptable?

Are trailing spaces acceptable?

May we use uppercase?

May we return a list of strings?

@Giuseppe sure, no problem!

@DomHastings yes, they are!

@Adám yes to both of your questions!

Charcoal, 9 bytes
↘✂β⁰Ｎ↓✂βη

Try it online!
How it works
↘✂β⁰Ｎ↓✂βη
 ✂β⁰Ｎ         the alphabet from position 0 to the input
↘               print diagonally, down and to the right
        ✂βη    the alphabet starting from the position of the input
       ↓        print downwards

This solution no longer works in the current version of Charcoal (most likely due to a bug fix), but the issue is resolved for 10 bytes with ↘✂β⁰Ｎ↓✂βＩθ.

I'm not sure why that works; it may be a bug that was introduced a couple of weeks ago. (You'd normally have to use Ｉθ instead of η.)

@Neil It seem broken today. Using Ｉθ solves it.

Save 1 byte by using …βＮ instead of ✂β⁰Ｎ.

05AB1E, 11 bytes
AvNI<‚Wysú,

First time trying 05AB1E, so I'm open to tips.
Try it online!
If a zero-indexed input from 0 to 25 is allowed, this can be 10 bytes by omitting the <.

Niiice! Exactly what I got. I tried "lift" but it's not working as planned. I think that's pretty optimal :).

Python 2, 61 58 57 56 bytes
def f(i,j=0):exec"print(' '*~-i)[:j]+chr(97+j);j+=1;"*26

-3 bytes thanks to Rod
-2 more bytes thanks to Mr. Xcoder

same answer, but with input/print to save few bytes

@Pavel That wouldn't work since then input would be called every time the for loop iterates, even though there's only one line of input.

57 bytes using exec

57 bytes using subscripting.

56 bytes

JavaScript (ES2017), 73 72 71 66 bytes
Saved some bytes thanks to @JustinMariner
f=(n,x=26)=>x?f(n,x-1)+(x+9).toString(36).padStart(x<n?x:n)+`
`:''

This adds a 10 after z at the end due to having ++x before x.toString(). Bugfixed and golfed to 68 bytes using padStart: TIO

@JustinMariner Thanks, I think I might switch to ES8 for that...

Can you save anything by currying? n=>g=(x=26)=>x?f(x-1)+(x+9).toString(36).padStart(x<n?x:n)+'\n':""

@Shaggy Perhaps, I don't know if that type of currying is allowed though.

Ah, nuts, looks like your proposal to allow this is no longer a consensus :(

Ruby, 51 46 43 bytes
->n{(0..25).map{|x|(' '*x)[0,n-1]<<(x+97)}}

Returns a list of strings.
Looks like the Python guys were on to something with their subscripts. -5 bytes by taking inspiration from Mr. Xcoder's improvement of ppperry's solution.
Previous solution with rjust (51 bytes):
->n{i=0;(?a..?z).map{|c|c.rjust i+=n>c.ord-97?1:0}}

R, 99 89 bytes
@MickeyT saved 10 bytes
function
function(x)for(i in 1:26)cat(paste(c(rep(" ",min(x,i)),letters[i]),collapse=""),sep="\n")

demo
f <- function(x)for(i in 1:26)cat(paste(c(rep(" ",min(x,i)),letters[i]),collapse=""),sep="\n")
f(1)
f(10)
f(15)
f(26)

A couple of little savings.  Rather then the ifelse try min.  print.noquote can be replaced with cat with a '\n' in the paste.  The \n can be a straight carriage return. Curly braces for the function body can be dropped.

You can save some more by using write rather than cat and paste: write(c(rep(" ",min(x,i)),letters[i]),"",26,,"")

Python 2, 62 50 57 bytes
x=input();n=m=1
exec"print'%*c'%(m,n+96);n+=1;m+=x>m;"*26

Try it online!
Steals heavily from this answer by Dennis.

Retina, 72 68 bytes
^
z
{2=`
$`
}T`l`_l`^.
\D
$.`$* $&¶
\d+
$*
s`( *)( +)(?=.*¶\1 $)
$1

Try it online! Output includes trailing whitespace. Save 1 byte by deleting the space before the $ if zero-indexing is allowed. Edit: Saved 4 bytes by using @MartinEnder's alphabet generator. Explanation:
^
z
{2=`
$`
}T`l`_l`^.

Insert the alphabet.
\D
$.`$* $&¶

Diagonalise it.
\d+
$*

Convert the input to unary as spaces.
s`( *)( +)(?=.*¶\1 $)
$1

Trim overlong lines so that no line is longer than the blank line at the end.

APL (Dyalog), 12 11 bytes
-1 as OP has now clarified that returning a list of strings is fine.
Prompts for input.
⎕A↑¨⍨-⎕⌊⍳26

Try it online!
⍳26 first 26 strictly positive ɩntegers
⎕⌊ minimum of input and those
- negate those
⎕A↑⍨¨ for each letter of the Alphabet, take that many characters (from the rear, as all numbers are negative), padding with spaces as necessary

↑ convert list of strings into matrix (only in TIO link to enable readable output)

Haskell, 58 54 bytes
f n=do m<-[1..26];([2..min n m]>>" ")++['`'..]!!m:"\n"

Try it online!
How it works
f n=                  -- input number is n
  do m<-[1..26]       -- for each m from [1..26], construct a string and concatenate
                      -- them into a single string. The string is:
   [2..min n m]>>" "  -- min(n,m)-1 spaces,
      ++              -- followed by
   ['`'..]!!m         -- the m-th char after `
      :               -- followed by
   "\n"               -- a newline

Edit: @Lynn saved 4 bytes. Thanks!

You can save four bytes using do notation and ['`'..]!!m.

@Lynn; Thanks! I always forget about do notation for lists.

Java (OpenJDK 8), 69 bytes
n->{for(int a=0;a++<26;)System.out.printf("%"+(a<n?a:n)+"c%n",a+96);}

Try it online!

Mathematica, 103 bytes
(T=Table;a=Alphabet[];c=Column)[c/@{T[""<>{T[" ",i],a[[i]]},{i,#}],T[""<>{T[" ",#],a[[i]]},{i,#,26}]}]&

Pyth, 21 17 15 bytes
VlG+*d?>QNNQ@GN

Explanation:
VlG        For each character in the alphabet (G)
+          Concatenate...
 *d        Space (d) times...
   ?>QNNQ  Ternary; if Q (input) is less than N, return N, else Q
 @GN       The Nth character of the alphabet (G)

Try it online!

Found some considerably shorter approaches, and I decided to post my own answer.

Jelly, 11 bytes
26Ḷ«’⁶ẋżØaY

Try it online!

Common Lisp, 84 bytes
(lambda(x)(dotimes(i 26)(format t"~v,,,@a~%"(if(< i x)(1+ i)x)(code-char(+ i 97)))))

Try it online!

Python, 52 bytes
Quite surprised nobody noticed the obvious approach was also as short as the others.
lambda k:[(i*" ")[:k-1]+chr(i+97)for i in range(26)]

Try it online!
Python, 53 bytes
lambda k:[min(k-1,i)*" "+chr(i+97)for i in range(26)]

Try it online!

Gaia, 12 bytes
…26⊃§×¦₵a+†ṣ

Try it online!
Explanation
…             Range 0..input-1
 26⊃          Repeat the last number enough times to make it have length 26
    §×¦       Turn each number into a string of that many spaces
       ₵a+†   Add the corresponding letter to each
           ṣ  Join with newlines

PowerShell, 66 60 bytes
param($a)65..90|%{" "*(($b=$_-65),($a-1))[$b-ge$a]+[char]$_}

Try it online!
Loops through the alphabet, each iteration using string multiplication to prepend the appropriate number of spaces (chosen using a pesudo-ternary (,)[]), then string-concatenates with the current character.

SimpleTemplate, 79 70 bytes
The code outputs the required text and a trailing newline.
{@forfrom"a"to"z"}{@echols,_}{@inca}{@ifa is lowerargv.0}{@sets s," "}

Ungolfed:
{@for letter from "a" to "z"}
    {@echo spaces, letter, EOL} {@// same as echol}
    {@inc by 1 index} {@// sets to 1 if it doesn't exist}
    {@if index is lower than argv.0}
        {@// creates an array like [[[...], " "], " "]}
        {@set spaces spaces, " "}
    {@/} {@//not required}
{@/} {@// not required}

You can try it on http://sandbox.onlinephpfunctions.com/code/a0ee99464f463d23072ff5d5be7dbd3a532f9c7c
(Old version: http://sandbox.onlinephpfunctions.com/code/a60e11b9dd2dcd54a84c11937f1918f26e0adcfa)

Japt, 16 13 bytes
Saved 3 bytes thanks to @Oliver
;C£RiXiYmUÉ î

Test it online!

@Oliver Dang, I was tired...

JavaScript (Node.js), 72 bytes
n=>[..."abcdefghijklmnopqrstuvwxyz"].map((e,i)=>" ".repeat(i<n?i:n-1)+e)

Returns a list of strings.
Try it online!

May I ask why node.js? seems like valid normal JS

@Downgoat It's the TIO auto formatting

btw you can save bytes using .padStart

Wait nvm the way I was thinking basically makes it into ETH's answer

Switch to ES8 and save a byte with padEnd instead of repeat.

Mathematica, 67 bytes
SparseArray[x=#;{#,#~Min~x}->Alphabet[][[#]]&~Array~26,{26,#}," "]&

Returns a SparseArray of strings. To visualize, append Grid@ in front.
Try it on Wolfram Sandbox
Usage
Grid@SparseArray[x=#;{#,#~Min~x}->Alphabet[][[#]]&~Array~26,{26,#}," "]&[5]

a
 b
  c
   d
    e
    f
    g

    ⋮

    z

Python 2, 52 bytes
lambda n:['%*c'%(min(i+1,n),i+97)for i in range(26)]

Try it online!
I'm assuming a list of strings is fine...
Shortest I could get with recursion:
f=lambda n,i=0:i<26and['%*c'%(min(i+1,n),i+97)]+f(n,i+1)or[]

SOGL V0.12, 12 bytes
z{ē.-.Hχ@*Ot

Try it Here!

Perl 5, 47 39 bytes
$l=<>;say$"x($#i+=$#i<$l-1).$_ for a..z

Try it online!

Nuce use of $#i. That might even be worth adding as a separate tip!

Coming back to this after three years and noticed you can drop to 30 bytes using -na!: Try it online!

Python 3, 52 bytes
lambda n:[('%*c'%(i,i+96))[-n:]for i in range(1,27)]

Try it online!

C (gcc), 50 bytes
i;f(n){for(;i<26;printf("%*c\n",i++<n?i:n,i+97));}

Try it online!

Pyth, 12 bytes
j.e+<*kdtQbG

Try it here!
If lists of Strings are allowed, this can be shortened to 11 bytes:
.e+<*kdtQbG

Pyth, 12 bytes
VG+<*dxGNtQN

Try it here!
Pyth, 14 bytes
jm+<*d;tQ@Gd26

Try it here.
If lists of Strings are allowed, this can be shortened to 13 bytes:
m+<*d;tQ@Gd26

How do these work?
Unlike most of the other answers, this maps / loops over the lowercase alphabet in all 3 solutions.
Explanation #1
j.e+<*kdtQbG - Full program.

 .e        G - Enumerated map over "abcdefghijklmnopqrstuvwxyz", with indexes k and values b.
     *kd     - Repeat a space a number of times equal to the letter's index.
    <   tQ   - Crop the spaces after the input.
   +      b  - Concatenate with the letter.
j            - (Optional): Join by newlines.

Explanation #2
VG+<*dxGNtQN  - Full program.

VG            - For N in "abcdefghijklmnopqrstuvwxyz".
      xGN     - Index of the letter in the alphabet.
    *d        - Repeat the space a number of times equal to the index above.
   <     tQ   - But crop anything higher than the input.
  +        N  - Append the letter (at the end)

Explanation #3
jm+<*d;tQ@Gd26 - Full program.

 m          26 - Map over [0...26) with a variable d.
    *d;        - Space repeated d times.
   <   tQ      - Crop anything whose length is higher than the input.
  +      @Gd   - Concatenate with the letter at that index in the alphabet.
j              - (Optional): Join by newlines.

Proton, 40 bytes
Assuming that a list of Strings is fine.
k=>[(i*" ")[to~-k]+chr(i+97)for i:0..26]

Try it online!
Proton, 49 bytes
As ASCII-art instead:
k=>'\n'.join((i*" ")[to~-k]+chr(i+97)for i:0..26)

Try it online!

C# (.NET Core), 66 + 18 bytes
n=>new int[26].Select((x,i)=>$"{(char)(i+97)}".PadLeft(i<n?i+1:n))

Byte count also includes
using System.Linq;

Try it online!
This returns a collection of strings, one for each line. If it's not allowed, the answer will swell by 17 bytes for string.Concat() and \n inside string
Explanation:
n =>
    new int[26]                      // Create a new collection of size 26
    .Select((x, i) =>                // Replace its members with:
        $"{(char)(i + 97)}"          // String of an alphabet character corresponding to the index
        .PadLeft(i < n ? i + 1 : n)  // Add spaces to the left
    )

MATL, 14 bytes
26:tiXl2Y2oZ?c

Try it at MATL Online
Explanation
26      % number literal
:       % range; vector of equally spaced values [1...26]
t       % duplicate
i       % explicitly grab the input
Xl      % clamp the array to have a maximum value of the input
2Y2     % predefined literal: ['a'...'z']
o       % convert to a numeric array
Z?      % create sparse matrix using the first two inputs as the rows/columns
        % and the letters 'a'...'z' as the values
c       % convert back to character and implicitly display

Perl 5, 36 bytes
31 bytes code + 5 for -i# -l.
Note: this takes input via -i, if that is unacceptable (since it's non-standard) I can remove.
$\.=$"x(--$^I>0),print for a..z

Try it online!
Explanation
For this I'm abusing the special variable $\ which is automatically printed after each call to print, to store the next line's indentation. Using the flag -l (which enables line ending processing), $\ is pre-initialised to "\n" so we append a space each time we process an element in the range a..z, as long as --$^I isn't less than 0. Using $^I (via the -i commandline flag) means I don't need to store input separately, but it's bit of a stretch as its not the usual way to accept input in Perl. Since the postfix for loop stores the current item in $_, we don't need any arguments to print ($_ is automatically printed and $\ is automatically appended) so we just call it each iteration, appending spaces as we go to get the desired output. This does append trailing spaces though, which @SpookyGengar has allowed.
Thanks to @Xcali for pointing out an oversight!

Are you off by one here?  Based on the examples, it looks like an input of 4 should have d and e vertically aligned.

@Xcali Oops! Yeah! Change to pre-decrement instead, thank you!

Haskell, 60 bytes
f n=unlines$scanl(\p c->take(n-1)(p>>" ")++[c])"a"['b'..'z']

This is a function that returns the output as a String.
Try it online.

Java 1.8 (without Lambda), 98 Bytes
void m(int i){int c=0,o=97;String s="";for(;c++<26;s+=c<i?" ":"")System.out.println(s+(char)o++);}

The logic is straightforward. Provides no input data validation, very bad!

Update: Function only! Thank you to @Olivier Grégoire

To spare some bytes, use for(;c++<26;s+=c<i?" ":"")System.out.println(s+(char)o++); Also, you can write only a function, or a lambda instead of a full program.

If I were to include only the body of a function, then how would the reader know what a[0] refers to? I think snippets are not fair if they do not compile; the challenge is just as interesting with a language rich in constructs.

Hello! I did say a function or a lambda, not a snippet. ;-) So you can write void f(int i){...} (no static needed) or i->{...} instead of your whole program. See all Java tips. See my answer for this same challenge, as example. Have fun on the site! :-)

q/kdb+, 33 31 bytes
Solution:
-1{(&[x-1;til 26]#'" "),'.Q.a};

Example:
q)-1{(&[x-1;til 26]#'" "),'.Q.a}16;
a
 b
  c
   d
    e
     f
      g
       h
        i
         j
          k
           l
            m
             n
              o
               p
               q
               r
               s
               t
               u
               v
               w
               x
               y
               z

Explanation:
Create a list of spaces (26) up to the length of the minimum of the input and the range of 0..25), join with each letter of the alphabet, print to stdout.
-1{(&[x-1;til 26]#'" "),'.Q.a}; / solution
-1                            ; / print result to stdout and swallow return
  {                          }  / lambda function
                         .Q.a   / "abcd..xyz"
                       ,'       / concatenate (,) each
   (                  )         / do all this together
    &[   ;      ]               / minimum of each
      x-1                       / implicit input (e.g. 10) minus 1 (e.g. 9)
          til 26                / 0 1 2 ... 23 24 25
                   '#" "        / take " " each number of times (0 1 2 )

Notes:

-2 bytes by rejigging the brackets

While I couldn't find a shorter q answer, the following is only 22 bytes in k4: {-1(-x&1+!26)$'$.Q.a;}.

don't think you need the '? {-1(-x&1+!26)$$.Q.a;} for 21 bytes.

Ooh, good catch! Did not realize $ (pad) accepts a list left-hand argument.

Pyke, 6 bytes
G\xb1oh->

Try it here!
          - o = 0
G         -  alphabet
 \xb1     - for i in ^: (1 byte, pretty prints)
     oh   -    (o++)+1
       -  -   " "*^ + i
        > -  ^[input:]

Bash, 50 bytes
for c in {A..Z};{ printf "%$[++i<$1?i:$1]s\n" $c;}

Try it online!
Takes input as a command-line argument.

Japt -R, 9 bytes
;C¬ËùUm°E

Try it
;C¬ËùUm°E     :Implicit input of integer U
;C            :Lowercase alphabet
  ¬           :Split
   Ë          :Map each character at 0-based index E
    ù         :Left pad with spaces to length
     Um       :  Minimum of U and
       °E     :  E incremented
              :Implicit output joined with newlines

Forth (gforth), 53 bytes
: f 1- 26. do dup i min spaces i 97 + emit cr loop ;

Try it online!
Pretty standard answer.

Python 3, 101 bytes
def f(n,a=0):
 b="abcdefghijklmnopqrstuvwxyz"
 for l in range(len(b)):print(" "*a,b[l]);a+=[0,1][l<n]

Try it online!

Brainbash, 98 bytes
+[-[---<]>>-]<-~++++++++[>++++>+++>+<<<-]>>++>++>#-<<[>>>[-<<<<.>>>>>+<]>[-<+>]<<{->+<}<<-~.+~>.<]

Try it online!
Explanation
The code can be split into two parts:
+[-[---<]>>-]<-~++++++++[>++++>+++>+<<<-]>>++>++>#
-<<[>>>[-<<<<.>>>>>+<]>[-<+>]<<{->+<}<<-~.+~>.<]

Basically, generate the constants 97, 32, and 26. Then, takes a number N as input. After input (#) the tape looks like:
[ ]   0      0     >97     0
[*]   0      32     26     10    >0

The second part executes 26 times, each time decrementing the input. Every time the input is decremented, the prefix length is incremented. After the input reaches zero, the prefix length remain constant. After each loop, the spaces, the letter, and a newline are printed.

Excel VBA, 53 50 Bytes
Anonymous VBE immediate window function that takes input of expected type Integer in the domain of [1,26] from range [A1] and outputs to the VBE immediate window
For i=0To 25:[B1]=i:?Spc([Min(1:1)])Chr(97+i):Next

><> (-v), 51+2 Bytes
'a'$1-0\   /' 'o1-81.
'z')?;}>::?/~$:@@:@)+{:oao1+:

Try it online
equivalent pseudo code
char = 'a'
input = read_number
input -= 1
tabCount = 0

while true
    for i from 0 to tabCount
        print ' '
    if tabCount < input
        ++tabCount
    print char
    print '\n'
    ++char
    if char > 'z'
        exit

Röda, 48 bytes
f n{seq 1,26|min([n,_])<>chr 96+_1|print" "*_,_}

Try it online!
Each output line has one leading space.
Explanation:
f n{
  seq 1,26|    /* push numbers 1..26 to the stream (inclusive) */
               /* for each number in the stream: */
  min([n,_])<> /*  push min(n, _1) */
  chr 96+_1|   /*  push string containing _1 as a letter */
               /* for each number _1 and letter _2 in the stream: */
  print" "*_,_ /*  print _1 spaces and _2 */
}

 Elixir, 145 bytes
{n,_}=IO.gets("")|>Integer.parse;for x<-?a..?z,do: if x-97<n,do: IO.puts String.pad_leading(<<x>>,x-96),else: IO.puts String.pad_leading(<<x>>,n)

Try online

PHP, 67 bytes
<?for($l=a;$l!=aa;)echo str_pad($l++,min($argv[1],++$x)," ",0)."
";

Try it online!

VBA Excel, 51 bytes
using Immediate Window and [a1] as input
for x=1to 26:?spc(iif(x<[a1],x,[a1]))chr(96+x):next

SNOBOL4 (CSNOBOL4), 107 bytes
	N =INPUT
I	&LCASE POS(R) LEN(1) . L
	OUTPUT =DUPL(' ',X) L
	R =R + 1
	X =LT(R,N) X + 1
	LT(R,26)	:S(I)
END

Try it online!

05AB1E, 9 bytes
27α‚A34SΛ

Try it online.
A golfed version of the existing 05AB1E answer in the new 05AB1E version is 9 bytes as well:
Av<N‚ßyú,

Try it online.
Explanation:
27α        # Take the absolute difference of 27 with the (implicit) input
   ‚       # Pair it to the (implicit) input
    A      # Push the lowercase alphabet
     34S   # Push 34 as a list of digits: [3,4]
        Λ  # Use the Canvas builtin with these three as arguments:
           #  Direction [3,4], which translates to [↘,↓]
           #  Characters to draw: the lowercase alphabet
           #  Length of each part to draw: [input,|input-27|]
           # (after which the result is output immediately afterwards)

See this 05AB1E tip of mine for an in-depth explanation of how the canvas builtin works.
A          # Push the lowercase alphabet
 v         # Pop and loop over each of its characters `y`:
  <        #  Decrease the (implicit) input by 1
   N‚      #  Pair it with the 0-based loop index
     ß     #  Pop and push the minimum of this pair
      y    #  Push the current character
       ú   #  Pop both, and pad the character with leading spaces equal to the integer
        ,  #  Pop and print this string with trailing newline

Vyxal j, 9 bytes
ka¨2?‹∵Ip

Try it Online!

Python 3, 57 bytes
lambda n:[f"{chr(65+i):>{min(i+1,n)}}"for i in range(26)]

Try it online!
Used python formatting to automatically put spaces in output i.e. {'a':>5} will give     a

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/