How to enjoy competitive programming on iPad (lie-down)
Tags: python, ios, competitiveprogramming
Published: 2022-06-02 11:13:31

Lie-down Programming

![iPad coding](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i5b9sm8xahp77y64u76a.jpg)

## Preface
I think **resting your body is important for being in good shape until the end of retirement**.  Even if you are smart, sometimes you have to quit jobs due to the pain of the back. Lying down and resting is important because the weight of the back is sit >> stand >lie down.

Reading articles on iPad or Kindle is easy. Speech to text may be possible for novels and blogs thanks to the improvement of speech recognition. However, programming needs symbol inputs. That's not suitable for speech recognition.

The programming on tablet  sometimes stands for the tablet with Bluetooth keyboard. That's just the replacement of PC. Still need sitting. Programming while lying down is rare. Today I use AtCoder and Python as an example.

## How to do programming on tablet
The choices of development environments are mainly two ways.

* **Use language unique development app**
* **Open web-based IED on web browser**

The former has the advantage on opening local files, offline availability, temporary save. The latter provides more choices of programming languages.

At least on iOS, some developers publish software-engineer-oriented keyboards.  By combining those specialized keyboards, customization shines. However in this article, I focus on Python due to the number of past resources.

## Python running environment comparison
As Python environment on iPad, Pythonista ‪3‬ and Python3ID‪E are popular.

### Pythonista ‪3‬
https://apps.apple.com/us/app/pythonista-3/id1085978097

![iPad coding](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i5b9sm8xahp77y64u76a.jpg)

Pythonista is the most famous app for iOS + python. It is paid app and on sale while the season for major Python conferences.

As of Feb. 2021, the latest AtCoder python version is 3.8. Pythonista supports only old 3.6.  By saving files on iCloud, the same files are editable by both iPhone and iPad if you can wait sync time.

The in-app keyboard provides unique tab and symbol keys on the top line for convenience. The disadvantages are missing key for moving the cursor to the end of line and if-else indent is not smart. Not perfect for my use case, but affordable.

### Python3IDE
https://apps.apple.com/jp/app/python3ide/id1357215444


![Python3IDE screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m9pwk61nvla6k7z27ts6.jpg)

This one is Python 3.7 and for free. Although Pythonista supports library addition via pip with some hassles, Python3IDE has embedded UI for library install. That's much easier.

Unfortunately, I faced some buggy behavior on blank line insert and new line delete. Suggest is weak too.

## About AtCoder run environment
AtCoder has internal code test function, but local confirmation is my preference.
Without a terminal, the file input is need, but AtCoder only supports standard input. 

There's a trick for one code, run all. By using the platform difference between AtCoder and the local app, you can use local-only file input.

```python
# Pythonista
if sys.platform =='ios':
  sys.stdin=open('input1.txt')

# Python3IDE
if sys.platform =='darwin':
  sys.stdin=open('input1.txt')
```

## Finally
Custom keyboard often stands for hardware one for PC.
Creating a custom software keyboard for non-PC looks fun. I want to try it in the future.